清理django-cms编辑器和HTML数据属性 [英] django-cms editors and HTML data attribute cleaned up

查看:160
本文介绍了清理django-cms编辑器和HTML数据属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用django-cms 2.4我需要创建包含引导代码的页面,但html5lib用于清除data- *属性。无论您是否在TINYMCE_DEFAULT_CONFIG中指定valid_element。 (我仍然在为Wymeditor寻找类似的选项),因为这是在#plugins / text / models(clean_html函数: https://github.com/divio/django-cms/issues/1529

Using django-cms 2.4 I need to create pages that contain bootstrap code, but the html5lib used cleans data-* attributes. No matter if you specify valid_element in TINYMCE_DEFAULT_CONFIG. (I still looking for a similar option for Wymeditor), because this is done in #plugins/text/models (clean_html function: https://github.com/divio/django-cms/issues/1529 )

Github问题:
https://github.com/divio/django-cms/issues/1529

Github issue: https://github.com/divio/django-cms/issues/1529

可能的解决方法是什么?
如何在管理员部分扩展文本插件?

What could it be a possible workaround? How can I extend the text plugin in the admin part?

谢谢!

推荐答案

我相信删除字段是由html5lib完成的,cms用作python包,您需要打开html5lib文件夹并打开sanitizer.py,第184行代码为:

i belive the removing of the fields is done by html5lib that the cms uses as python package, you'll need to open html5lib folder and open sanitizer.py, in line 184 where the code is:

if name in self.allowed_attributes])

更改为:

if name in self.allowed_attributes or re.match( r'data-.*',name)]) 

这将允许所有数据 - (任何)属性

this will allow all data-(whatever) attributes

对于WYMeditor,数据(无论什么)属性已被允许

for WYMeditor the data-(whatever) attribute is already allowed

这篇关于清理django-cms编辑器和HTML数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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