2 * Full HTML5 compatibility rule set
3 * These rules define which tags and css classes are supported and which tags should be specially treated.
5 * Examples based on this rule set:
7 * <a href="http://foobar.com">foo</a>
9 * <a href="http://foobar.com" target="_blank" rel="nofollow">foo</a>
11 * <img align="left" src="http://foobar.com/image.png">
13 * <img class="wysiwyg-float-left" src="http://foobar.com/image.png" alt="">
15 * <div>foo<script>alert(document.cookie)</script></div>
19 * <marquee>foo</marquee>
23 * foo <br clear="both"> bar
25 * foo <br class="wysiwyg-clear-both"> bar
27 * <div>hello <iframe src="http://google.com"></iframe></div>
31 * <center>hello</center>
33 * <div class="wysiwyg-text-align-center">hello</div>
35 var wysihtml5ParserRules = {
37 * CSS Class white-list
38 * Following css classes won't be removed when parsed by the wysihtml5 html parser
41 "wysiwyg-clear-both": 1,
42 "wysiwyg-clear-left": 1,
43 "wysiwyg-clear-right": 1,
44 "wysiwyg-color-aqua": 1,
45 "wysiwyg-color-black": 1,
46 "wysiwyg-color-blue": 1,
47 "wysiwyg-color-fuchsia": 1,
48 "wysiwyg-color-gray": 1,
49 "wysiwyg-color-green": 1,
50 "wysiwyg-color-lime": 1,
51 "wysiwyg-color-maroon": 1,
52 "wysiwyg-color-navy": 1,
53 "wysiwyg-color-olive": 1,
54 "wysiwyg-color-purple": 1,
55 "wysiwyg-color-red": 1,
56 "wysiwyg-color-silver": 1,
57 "wysiwyg-color-teal": 1,
58 "wysiwyg-color-white": 1,
59 "wysiwyg-color-yellow": 1,
60 "wysiwyg-float-left": 1,
61 "wysiwyg-float-right": 1,
62 "wysiwyg-font-size-large": 1,
63 "wysiwyg-font-size-larger": 1,
64 "wysiwyg-font-size-medium": 1,
65 "wysiwyg-font-size-small": 1,
66 "wysiwyg-font-size-smaller": 1,
67 "wysiwyg-font-size-x-large": 1,
68 "wysiwyg-font-size-x-small": 1,
69 "wysiwyg-font-size-xx-large": 1,
70 "wysiwyg-font-size-xx-small": 1,
71 "wysiwyg-text-align-center": 1,
72 "wysiwyg-text-align-justify": 1,
73 "wysiwyg-text-align-left": 1,
74 "wysiwyg-text-align-right": 1
79 * Following options are available:
81 * - add_class: converts and deletes the given HTML4 attribute (align, clear, ...) via the given method to a css class
82 * The following methods are implemented in wysihtml5.dom.parse:
83 * - align_text: converts align attribute values (right/left/center/justify) to their corresponding css class "wysiwyg-text-align-*")
84 <p align="center">foo</p> ... becomes ... <p> class="wysiwyg-text-align-center">foo</p>
85 * - clear_br: converts clear attribute values left/right/all/both to their corresponding css class "wysiwyg-clear-*"
86 * <br clear="all"> ... becomes ... <br class="wysiwyg-clear-both">
87 * - align_img: converts align attribute values (right/left) on <img> to their corresponding css class "wysiwyg-float-*"
89 * - remove: removes the element and it's content
91 * - rename_tag: renames the element to the given tag
93 * - set_class: adds the given class to the element (note: make sure that the class is in the "classes" white list above)
95 * - set_attributes: sets/overrides the given attributes
97 * - check_attributes: checks the given HTML attribute via the given method
98 * - url: checks whether the given string is an url, deletes the attribute if not
99 * - alt: strips unwanted characters. if the attribute is not set, then it gets set (to ensure valid and compatible HTML)
100 * - numbers: ensures that the attribute only contains numeric characters
105 "align": "align_text"
131 "align": "align_text"
148 "rename_tag": "span",
149 "set_class": "wysiwyg-font-size-smaller"
180 "check_attributes": {
189 "check_attributes": {
229 "align": "align_text"
237 "align": "align_text"
248 "check_attributes": {
249 "rowspan": "numbers",
253 "align": "align_text"
261 "align": "align_text"
281 "rename_tag": "span",
282 "set_class": "wysiwyg-font-size-larger"
302 "align": "align_text"
319 "align": "align_text"
324 "align": "align_text"
345 "check_attributes": {
391 "check_attributes": {
406 "align": "align_text"
419 "rename_tag": "span",
432 "align": "align_text"
446 "align": "align_text"
453 "check_attributes": {
454 "rowspan": "numbers",
458 "align": "align_text"
486 "set_class": "wysiwyg-text-align-center"
524 "align": "align_text"
532 "align": "align_text"