FCKEditor 取代 &与 &;当从源视图切换到设计视图时?
我遇到的问题是,我安装的 FCKEditor 3.3.1 将所有 &
更改为 &
。
我在帖子中发布了很多链接,这使得它们无效。我在哪里可以定义 &
不被 &
替换?
谢谢 :-)
I have the problem that my installed FCKEditor 3.3.1 changes all &
to &
.
I am posting lots of links in my posts and this makes them invalid. Where can I define that &
ist NOT replaced with &
?
Thanks :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,你不能。 FCKEditor 做了正确的事。
HTML 中的独立
&
在任何情况下都不是错误。与号始终必须编码为&
- 除非它是转义序列本身的开始(如<
>)。HTML 源代码中的
&
会使链接无效,这是一种误解。事实并非如此。为了使 HTML 有效,其中的所有数据都必须经过 HTML 转义。 “数据”是指文本(标签之间)和属性值(如 href)。当解析 HTML 源代码时,解析器将自动对所有数据进行 HTML 转义,并且&
将在 DOM 中再次变为&
。不要让许多浏览器接受未转义的 & 符号这一事实欺骗了您。尽管如此,这是错误的(FCKEditor 只是尝试提供有效的 HTML)。No, you can't. FCKEditor does the right thing.
There is no situation where a standalone
&
in HTML is not an error. The ampersand always has to be encoded as&
- unless it is the start of an escape sequence itself (like in<
).It is a misconception that the
&
in the HTML source code would make a link invalid. It does not. For HTML to be valid, all data in it must be HTML-escaped. "Data" means both text (in-between tags) and attribute values (like href). When the HTML source is then parsed, the parser will automatically HTML-unescape all data and&
will become&
again in the DOM. Do not let the fact that many browsers accept an unescaped ampersand deceive you. It is wrong nevertheless (and FCKEditor just tries to deliver valid HTML).请参阅 FCKeditor 的 fckconfig.js 文件中的自定义设置。
Tomalak 对于如何呈现它是正确的,但我只是指出 FCKeditor 中有一个配置选项,以防您需要“打破规则”。在某些情况下这是必要的。将 & 符号呈现为真正的 HTML 实体 (&) 在某些 HTML 邮件客户端中不起作用,无论如何,这些客户端很少正确遵守 HTML 标准。如果您有一个额外的过滤器,可以在您的流程中进一步将其转换为 HTML 实体,则您可能需要强制使用普通的 & 符号。
See the custom setting in the fckconfig.js file for FCKeditor.
Tomalak is correct about how it should be presented but I'm just pointing out that there is a configuration option in FCKeditor, in case you need to "break the rules". There are situations where this is necessary. Rendering the ampersand as a true HTML entity (&) does not work in some HTML mail clients, which rarely adhere to HTML standards properly anyway. And you may need to force the plain ampersand if you have an additional filter that will convert it to an HTML entity further along your process.