rails-wysihtml5 0.3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +26 -0
- data/Rakefile +1 -0
- data/lib/generators/wysihtml5/parser_rules_generator.rb +9 -0
- data/lib/rails-wysihtml5.rb +6 -0
- data/lib/rails-wysihtml5/version.rb +3 -0
- data/lib/tasks/rails-wysihtml5_tasks.rake +4 -0
- data/rails-wysihtml5.gemspec +16 -0
- data/vendor/assets/javascripts/wysihtml5.js +9615 -0
- data/vendor/assets/javascripts/wysihtml5/parser_rules/advanced.js +553 -0
- data/vendor/assets/javascripts/wysihtml5/parser_rules/simple.js +32 -0
- metadata +57 -0
@@ -0,0 +1,553 @@
|
|
1
|
+
/**
|
2
|
+
* Full HTML5 compatibility rule set
|
3
|
+
* These rules define which tags and CSS classes are supported and which tags should be specially treated.
|
4
|
+
*
|
5
|
+
* Examples based on this rule set:
|
6
|
+
*
|
7
|
+
* <a href="http://foobar.com">foo</a>
|
8
|
+
* ... becomes ...
|
9
|
+
* <a href="http://foobar.com" target="_blank" rel="nofollow">foo</a>
|
10
|
+
*
|
11
|
+
* <img align="left" src="http://foobar.com/image.png">
|
12
|
+
* ... becomes ...
|
13
|
+
* <img class="wysiwyg-float-left" src="http://foobar.com/image.png" alt="">
|
14
|
+
*
|
15
|
+
* <div>foo<script>alert(document.cookie)</script></div>
|
16
|
+
* ... becomes ...
|
17
|
+
* <div>foo</div>
|
18
|
+
*
|
19
|
+
* <marquee>foo</marquee>
|
20
|
+
* ... becomes ...
|
21
|
+
* <span>foo</span>
|
22
|
+
*
|
23
|
+
* foo <br clear="both"> bar
|
24
|
+
* ... becomes ...
|
25
|
+
* foo <br class="wysiwyg-clear-both"> bar
|
26
|
+
*
|
27
|
+
* <div>hello <iframe src="http://google.com"></iframe></div>
|
28
|
+
* ... becomes ...
|
29
|
+
* <div>hello </div>
|
30
|
+
*
|
31
|
+
* <center>hello</center>
|
32
|
+
* ... becomes ...
|
33
|
+
* <div class="wysiwyg-text-align-center">hello</div>
|
34
|
+
*/
|
35
|
+
var wysihtml5ParserRules = {
|
36
|
+
/**
|
37
|
+
* CSS Class white-list
|
38
|
+
* Following CSS classes won't be removed when parsed by the wysihtml5 HTML parser
|
39
|
+
*/
|
40
|
+
"classes": {
|
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
|
75
|
+
},
|
76
|
+
/**
|
77
|
+
* Tag list
|
78
|
+
*
|
79
|
+
* The following options are available:
|
80
|
+
*
|
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-*"
|
88
|
+
*
|
89
|
+
* - remove: removes the element and its content
|
90
|
+
*
|
91
|
+
* - rename_tag: renames the element to the given tag
|
92
|
+
*
|
93
|
+
* - set_class: adds the given class to the element (note: make sure that the class is in the "classes" white list above)
|
94
|
+
*
|
95
|
+
* - set_attributes: sets/overrides the given attributes
|
96
|
+
*
|
97
|
+
* - check_attributes: checks the given HTML attribute via the given method
|
98
|
+
* - url: allows only valid urls (starting with http:// or https://)
|
99
|
+
* - src: allows something like "/foobar.jpg", "http://google.com", ...
|
100
|
+
* - href: allows something like "mailto:bert@foo.com", "http://google.com", "/foobar.jpg"
|
101
|
+
* - alt: strips unwanted characters. if the attribute is not set, then it gets set (to ensure valid and compatible HTML)
|
102
|
+
* - numbers: ensures that the attribute only contains numeric characters
|
103
|
+
*/
|
104
|
+
"tags": {
|
105
|
+
"tr": {
|
106
|
+
"add_class": {
|
107
|
+
"align": "align_text"
|
108
|
+
}
|
109
|
+
},
|
110
|
+
"strike": {
|
111
|
+
"remove": 1
|
112
|
+
},
|
113
|
+
"form": {
|
114
|
+
"rename_tag": "div"
|
115
|
+
},
|
116
|
+
"rt": {
|
117
|
+
"rename_tag": "span"
|
118
|
+
},
|
119
|
+
"code": {},
|
120
|
+
"acronym": {
|
121
|
+
"rename_tag": "span"
|
122
|
+
},
|
123
|
+
"br": {
|
124
|
+
"add_class": {
|
125
|
+
"clear": "clear_br"
|
126
|
+
}
|
127
|
+
},
|
128
|
+
"details": {
|
129
|
+
"rename_tag": "div"
|
130
|
+
},
|
131
|
+
"h4": {
|
132
|
+
"add_class": {
|
133
|
+
"align": "align_text"
|
134
|
+
}
|
135
|
+
},
|
136
|
+
"em": {},
|
137
|
+
"title": {
|
138
|
+
"remove": 1
|
139
|
+
},
|
140
|
+
"multicol": {
|
141
|
+
"rename_tag": "div"
|
142
|
+
},
|
143
|
+
"figure": {
|
144
|
+
"rename_tag": "div"
|
145
|
+
},
|
146
|
+
"xmp": {
|
147
|
+
"rename_tag": "span"
|
148
|
+
},
|
149
|
+
"small": {
|
150
|
+
"rename_tag": "span",
|
151
|
+
"set_class": "wysiwyg-font-size-smaller"
|
152
|
+
},
|
153
|
+
"area": {
|
154
|
+
"remove": 1
|
155
|
+
},
|
156
|
+
"time": {
|
157
|
+
"rename_tag": "span"
|
158
|
+
},
|
159
|
+
"dir": {
|
160
|
+
"rename_tag": "ul"
|
161
|
+
},
|
162
|
+
"bdi": {
|
163
|
+
"rename_tag": "span"
|
164
|
+
},
|
165
|
+
"command": {
|
166
|
+
"remove": 1
|
167
|
+
},
|
168
|
+
"ul": {},
|
169
|
+
"progress": {
|
170
|
+
"rename_tag": "span"
|
171
|
+
},
|
172
|
+
"dfn": {
|
173
|
+
"rename_tag": "span"
|
174
|
+
},
|
175
|
+
"iframe": {
|
176
|
+
"remove": 1
|
177
|
+
},
|
178
|
+
"figcaption": {
|
179
|
+
"rename_tag": "div"
|
180
|
+
},
|
181
|
+
"a": {
|
182
|
+
"check_attributes": {
|
183
|
+
"href": "href"
|
184
|
+
},
|
185
|
+
"set_attributes": {
|
186
|
+
"rel": "nofollow",
|
187
|
+
"target": "_blank"
|
188
|
+
}
|
189
|
+
},
|
190
|
+
"img": {
|
191
|
+
"check_attributes": {
|
192
|
+
"width": "numbers",
|
193
|
+
"alt": "alt",
|
194
|
+
"src": "src",
|
195
|
+
"height": "numbers"
|
196
|
+
},
|
197
|
+
"add_class": {
|
198
|
+
"align": "align_img"
|
199
|
+
}
|
200
|
+
},
|
201
|
+
"rb": {
|
202
|
+
"rename_tag": "span"
|
203
|
+
},
|
204
|
+
"footer": {
|
205
|
+
"rename_tag": "div"
|
206
|
+
},
|
207
|
+
"noframes": {
|
208
|
+
"remove": 1
|
209
|
+
},
|
210
|
+
"abbr": {
|
211
|
+
"rename_tag": "span"
|
212
|
+
},
|
213
|
+
"u": {},
|
214
|
+
"bgsound": {
|
215
|
+
"remove": 1
|
216
|
+
},
|
217
|
+
"sup": {
|
218
|
+
"rename_tag": "span"
|
219
|
+
},
|
220
|
+
"address": {
|
221
|
+
"rename_tag": "div"
|
222
|
+
},
|
223
|
+
"basefont": {
|
224
|
+
"remove": 1
|
225
|
+
},
|
226
|
+
"nav": {
|
227
|
+
"rename_tag": "div"
|
228
|
+
},
|
229
|
+
"h1": {
|
230
|
+
"add_class": {
|
231
|
+
"align": "align_text"
|
232
|
+
}
|
233
|
+
},
|
234
|
+
"head": {
|
235
|
+
"remove": 1
|
236
|
+
},
|
237
|
+
"tbody": {
|
238
|
+
"add_class": {
|
239
|
+
"align": "align_text"
|
240
|
+
}
|
241
|
+
},
|
242
|
+
"dd": {
|
243
|
+
"rename_tag": "div"
|
244
|
+
},
|
245
|
+
"s": {
|
246
|
+
"rename_tag": "span"
|
247
|
+
},
|
248
|
+
"li": {},
|
249
|
+
"td": {
|
250
|
+
"check_attributes": {
|
251
|
+
"rowspan": "numbers",
|
252
|
+
"colspan": "numbers"
|
253
|
+
},
|
254
|
+
"add_class": {
|
255
|
+
"align": "align_text"
|
256
|
+
}
|
257
|
+
},
|
258
|
+
"object": {
|
259
|
+
"remove": 1
|
260
|
+
},
|
261
|
+
"div": {
|
262
|
+
"add_class": {
|
263
|
+
"align": "align_text"
|
264
|
+
}
|
265
|
+
},
|
266
|
+
"option": {
|
267
|
+
"rename_tag": "span"
|
268
|
+
},
|
269
|
+
"select": {
|
270
|
+
"rename_tag": "span"
|
271
|
+
},
|
272
|
+
"i": {},
|
273
|
+
"track": {
|
274
|
+
"remove": 1
|
275
|
+
},
|
276
|
+
"wbr": {
|
277
|
+
"remove": 1
|
278
|
+
},
|
279
|
+
"fieldset": {
|
280
|
+
"rename_tag": "div"
|
281
|
+
},
|
282
|
+
"big": {
|
283
|
+
"rename_tag": "span",
|
284
|
+
"set_class": "wysiwyg-font-size-larger"
|
285
|
+
},
|
286
|
+
"button": {
|
287
|
+
"rename_tag": "span"
|
288
|
+
},
|
289
|
+
"noscript": {
|
290
|
+
"remove": 1
|
291
|
+
},
|
292
|
+
"svg": {
|
293
|
+
"remove": 1
|
294
|
+
},
|
295
|
+
"input": {
|
296
|
+
"remove": 1
|
297
|
+
},
|
298
|
+
"table": {},
|
299
|
+
"keygen": {
|
300
|
+
"remove": 1
|
301
|
+
},
|
302
|
+
"h5": {
|
303
|
+
"add_class": {
|
304
|
+
"align": "align_text"
|
305
|
+
}
|
306
|
+
},
|
307
|
+
"meta": {
|
308
|
+
"remove": 1
|
309
|
+
},
|
310
|
+
"map": {
|
311
|
+
"rename_tag": "div"
|
312
|
+
},
|
313
|
+
"isindex": {
|
314
|
+
"remove": 1
|
315
|
+
},
|
316
|
+
"mark": {
|
317
|
+
"rename_tag": "span"
|
318
|
+
},
|
319
|
+
"caption": {
|
320
|
+
"add_class": {
|
321
|
+
"align": "align_text"
|
322
|
+
}
|
323
|
+
},
|
324
|
+
"tfoot": {
|
325
|
+
"add_class": {
|
326
|
+
"align": "align_text"
|
327
|
+
}
|
328
|
+
},
|
329
|
+
"base": {
|
330
|
+
"remove": 1
|
331
|
+
},
|
332
|
+
"video": {
|
333
|
+
"remove": 1
|
334
|
+
},
|
335
|
+
"strong": {},
|
336
|
+
"canvas": {
|
337
|
+
"remove": 1
|
338
|
+
},
|
339
|
+
"output": {
|
340
|
+
"rename_tag": "span"
|
341
|
+
},
|
342
|
+
"marquee": {
|
343
|
+
"rename_tag": "span"
|
344
|
+
},
|
345
|
+
"b": {},
|
346
|
+
"q": {
|
347
|
+
"check_attributes": {
|
348
|
+
"cite": "url"
|
349
|
+
}
|
350
|
+
},
|
351
|
+
"applet": {
|
352
|
+
"remove": 1
|
353
|
+
},
|
354
|
+
"span": {},
|
355
|
+
"rp": {
|
356
|
+
"rename_tag": "span"
|
357
|
+
},
|
358
|
+
"spacer": {
|
359
|
+
"remove": 1
|
360
|
+
},
|
361
|
+
"source": {
|
362
|
+
"remove": 1
|
363
|
+
},
|
364
|
+
"aside": {
|
365
|
+
"rename_tag": "div"
|
366
|
+
},
|
367
|
+
"frame": {
|
368
|
+
"remove": 1
|
369
|
+
},
|
370
|
+
"section": {
|
371
|
+
"rename_tag": "div"
|
372
|
+
},
|
373
|
+
"body": {
|
374
|
+
"rename_tag": "div"
|
375
|
+
},
|
376
|
+
"ol": {},
|
377
|
+
"nobr": {
|
378
|
+
"rename_tag": "span"
|
379
|
+
},
|
380
|
+
"html": {
|
381
|
+
"rename_tag": "div"
|
382
|
+
},
|
383
|
+
"summary": {
|
384
|
+
"rename_tag": "span"
|
385
|
+
},
|
386
|
+
"var": {
|
387
|
+
"rename_tag": "span"
|
388
|
+
},
|
389
|
+
"del": {
|
390
|
+
"remove": 1
|
391
|
+
},
|
392
|
+
"blockquote": {
|
393
|
+
"check_attributes": {
|
394
|
+
"cite": "url"
|
395
|
+
}
|
396
|
+
},
|
397
|
+
"style": {
|
398
|
+
"remove": 1
|
399
|
+
},
|
400
|
+
"device": {
|
401
|
+
"remove": 1
|
402
|
+
},
|
403
|
+
"meter": {
|
404
|
+
"rename_tag": "span"
|
405
|
+
},
|
406
|
+
"h3": {
|
407
|
+
"add_class": {
|
408
|
+
"align": "align_text"
|
409
|
+
}
|
410
|
+
},
|
411
|
+
"textarea": {
|
412
|
+
"rename_tag": "span"
|
413
|
+
},
|
414
|
+
"embed": {
|
415
|
+
"remove": 1
|
416
|
+
},
|
417
|
+
"hgroup": {
|
418
|
+
"rename_tag": "div"
|
419
|
+
},
|
420
|
+
"font": {
|
421
|
+
"rename_tag": "span",
|
422
|
+
"add_class": {
|
423
|
+
"size": "size_font"
|
424
|
+
}
|
425
|
+
},
|
426
|
+
"tt": {
|
427
|
+
"rename_tag": "span"
|
428
|
+
},
|
429
|
+
"noembed": {
|
430
|
+
"remove": 1
|
431
|
+
},
|
432
|
+
"thead": {
|
433
|
+
"add_class": {
|
434
|
+
"align": "align_text"
|
435
|
+
}
|
436
|
+
},
|
437
|
+
"blink": {
|
438
|
+
"rename_tag": "span"
|
439
|
+
},
|
440
|
+
"plaintext": {
|
441
|
+
"rename_tag": "span"
|
442
|
+
},
|
443
|
+
"xml": {
|
444
|
+
"remove": 1
|
445
|
+
},
|
446
|
+
"h6": {
|
447
|
+
"add_class": {
|
448
|
+
"align": "align_text"
|
449
|
+
}
|
450
|
+
},
|
451
|
+
"param": {
|
452
|
+
"remove": 1
|
453
|
+
},
|
454
|
+
"th": {
|
455
|
+
"check_attributes": {
|
456
|
+
"rowspan": "numbers",
|
457
|
+
"colspan": "numbers"
|
458
|
+
},
|
459
|
+
"add_class": {
|
460
|
+
"align": "align_text"
|
461
|
+
}
|
462
|
+
},
|
463
|
+
"legend": {
|
464
|
+
"rename_tag": "span"
|
465
|
+
},
|
466
|
+
"hr": {},
|
467
|
+
"label": {
|
468
|
+
"rename_tag": "span"
|
469
|
+
},
|
470
|
+
"dl": {
|
471
|
+
"rename_tag": "div"
|
472
|
+
},
|
473
|
+
"kbd": {
|
474
|
+
"rename_tag": "span"
|
475
|
+
},
|
476
|
+
"listing": {
|
477
|
+
"rename_tag": "div"
|
478
|
+
},
|
479
|
+
"dt": {
|
480
|
+
"rename_tag": "span"
|
481
|
+
},
|
482
|
+
"nextid": {
|
483
|
+
"remove": 1
|
484
|
+
},
|
485
|
+
"pre": {},
|
486
|
+
"center": {
|
487
|
+
"rename_tag": "div",
|
488
|
+
"set_class": "wysiwyg-text-align-center"
|
489
|
+
},
|
490
|
+
"audio": {
|
491
|
+
"remove": 1
|
492
|
+
},
|
493
|
+
"datalist": {
|
494
|
+
"rename_tag": "span"
|
495
|
+
},
|
496
|
+
"samp": {
|
497
|
+
"rename_tag": "span"
|
498
|
+
},
|
499
|
+
"col": {
|
500
|
+
"remove": 1
|
501
|
+
},
|
502
|
+
"article": {
|
503
|
+
"rename_tag": "div"
|
504
|
+
},
|
505
|
+
"cite": {},
|
506
|
+
"link": {
|
507
|
+
"remove": 1
|
508
|
+
},
|
509
|
+
"script": {
|
510
|
+
"remove": 1
|
511
|
+
},
|
512
|
+
"bdo": {
|
513
|
+
"rename_tag": "span"
|
514
|
+
},
|
515
|
+
"menu": {
|
516
|
+
"rename_tag": "ul"
|
517
|
+
},
|
518
|
+
"colgroup": {
|
519
|
+
"remove": 1
|
520
|
+
},
|
521
|
+
"ruby": {
|
522
|
+
"rename_tag": "span"
|
523
|
+
},
|
524
|
+
"h2": {
|
525
|
+
"add_class": {
|
526
|
+
"align": "align_text"
|
527
|
+
}
|
528
|
+
},
|
529
|
+
"ins": {
|
530
|
+
"rename_tag": "span"
|
531
|
+
},
|
532
|
+
"p": {
|
533
|
+
"add_class": {
|
534
|
+
"align": "align_text"
|
535
|
+
}
|
536
|
+
},
|
537
|
+
"sub": {
|
538
|
+
"rename_tag": "span"
|
539
|
+
},
|
540
|
+
"comment": {
|
541
|
+
"remove": 1
|
542
|
+
},
|
543
|
+
"frameset": {
|
544
|
+
"remove": 1
|
545
|
+
},
|
546
|
+
"optgroup": {
|
547
|
+
"rename_tag": "span"
|
548
|
+
},
|
549
|
+
"header": {
|
550
|
+
"rename_tag": "div"
|
551
|
+
}
|
552
|
+
}
|
553
|
+
};
|