selma 0.0.2-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1133 @@
1
+ use enum_iterator::{all, Sequence};
2
+ use lol_html::html_content::Element;
3
+
4
+ #[derive(Copy, Clone)]
5
+ pub struct Tag {
6
+ pub name: &'static str,
7
+ pub index: usize,
8
+ // Note that while lol_html::Element has `.is_self_closing()`, it's not
9
+ // accurate. For example, `<br>` is self-closing, but not explicitly as such (`<br/>`),
10
+ // so it's not considered self-closing by lol_html. We need to know this when removing
11
+ // tags and text, so we need to track it ourselves.
12
+ pub self_closing: bool,
13
+ }
14
+
15
+ #[derive(Copy, Clone, Sequence)]
16
+ pub enum HTMLTag {
17
+ HTML = 0,
18
+ HEAD,
19
+ TITLE,
20
+ BASE,
21
+ LINK,
22
+ META,
23
+ STYLE,
24
+ SCRIPT,
25
+ NOSCRIPT,
26
+ TEMPLATE,
27
+ BODY,
28
+ ARTICLE,
29
+ SECTION,
30
+ NAV,
31
+ ASIDE,
32
+ H1,
33
+ H2,
34
+ H3,
35
+ H4,
36
+ H5,
37
+ H6,
38
+ HGROUP,
39
+ HEADER,
40
+ FOOTER,
41
+ ADDRESS,
42
+ P,
43
+ HR,
44
+ PRE,
45
+ BLOCKQUOTE,
46
+ OL,
47
+ UL,
48
+ LI,
49
+ DL,
50
+ DT,
51
+ DD,
52
+ FIGURE,
53
+ FIGCAPTION,
54
+ MAIN,
55
+ DIV,
56
+ A,
57
+ EM,
58
+ STRONG,
59
+ SMALL,
60
+ S,
61
+ CITE,
62
+ Q,
63
+ DFN,
64
+ ABBR,
65
+ DATA,
66
+ TIME,
67
+ CODE,
68
+ VAR,
69
+ SAMP,
70
+ KBD,
71
+ SUB,
72
+ SUP,
73
+ I,
74
+ B,
75
+ U,
76
+ MARK,
77
+ RUBY,
78
+ RT,
79
+ RP,
80
+ BDI,
81
+ BDO,
82
+ SPAN,
83
+ BR,
84
+ WBR,
85
+ INS,
86
+ DEL,
87
+ IMAGE,
88
+ IMG,
89
+ IFRAME,
90
+ EMBED,
91
+ OBJECT,
92
+ PARAM,
93
+ VIDEO,
94
+ AUDIO,
95
+ SOURCE,
96
+ TRACK,
97
+ CANVAS,
98
+ MAP,
99
+ AREA,
100
+ MATH,
101
+ MI,
102
+ MO,
103
+ MN,
104
+ MS,
105
+ MTEXT,
106
+ MGLYPH,
107
+ MALIGNMARK,
108
+ ANNOTATION, // Gumbo calls this "GUMBO_TAG_ANNOTATION_XML"
109
+ SVG,
110
+ FOREIGNOBJECT,
111
+ DESC,
112
+ TABLE,
113
+ CAPTION,
114
+ COLGROUP,
115
+ COL,
116
+ TBODY,
117
+ THEAD,
118
+ TFOOT,
119
+ TR,
120
+ TD,
121
+ TH,
122
+ FORM,
123
+ FIELDSET,
124
+ LEGEND,
125
+ LABEL,
126
+ INPUT,
127
+ BUTTON,
128
+ SELECT,
129
+ DATALIST,
130
+ OPTGROUP,
131
+ OPTION,
132
+ TEXTAREA,
133
+ KEYGEN,
134
+ OUTPUT,
135
+ PROGRESS,
136
+ METER,
137
+ DETAILS,
138
+ SUMMARY,
139
+ MENU,
140
+ MENUITEM,
141
+ APPLET,
142
+ ACRONYM,
143
+ BGSOUND,
144
+ DIR,
145
+ FRAME,
146
+ FRAMESET,
147
+ NOFRAMES,
148
+ LISTING,
149
+ XMP,
150
+ NEXTID,
151
+ NOEMBED,
152
+ PLAINTEXT,
153
+ RB,
154
+ STRIKE,
155
+ BASEFONT,
156
+ BIG,
157
+ BLINK,
158
+ CENTER,
159
+ FONT,
160
+ MARQUEE,
161
+ MULTICOL,
162
+ NOBR,
163
+ SPACER,
164
+ TT,
165
+ RTC,
166
+ DIALOG,
167
+ UNKNOWN,
168
+ }
169
+
170
+ impl Tag {
171
+ pub const TAG_COUNT: usize = 151;
172
+
173
+ /// Identifies whether this is an HTML tag whose contents
174
+ /// are considered "text nodes", and thus, must be removed
175
+ pub fn has_text_content(tag: Tag) -> bool {
176
+ tag.index == HTMLTag::SCRIPT as usize
177
+ || tag.index == HTMLTag::STYLE as usize
178
+ || tag.index == HTMLTag::MATH as usize
179
+ || tag.index == HTMLTag::SVG as usize
180
+ }
181
+
182
+ /// Is this tag an `<iframe>`?
183
+ pub fn is_iframe(tag: Tag) -> bool {
184
+ tag.index == HTMLTag::IFRAME as usize
185
+ }
186
+
187
+ /// Is this tag a `<meta>`?
188
+ pub fn is_meta(tag: Tag) -> bool {
189
+ tag.index == HTMLTag::META as usize
190
+ }
191
+
192
+ /// Is this tag something which needs to be removed?
193
+ pub fn is_tag_escapeworthy(tag: Tag) -> bool {
194
+ tag.index == HTMLTag::TITLE as usize
195
+ || tag.index == HTMLTag::TEXTAREA as usize
196
+ || tag.index == HTMLTag::STYLE as usize
197
+ || tag.index == HTMLTag::XMP as usize
198
+ || tag.index == HTMLTag::IFRAME as usize
199
+ || tag.index == HTMLTag::NOEMBED as usize
200
+ || tag.index == HTMLTag::NOFRAMES as usize
201
+ || tag.index == HTMLTag::SCRIPT as usize
202
+ || tag.index == HTMLTag::PLAINTEXT as usize
203
+ }
204
+
205
+ pub const ESCAPEWORTHY_TAGS_CSS: &str =
206
+ "title, textarea, style, xmp, iframe, noembed, noframes, script, plaintext";
207
+
208
+ pub fn html_tags() -> Vec<HTMLTag> {
209
+ all::<HTMLTag>().collect::<Vec<_>>()
210
+ }
211
+
212
+ pub fn tag_from_element(element: &mut Element) -> Tag {
213
+ Self::tag_from_tag_name(element.tag_name().to_lowercase().as_str())
214
+ }
215
+
216
+ pub fn tag_from_tag_name(tag_name: &str) -> Tag {
217
+ {
218
+ match tag_name {
219
+ "html" => Tag {
220
+ name: "html",
221
+ index: 0,
222
+ self_closing: false,
223
+ },
224
+ "head" => Tag {
225
+ name: "head",
226
+ index: 1,
227
+ self_closing: false,
228
+ },
229
+ "title" => Tag {
230
+ name: "title",
231
+ index: 2,
232
+ self_closing: false,
233
+ },
234
+ "base" => Tag {
235
+ name: "base",
236
+ index: 3,
237
+ self_closing: true,
238
+ },
239
+ "link" => Tag {
240
+ name: "link",
241
+ index: 4,
242
+ self_closing: true,
243
+ },
244
+ "meta" => Tag {
245
+ name: "meta",
246
+ index: 5,
247
+ self_closing: true,
248
+ },
249
+ "style" => Tag {
250
+ name: "style",
251
+ index: 6,
252
+ self_closing: false,
253
+ },
254
+ "script" => Tag {
255
+ name: "script",
256
+ index: 7,
257
+ self_closing: false,
258
+ },
259
+ "noscript" => Tag {
260
+ name: "noscript",
261
+ index: 8,
262
+ self_closing: false,
263
+ },
264
+ "template" => Tag {
265
+ name: "template",
266
+ index: 9,
267
+ self_closing: false,
268
+ },
269
+ "body" => Tag {
270
+ name: "body",
271
+ index: 10,
272
+ self_closing: false,
273
+ },
274
+ "article" => Tag {
275
+ name: "article",
276
+ index: 11,
277
+ self_closing: false,
278
+ },
279
+ "section" => Tag {
280
+ name: "section",
281
+ index: 12,
282
+ self_closing: false,
283
+ },
284
+ "nav" => Tag {
285
+ name: "nav",
286
+ index: 13,
287
+ self_closing: false,
288
+ },
289
+ "aside" => Tag {
290
+ name: "aside",
291
+ index: 14,
292
+ self_closing: false,
293
+ },
294
+ "h1" => Tag {
295
+ name: "h1",
296
+ index: 15,
297
+ self_closing: false,
298
+ },
299
+ "h2" => Tag {
300
+ name: "h2",
301
+ index: 16,
302
+ self_closing: false,
303
+ },
304
+ "h3" => Tag {
305
+ name: "h3",
306
+ index: 17,
307
+ self_closing: false,
308
+ },
309
+ "h4" => Tag {
310
+ name: "h4",
311
+ index: 18,
312
+ self_closing: false,
313
+ },
314
+ "h5" => Tag {
315
+ name: "h5",
316
+ index: 19,
317
+ self_closing: false,
318
+ },
319
+ "h6" => Tag {
320
+ name: "h6",
321
+ index: 20,
322
+ self_closing: false,
323
+ },
324
+ "hgroup" => Tag {
325
+ name: "hgroup",
326
+ index: 21,
327
+ self_closing: false,
328
+ },
329
+ "header" => Tag {
330
+ name: "header",
331
+ index: 22,
332
+ self_closing: false,
333
+ },
334
+ "footer" => Tag {
335
+ name: "footer",
336
+ index: 23,
337
+ self_closing: false,
338
+ },
339
+ "address" => Tag {
340
+ name: "address",
341
+ index: 24,
342
+ self_closing: false,
343
+ },
344
+ "p" => Tag {
345
+ name: "p",
346
+ index: 25,
347
+ self_closing: false,
348
+ },
349
+ "hr" => Tag {
350
+ name: "hr",
351
+ index: 26,
352
+ self_closing: true,
353
+ },
354
+ "pre" => Tag {
355
+ name: "pre",
356
+ index: 27,
357
+ self_closing: false,
358
+ },
359
+ "blockquote" => Tag {
360
+ name: "blockquote",
361
+ index: 28,
362
+ self_closing: false,
363
+ },
364
+ "ol" => Tag {
365
+ name: "ol",
366
+ index: 29,
367
+ self_closing: false,
368
+ },
369
+ "ul" => Tag {
370
+ name: "ul",
371
+ index: 30,
372
+ self_closing: false,
373
+ },
374
+ "li" => Tag {
375
+ name: "li",
376
+ index: 31,
377
+ self_closing: false,
378
+ },
379
+ "dl" => Tag {
380
+ name: "dl",
381
+ index: 32,
382
+ self_closing: false,
383
+ },
384
+ "dt" => Tag {
385
+ name: "dt",
386
+ index: 33,
387
+ self_closing: false,
388
+ },
389
+ "dd" => Tag {
390
+ name: "dd",
391
+ index: 34,
392
+ self_closing: false,
393
+ },
394
+ "figure" => Tag {
395
+ name: "figure",
396
+ index: 35,
397
+ self_closing: false,
398
+ },
399
+ "figcaption" => Tag {
400
+ name: "figcaption",
401
+ index: 36,
402
+ self_closing: false,
403
+ },
404
+ "main" => Tag {
405
+ name: "main",
406
+ index: 37,
407
+ self_closing: false,
408
+ },
409
+ "div" => Tag {
410
+ name: "div",
411
+ index: 38,
412
+ self_closing: false,
413
+ },
414
+ "a" => Tag {
415
+ name: "a",
416
+ index: 39,
417
+ self_closing: false,
418
+ },
419
+ "em" => Tag {
420
+ name: "em",
421
+ index: 40,
422
+ self_closing: false,
423
+ },
424
+ "strong" => Tag {
425
+ name: "strong",
426
+ index: 41,
427
+ self_closing: false,
428
+ },
429
+ "small" => Tag {
430
+ name: "small",
431
+ index: 42,
432
+ self_closing: false,
433
+ },
434
+ "s" => Tag {
435
+ name: "s",
436
+ index: 43,
437
+ self_closing: false,
438
+ },
439
+ "cite" => Tag {
440
+ name: "cite",
441
+ index: 44,
442
+ self_closing: false,
443
+ },
444
+ "q" => Tag {
445
+ name: "q",
446
+ index: 45,
447
+ self_closing: false,
448
+ },
449
+ "dfn" => Tag {
450
+ name: "dfn",
451
+ index: 46,
452
+ self_closing: false,
453
+ },
454
+ "abbr" => Tag {
455
+ name: "abbr",
456
+ index: 47,
457
+ self_closing: false,
458
+ },
459
+ "data" => Tag {
460
+ name: "data",
461
+ index: 48,
462
+ self_closing: false,
463
+ },
464
+ "time" => Tag {
465
+ name: "time",
466
+ index: 49,
467
+ self_closing: false,
468
+ },
469
+ "code" => Tag {
470
+ name: "code",
471
+ index: 50,
472
+ self_closing: false,
473
+ },
474
+ "var" => Tag {
475
+ name: "var",
476
+ index: 51,
477
+ self_closing: false,
478
+ },
479
+ "samp" => Tag {
480
+ name: "samp",
481
+ index: 52,
482
+ self_closing: false,
483
+ },
484
+ "kbd" => Tag {
485
+ name: "kbd",
486
+ index: 53,
487
+ self_closing: false,
488
+ },
489
+ "sub" => Tag {
490
+ name: "sub",
491
+ index: 54,
492
+ self_closing: false,
493
+ },
494
+ "sup" => Tag {
495
+ name: "sup",
496
+ index: 55,
497
+ self_closing: false,
498
+ },
499
+ "i" => Tag {
500
+ name: "i",
501
+ index: 56,
502
+ self_closing: false,
503
+ },
504
+ "b" => Tag {
505
+ name: "b",
506
+ index: 57,
507
+ self_closing: false,
508
+ },
509
+ "u" => Tag {
510
+ name: "u",
511
+ index: 58,
512
+ self_closing: false,
513
+ },
514
+ "mark" => Tag {
515
+ name: "mark",
516
+ index: 59,
517
+ self_closing: false,
518
+ },
519
+ "ruby" => Tag {
520
+ name: "ruby",
521
+ index: 60,
522
+ self_closing: false,
523
+ },
524
+ "rt" => Tag {
525
+ name: "rt",
526
+ index: 61,
527
+ self_closing: false,
528
+ },
529
+ "rp" => Tag {
530
+ name: "rp",
531
+ index: 62,
532
+ self_closing: false,
533
+ },
534
+ "bdi" => Tag {
535
+ name: "bdi",
536
+ index: 63,
537
+ self_closing: false,
538
+ },
539
+ "bdo" => Tag {
540
+ name: "bdo",
541
+ index: 64,
542
+ self_closing: false,
543
+ },
544
+ "span" => Tag {
545
+ name: "span",
546
+ index: 65,
547
+ self_closing: false,
548
+ },
549
+ "br" => Tag {
550
+ name: "br",
551
+ index: 66,
552
+ self_closing: true,
553
+ },
554
+ "wbr" => Tag {
555
+ name: "wbr",
556
+ index: 67,
557
+ self_closing: true,
558
+ },
559
+ "ins" => Tag {
560
+ name: "ins",
561
+ index: 68,
562
+ self_closing: false,
563
+ },
564
+ "del" => Tag {
565
+ name: "del",
566
+ index: 69,
567
+ self_closing: false,
568
+ },
569
+ "image" => Tag {
570
+ name: "image",
571
+ index: 70,
572
+ self_closing: false,
573
+ },
574
+ "img" => Tag {
575
+ name: "img",
576
+ index: 71,
577
+ self_closing: true,
578
+ },
579
+ "iframe" => Tag {
580
+ name: "iframe",
581
+ index: 72,
582
+ self_closing: false,
583
+ },
584
+ "embed" => Tag {
585
+ name: "embed",
586
+ index: 73,
587
+ self_closing: true,
588
+ },
589
+ "object" => Tag {
590
+ name: "object",
591
+ index: 74,
592
+ self_closing: false,
593
+ },
594
+ "param" => Tag {
595
+ name: "param",
596
+ index: 75,
597
+ self_closing: true,
598
+ },
599
+ "video" => Tag {
600
+ name: "video",
601
+ index: 76,
602
+ self_closing: false,
603
+ },
604
+ "audio" => Tag {
605
+ name: "audio",
606
+ index: 77,
607
+ self_closing: false,
608
+ },
609
+ "source" => Tag {
610
+ name: "source",
611
+ index: 78,
612
+ self_closing: true,
613
+ },
614
+ "track" => Tag {
615
+ name: "track",
616
+ index: 79,
617
+ self_closing: true,
618
+ },
619
+ "canvas" => Tag {
620
+ name: "canvas",
621
+ index: 80,
622
+ self_closing: false,
623
+ },
624
+ "map" => Tag {
625
+ name: "map",
626
+ index: 81,
627
+ self_closing: false,
628
+ },
629
+ "area" => Tag {
630
+ name: "area",
631
+ index: 82,
632
+ self_closing: true,
633
+ },
634
+ "math" => Tag {
635
+ name: "math",
636
+ index: 83,
637
+ self_closing: false,
638
+ },
639
+ "mi" => Tag {
640
+ name: "mi",
641
+ index: 84,
642
+ self_closing: false,
643
+ },
644
+ "mo" => Tag {
645
+ name: "mo",
646
+ index: 85,
647
+ self_closing: false,
648
+ },
649
+ "mn" => Tag {
650
+ name: "mn",
651
+ index: 86,
652
+ self_closing: false,
653
+ },
654
+ "ms" => Tag {
655
+ name: "ms",
656
+ index: 87,
657
+ self_closing: false,
658
+ },
659
+ "mtext" => Tag {
660
+ name: "mtext",
661
+ index: 88,
662
+ self_closing: false,
663
+ },
664
+ "mglyph" => Tag {
665
+ name: "mglyph",
666
+ index: 89,
667
+ self_closing: false,
668
+ },
669
+ "malignmark" => Tag {
670
+ name: "malignmark",
671
+ index: 90,
672
+ self_closing: false,
673
+ },
674
+ "annotation" => Tag {
675
+ name: "annotation",
676
+ index: 91,
677
+ self_closing: false,
678
+ },
679
+ "svg" => Tag {
680
+ name: "svg",
681
+ index: 92,
682
+ self_closing: false,
683
+ },
684
+ "foreignobject" => Tag {
685
+ name: "foreignobject",
686
+ index: 93,
687
+ self_closing: false,
688
+ },
689
+ "desc" => Tag {
690
+ name: "desc",
691
+ index: 94,
692
+ self_closing: false,
693
+ },
694
+ "table" => Tag {
695
+ name: "table",
696
+ index: 95,
697
+ self_closing: false,
698
+ },
699
+ "caption" => Tag {
700
+ name: "caption",
701
+ index: 96,
702
+ self_closing: false,
703
+ },
704
+ "colgroup" => Tag {
705
+ name: "colgroup",
706
+ index: 97,
707
+ self_closing: false,
708
+ },
709
+ "col" => Tag {
710
+ name: "col",
711
+ index: 98,
712
+ self_closing: true,
713
+ },
714
+ "tbody" => Tag {
715
+ name: "tbody",
716
+ index: 99,
717
+ self_closing: false,
718
+ },
719
+ "thead" => Tag {
720
+ name: "thead",
721
+ index: 100,
722
+ self_closing: false,
723
+ },
724
+ "tfoot" => Tag {
725
+ name: "tfoot",
726
+ index: 101,
727
+ self_closing: false,
728
+ },
729
+ "tr" => Tag {
730
+ name: "tr",
731
+ index: 102,
732
+ self_closing: false,
733
+ },
734
+ "td" => Tag {
735
+ name: "td",
736
+ index: 103,
737
+ self_closing: false,
738
+ },
739
+ "th" => Tag {
740
+ name: "th",
741
+ index: 104,
742
+ self_closing: false,
743
+ },
744
+ "form" => Tag {
745
+ name: "form",
746
+ index: 105,
747
+ self_closing: false,
748
+ },
749
+ "fieldset" => Tag {
750
+ name: "fieldset",
751
+ index: 106,
752
+ self_closing: false,
753
+ },
754
+ "legend" => Tag {
755
+ name: "legend",
756
+ index: 107,
757
+ self_closing: false,
758
+ },
759
+ "label" => Tag {
760
+ name: "label",
761
+ index: 108,
762
+ self_closing: false,
763
+ },
764
+ "input" => Tag {
765
+ name: "input",
766
+ index: 109,
767
+ self_closing: true,
768
+ },
769
+ "button" => Tag {
770
+ name: "button",
771
+ index: 110,
772
+ self_closing: false,
773
+ },
774
+ "select" => Tag {
775
+ name: "select",
776
+ index: 111,
777
+ self_closing: false,
778
+ },
779
+ "datalist" => Tag {
780
+ name: "datalist",
781
+ index: 112,
782
+ self_closing: false,
783
+ },
784
+ "optgroup" => Tag {
785
+ name: "optgroup",
786
+ index: 113,
787
+ self_closing: false,
788
+ },
789
+ "option" => Tag {
790
+ name: "option",
791
+ index: 114,
792
+ self_closing: false,
793
+ },
794
+ "textarea" => Tag {
795
+ name: "textarea",
796
+ index: 115,
797
+ self_closing: false,
798
+ },
799
+ "keygen" => Tag {
800
+ name: "keygen",
801
+ index: 116,
802
+ self_closing: true,
803
+ },
804
+ "output" => Tag {
805
+ name: "output",
806
+ index: 117,
807
+ self_closing: false,
808
+ },
809
+ "progress" => Tag {
810
+ name: "progress",
811
+ index: 118,
812
+ self_closing: false,
813
+ },
814
+ "meter" => Tag {
815
+ name: "meter",
816
+ index: 119,
817
+ self_closing: false,
818
+ },
819
+ "details" => Tag {
820
+ name: "details",
821
+ index: 120,
822
+ self_closing: false,
823
+ },
824
+ "summary" => Tag {
825
+ name: "summary",
826
+ index: 121,
827
+ self_closing: false,
828
+ },
829
+ "menu" => Tag {
830
+ name: "menu",
831
+ index: 122,
832
+ self_closing: false,
833
+ },
834
+ "menuitem" => Tag {
835
+ name: "menuitem",
836
+ index: 123,
837
+ self_closing: true,
838
+ },
839
+ "applet" => Tag {
840
+ name: "applet",
841
+ index: 124,
842
+ self_closing: false,
843
+ },
844
+ "acronym" => Tag {
845
+ name: "acronym",
846
+ index: 125,
847
+ self_closing: false,
848
+ },
849
+ "bgsound" => Tag {
850
+ name: "bgsound",
851
+ index: 126,
852
+ self_closing: true,
853
+ },
854
+ "dir" => Tag {
855
+ name: "dir",
856
+ index: 127,
857
+ self_closing: false,
858
+ },
859
+ "frame" => Tag {
860
+ name: "frame",
861
+ index: 128,
862
+ self_closing: true,
863
+ },
864
+ "frameset" => Tag {
865
+ name: "frameset",
866
+ index: 129,
867
+ self_closing: false,
868
+ },
869
+ "noframes" => Tag {
870
+ name: "noframes",
871
+ index: 130,
872
+ self_closing: false,
873
+ },
874
+ "listing" => Tag {
875
+ name: "listing",
876
+ index: 131,
877
+ self_closing: false,
878
+ },
879
+ "xmp" => Tag {
880
+ name: "xmp",
881
+ index: 132,
882
+ self_closing: false,
883
+ },
884
+ "nextid" => Tag {
885
+ name: "nextid",
886
+ index: 133,
887
+ self_closing: false,
888
+ },
889
+ "noembed" => Tag {
890
+ name: "noembed",
891
+ index: 134,
892
+ self_closing: false,
893
+ },
894
+ "plaintext" => Tag {
895
+ name: "plaintext",
896
+ index: 135,
897
+ self_closing: false,
898
+ },
899
+ "rb" => Tag {
900
+ name: "rb",
901
+ index: 136,
902
+ self_closing: false,
903
+ },
904
+ "strike" => Tag {
905
+ name: "strike",
906
+ index: 137,
907
+ self_closing: false,
908
+ },
909
+ "basefont" => Tag {
910
+ name: "basefont",
911
+ index: 138,
912
+ self_closing: true,
913
+ },
914
+ "big" => Tag {
915
+ name: "big",
916
+ index: 139,
917
+ self_closing: false,
918
+ },
919
+ "blink" => Tag {
920
+ name: "blink",
921
+ index: 140,
922
+ self_closing: false,
923
+ },
924
+ "center" => Tag {
925
+ name: "center",
926
+ index: 141,
927
+ self_closing: false,
928
+ },
929
+ "font" => Tag {
930
+ name: "font",
931
+ index: 142,
932
+ self_closing: false,
933
+ },
934
+ "marquee" => Tag {
935
+ name: "marquee",
936
+ index: 143,
937
+ self_closing: false,
938
+ },
939
+ "multicol" => Tag {
940
+ name: "multicol",
941
+ index: 144,
942
+ self_closing: false,
943
+ },
944
+ "nobr" => Tag {
945
+ name: "nobr",
946
+ index: 145,
947
+ self_closing: false,
948
+ },
949
+ "spacer" => Tag {
950
+ name: "spacer",
951
+ index: 146,
952
+ self_closing: false,
953
+ },
954
+ "tt" => Tag {
955
+ name: "tt",
956
+ index: 147,
957
+ self_closing: false,
958
+ },
959
+ "rtc" => Tag {
960
+ name: "rtc",
961
+ index: 148,
962
+ self_closing: false,
963
+ },
964
+ "dialog" => Tag {
965
+ name: "dialog",
966
+ index: 149,
967
+ self_closing: false,
968
+ },
969
+ &_ => Tag {
970
+ name: "unknown",
971
+ index: 150,
972
+ self_closing: false,
973
+ },
974
+ }
975
+ }
976
+ }
977
+
978
+ pub fn element_name_from_enum(html_tag: &HTMLTag) -> &'static str {
979
+ match html_tag {
980
+ HTMLTag::HTML => "html",
981
+ HTMLTag::HEAD => "head",
982
+ HTMLTag::TITLE => "title",
983
+ HTMLTag::BASE => "base",
984
+ HTMLTag::LINK => "link",
985
+ HTMLTag::META => "meta",
986
+ HTMLTag::STYLE => "style",
987
+ HTMLTag::SCRIPT => "script",
988
+ HTMLTag::NOSCRIPT => "noscript",
989
+ HTMLTag::TEMPLATE => "template",
990
+ HTMLTag::BODY => "body",
991
+ HTMLTag::ARTICLE => "article",
992
+ HTMLTag::SECTION => "section",
993
+ HTMLTag::NAV => "nav",
994
+ HTMLTag::ASIDE => "aside",
995
+ HTMLTag::H1 => "h1",
996
+ HTMLTag::H2 => "h2",
997
+ HTMLTag::H3 => "h3",
998
+ HTMLTag::H4 => "h4",
999
+ HTMLTag::H5 => "h5",
1000
+ HTMLTag::H6 => "h6",
1001
+ HTMLTag::HGROUP => "hgroup",
1002
+ HTMLTag::HEADER => "header",
1003
+ HTMLTag::FOOTER => "footer",
1004
+ HTMLTag::ADDRESS => "address",
1005
+ HTMLTag::P => "p",
1006
+ HTMLTag::HR => "hr",
1007
+ HTMLTag::PRE => "pre",
1008
+ HTMLTag::BLOCKQUOTE => "blockquote",
1009
+ HTMLTag::OL => "ol",
1010
+ HTMLTag::UL => "ul",
1011
+ HTMLTag::LI => "li",
1012
+ HTMLTag::DL => "dl",
1013
+ HTMLTag::DT => "dt",
1014
+ HTMLTag::DD => "dd",
1015
+ HTMLTag::FIGURE => "figure",
1016
+ HTMLTag::FIGCAPTION => "figcaption",
1017
+ HTMLTag::MAIN => "main",
1018
+ HTMLTag::DIV => "div",
1019
+ HTMLTag::A => "a",
1020
+ HTMLTag::EM => "em",
1021
+ HTMLTag::STRONG => "strong",
1022
+ HTMLTag::SMALL => "small",
1023
+ HTMLTag::S => "s",
1024
+ HTMLTag::CITE => "cite",
1025
+ HTMLTag::Q => "q",
1026
+ HTMLTag::DFN => "dfn",
1027
+ HTMLTag::ABBR => "abbr",
1028
+ HTMLTag::DATA => "data",
1029
+ HTMLTag::TIME => "time",
1030
+ HTMLTag::CODE => "code",
1031
+ HTMLTag::VAR => "var",
1032
+ HTMLTag::SAMP => "samp",
1033
+ HTMLTag::KBD => "kbd",
1034
+ HTMLTag::SUB => "sub",
1035
+ HTMLTag::SUP => "sup",
1036
+ HTMLTag::I => "i",
1037
+ HTMLTag::B => "b",
1038
+ HTMLTag::U => "u",
1039
+ HTMLTag::MARK => "mark",
1040
+ HTMLTag::RUBY => "ruby",
1041
+ HTMLTag::RT => "rt",
1042
+ HTMLTag::RP => "rp",
1043
+ HTMLTag::BDI => "bdi",
1044
+ HTMLTag::BDO => "bdo",
1045
+ HTMLTag::SPAN => "span",
1046
+ HTMLTag::BR => "br",
1047
+ HTMLTag::WBR => "wbr",
1048
+ HTMLTag::INS => "ins",
1049
+ HTMLTag::DEL => "del",
1050
+ HTMLTag::IMAGE => "image",
1051
+ HTMLTag::IMG => "img",
1052
+ HTMLTag::IFRAME => "iframe",
1053
+ HTMLTag::EMBED => "embed",
1054
+ HTMLTag::OBJECT => "object",
1055
+ HTMLTag::PARAM => "param",
1056
+ HTMLTag::VIDEO => "video",
1057
+ HTMLTag::AUDIO => "audio",
1058
+ HTMLTag::SOURCE => "source",
1059
+ HTMLTag::TRACK => "track",
1060
+ HTMLTag::CANVAS => "canvas",
1061
+ HTMLTag::MAP => "map",
1062
+ HTMLTag::AREA => "area",
1063
+ HTMLTag::MATH => "math",
1064
+ HTMLTag::MI => "mi",
1065
+ HTMLTag::MO => "mo",
1066
+ HTMLTag::MN => "mn",
1067
+ HTMLTag::MS => "ms",
1068
+ HTMLTag::MTEXT => "mtext",
1069
+ HTMLTag::MGLYPH => "mglyph",
1070
+ HTMLTag::MALIGNMARK => "malignmark",
1071
+ HTMLTag::ANNOTATION => "annotation",
1072
+ HTMLTag::SVG => "svg",
1073
+ HTMLTag::FOREIGNOBJECT => "foreignobject",
1074
+ HTMLTag::DESC => "desc",
1075
+ HTMLTag::TABLE => "table",
1076
+ HTMLTag::CAPTION => "caption",
1077
+ HTMLTag::COLGROUP => "colgroup",
1078
+ HTMLTag::COL => "col",
1079
+ HTMLTag::TBODY => "tbody",
1080
+ HTMLTag::THEAD => "thead",
1081
+ HTMLTag::TFOOT => "tfoot",
1082
+ HTMLTag::TR => "tr",
1083
+ HTMLTag::TD => "td",
1084
+ HTMLTag::TH => "th",
1085
+ HTMLTag::FORM => "form",
1086
+ HTMLTag::FIELDSET => "fieldset",
1087
+ HTMLTag::LEGEND => "legend",
1088
+ HTMLTag::LABEL => "label",
1089
+ HTMLTag::INPUT => "input",
1090
+ HTMLTag::BUTTON => "button",
1091
+ HTMLTag::SELECT => "select",
1092
+ HTMLTag::DATALIST => "datalist",
1093
+ HTMLTag::OPTGROUP => "optgroup",
1094
+ HTMLTag::OPTION => "option",
1095
+ HTMLTag::TEXTAREA => "textarea",
1096
+ HTMLTag::KEYGEN => "keygen",
1097
+ HTMLTag::OUTPUT => "output",
1098
+ HTMLTag::PROGRESS => "progress",
1099
+ HTMLTag::METER => "meter",
1100
+ HTMLTag::DETAILS => "details",
1101
+ HTMLTag::SUMMARY => "summary",
1102
+ HTMLTag::MENU => "menu",
1103
+ HTMLTag::MENUITEM => "menuitem",
1104
+ HTMLTag::APPLET => "applet",
1105
+ HTMLTag::ACRONYM => "acronym",
1106
+ HTMLTag::BGSOUND => "bgsound",
1107
+ HTMLTag::DIR => "dir",
1108
+ HTMLTag::FRAME => "frame",
1109
+ HTMLTag::FRAMESET => "frameset",
1110
+ HTMLTag::NOFRAMES => "noframes",
1111
+ HTMLTag::LISTING => "listing",
1112
+ HTMLTag::XMP => "xmp",
1113
+ HTMLTag::NEXTID => "nextid",
1114
+ HTMLTag::NOEMBED => "noembed",
1115
+ HTMLTag::PLAINTEXT => "plaintext",
1116
+ HTMLTag::RB => "rb",
1117
+ HTMLTag::STRIKE => "strike",
1118
+ HTMLTag::BASEFONT => "basefont",
1119
+ HTMLTag::BIG => "big",
1120
+ HTMLTag::BLINK => "blink",
1121
+ HTMLTag::CENTER => "center",
1122
+ HTMLTag::FONT => "font",
1123
+ HTMLTag::MARQUEE => "marquee",
1124
+ HTMLTag::MULTICOL => "multicol",
1125
+ HTMLTag::NOBR => "nobr",
1126
+ HTMLTag::SPACER => "spacer",
1127
+ HTMLTag::TT => "tt",
1128
+ HTMLTag::RTC => "rtc",
1129
+ HTMLTag::DIALOG => "dialog",
1130
+ _ => "unknown",
1131
+ }
1132
+ }
1133
+ }