html - Microsoft Word/Outlook 修剪前导空格

标签 html ms-word outlook editor trim

我使用 Word 作为编辑器,通过 Outlook 将 SQL 作为 HTML 发送给感兴趣的各方。

我喜欢使用空格而不是制表符来格式化我的 SQL。

当我将 SQL 粘贴到编辑器中时,格式正确。 但“已发送”版本删除了前导空格。

例如:

Select
 *
From
 Employees

成为

Select
*
From
Employees

是否有防止这种情况发生的选项?

最佳答案

我没有找到解决方案,但找到了解决方法 - 将所有(且仅)前导空格替换为 Nonbreaking Spaces。无需替换所有的空格,只需替换前导空格。这样 Outlook 就不会在发送电子邮件时自动修剪它们。

发送邮件前需要

  1. 选中要保留前导空格的文本,运行查找和替换(Ctrl+H)
  2. 放入Find what: "^p " (caret, p, space) 或点击底部的[Special] 按钮和选择段落标记和一个空格字符
  3. 放入替换为: "^p^s" (caret, p, caret, s) 或点击底部的[Special] 按钮并选择段落标记不间断空格
  4. 现在按[全部替换] - 它将仅在所选文本中用不间断空格替换前导空格,其余所有文本保持不变。

带前导空格的结果:

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/

相关文章:

c# - 在word文档的页脚中添加从第n页开始的页码

python - 如何使用 python win32com 访问除默认文件夹(如收件箱、已发送)以外的 outlook 文件夹?

vba - 查看附件是嵌入的还是附加的

javascript - 动态注入(inject) SVG 过滤器并应用于 HTML

php - 在mysql文本字段中存储一个变量

java - 使用 Selenium Java 测试用例调用 CLICK 时获取 "org.openqa.selenium.ElementClickInterceptedException"

html - 侧边栏位置

vba - 从 VBScript 调用外部 VBA

vba - 在 Word 2016 for Mac 中创建对象 ("Excel.Application")

测试 Outlook VSTO 插件