Rails 中的富文本用户输入

发布于 07-20 12:31 字数 188 浏览 10 评论 0原文

在 Rails 中处理富文本用户输入的首选方法是什么? Markdown 看起来很有用,但我还没有找到一个看起来易于设置的编辑器,我也不知道如何处理 html 的清理。 (sanitize 帮助程序似乎仍然允许诸如 之类的内容,这会破坏我的布局)我想保证清理后的代码是有效的 XHTML Strict 。

What's the preferred way to handle rich text user input in rails? Markdown looks useful, but I haven't found an editor that looks simple to setup for it, nor am I sure how to handle sanitizing the html. (the sanitize helper still seems to allow stuff like </div>, which breaks my layout) I'd like to guarantee that the cleaned up code is valid XHTML Strict.

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

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

发布评论

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

评论(2

江南月2024-07-27 12:31:47

我选择了TinyMCE。 它允许我将返回的 HTML 代码清理为标签和属性。 有关详细信息,请参阅 valid_elements 选项的文档。

但要注意:如果有人直接发布垃圾(没有浏览器,例如使用curl),这些卫生功能将无济于事。 我在 TidyFFI 的帮助下使用 Tidy 来防止此类麻烦。

(抱歉,没有链接,因为我不允许发布此类恶意软件;-)

I chose TinyMCE. It allows me to sanitize the returned HTML code down to tags and attributes. See the documentation for the valid_elements option for details.

But beware: These sanitation feature don't help if someone POSTs rubbish directly (w/o a browser, e.g. using curl). I use Tidy with a little help by TidyFFI to prevent such troubles.

(Sorry, no links because I'm not allowed to post such kind of malware ;-)

牵强ㄟ2024-07-27 12:31:47

线程显示< Yahoo UI 库中的 href="http://developer.yahoo.com/yui/editor/" rel="nofollow noreferrer">编辑器 是一个很好的解决方案。 始终先尝试搜索功能! :)

From this thread it appears the editor in Yahoo's UI library is a good solution. Always try the search feature first! :)

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