我使用 Word 作为编辑器,通过 Outlook 将 SQL 作为 HTML 发送给感兴趣的各方。
我喜欢使用空格而不是制表符来格式化我的 SQL。
当我将 SQL 粘贴到编辑器中时,格式正确。 但“已发送”版本删除了前导空格。
例如:
Select
*
From
Employees
成为
Select
*
From
Employees
是否有防止这种情况发生的选项?
最佳答案
我没有找到解决方案,但找到了解决方法 - 将所有(且仅)前导空格替换为 Nonbreaking Spaces。无需替换所有的空格,只需替换前导空格。这样 Outlook 就不会在发送电子邮件时自动修剪它们。
发送邮件前需要
- 选中要保留前导空格的文本,运行查找和替换(Ctrl+H)
- 放入Find what:
"^p "
(caret, p, space) 或点击底部的[Special] 按钮和选择段落标记和一个空格字符 - 放入替换为:
"^p^s"
(caret, p, caret, s) 或点击底部的[Special] 按钮并选择段落标记和不间断空格 - 现在按[全部替换] - 它将仅在所选文本中用不间断空格替换前导空格,其余所有文本保持不变。
带前导空格的结果:
First without leading spaces
One leading space in this row
No leading spaces again
One leading space in this row
Two leading spaces here
One leading space in this row
No leading spaces again
One leading space in this row
Two leading spaces here
Two leading spaces here
One leading space in this row
Two leading spaces here
Two leading spaces here
Three leading spaces here
前导不间断空格:
First without leading spaces
One leading space in this row
No leading spaces again
One leading space in this row
Two leading spaces here
One leading space in this row
No leading spaces again
One leading space in this row
Two leading spaces here
Two leading spaces here
One leading space in this row
Two leading spaces here
Two leading spaces here
Three leading spaces here
关于html - Microsoft Word/Outlook 修剪前导空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29128145/