保持用户生成的内容不会破坏布局? [英] keep user-generated content from breaking layout?

查看:77
本文介绍了保持用户生成的内容不会破坏布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站包装了一些用户生成的内容,我希望能够将布局的标记和用户生成内容的标记分开,因此ug内容不会破坏网站布局。

用户生成的内容是可信的,因为它来自我网络上已知的一组用户,但是只允许一小部分html标签( p,ul / ol / li,em,strong和更多)。但是,用户生成的内容不能保证格式正确,而且我们有一些格式错误的用户生成内容会破坏网站的布局。



我们正在与我们的用户合作,以​​保持内容的完整性,但同时我正试图找到一种将内容与布局分开的好方法。我一直在寻找命名空间,但一直无法找到关于CSS支持嵌入式命名空间的良好文档。



任何人有任何好主意?



编辑



我在这里看到了一些非常好的建议,但我应该澄清一下,对用户使用的输入机制不进行控制。他们正在将内容输入到一个系统中,而我的页面使用该系统的API将内容从中拉出。该系统使用TinyMCE,但正如我所说,我们仍然收到一些格式不正确的内容。

>

也许矫枉过正,但 HTML
Tidy

a
可以帮助您使用它。 .moxiecode.com /rel =nofollow noreferrer> TinyMCE

CKEditor 已经建立了清理方法。




看起来非常出色,尤其是考虑到您只允许使用一些无害的格式标签。



我不认为用CSS可以做任何事情来阻止布局由于打开HTML标签而中断,所以我可能会f或者说这个想法。


I have a site that wraps some user-generated content, and I want to be able to separate the markup for the layout, and the markup from the user-generated content, so the u-g content can't break the site layout.

The user-generated content is trusted, as it is coming from a known group of users on my network, but nonetheless only a small subset of html tags are allowed (p, ul/ol/li, em, strong, and a couple more). However, the user-generated content is not guaranteed to be well-formed, and we have had some instances of malformed user-generated content breaking the layout of the site.

We are working with our users to keep the content well-formed, but in the meantime I am trying to find a good way to separate the content from the layout. I have been looking into namespaces, but have been unable to find good documentation about CSS support for embedded namespaces.

Anyone have any good ideas?

EDIT

I have seen some really good suggestions here, but I should probably clarify that I have absolutely no control over the input mechanism that the users use. They are entering content into one system, and my page uses that system's API to pull content out of it. That system is using TinyMCE, but like I said, we are still getting some malformed content.

解决方案

Robert Koritnik's suggestion to use markdown seems brilliant, especially considering that you only allow a few harmless formatting tags.

I don't think there's anything you can do with CSS to stop layouts from breaking due to open HTML tags, so I would probably forget that idea.

这篇关于保持用户生成的内容不会破坏布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆