jQuery/Javascript:整洁的 html

发布于 2024-08-23 20:11:10 字数 121 浏览 6 评论 0原文

我的 cms 中有一个 html-wysiwyg 编辑器,我想知道 - 是否有一个好的脚本来整理 html 客户端?我主要是在处理从 winword 粘贴的 html。 也许一些正则表达式已经有帮助了。

提前致谢

i'm got a little html-wysiwyg editor in my cms and was wondering - is there a good script for tidying up html client-side? i'm mainly struggling with html that's pasted from winword.
maybe some regex would help already.

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Spring初心 2024-08-30 20:11:10

从 WORD 粘贴到所见即所得编辑器通常是一个坏主意。有些编辑试图清理这个问题,但没有一个做得完美。 FCK编辑器具有strip-WORD功能,但它并不是万无一失的。

WORD 做了一些愚蠢的事情,例如: some单词,程序很难检测和修复。你最终会得到各种多余的标记,这可能会把事情搞砸。

唯一安全的选择是删除所有标记(即使其成为纯文本)并允许用户在编辑器中修复它。

Pasting from WORD into a WYSIWYG editor is usually a bad idea. There are editors that try to clean this up, but none of them do a perfect job. FCK editor has a strip-WORD feature, but it's not fool-proof.

WORD does some dumb things like: <bold>some <bold></bold> words</bold>, which are difficult for programs to detect and fix. You end up with all kinds of superfluous mark-up that can mess things up.

The only safe bet is to strip out ALL of the markup (i.e. make it plain text) and allow the user to fix it up in the editor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文