0

我将样式文本从 MS word 复制/粘贴到在线文本编辑器。当我使用 JavaScriptclipboardData.getData("text/html")获取 htmlstring 时,我可以看到文本已经转换为 HTML/CSS 样式,例如 indent 将转换为text-indent="10dp". 并将"\t"替换为"     ". 有没有办法保留文本中的所有控制字符?

另外,我不知道CRLF来自哪里?

从 HTML 字符串

THE BOAT did not sail until late afternoon, but so eager was **CRLF**
Robert Townsend to get home that he thought, had there been a day as long as **CRLF**
this.

原来的

THE BOAT did not sail until late afternoon, but so eager was Robert Townsend to get home that he thought, had there been a day as long as this.

编辑

对不起,也许我的问题之前不够清楚。当我通过 doc.body.textContent||doc.body.innerText 剥离 html 字符串时,我仍然在结果字符串中得到 CRLF,那么如何摆脱那些样式标记。就像 clipboardData.getData("text") 一样吗?

4

1 回答 1

0

多余的空格和 CRLF 在 HTML 中是没有意义的,你可以忽略它们;你会在需要的地方找到硬休息(

于 2013-01-22T09:13:53.520 回答