| 1 | package com.renomad.minum.htmlparsing; | |
| 2 | ||
| 3 | ||
| 4 | import com.renomad.minum.utils.SearchUtils; | |
| 5 | ||
| 6 | import java.util.Arrays; | |
| 7 | ||
| 8 | /** | |
| 9 | * Possible tag names per the W3C HTML spec. | |
| 10 | * Pulled from <a href="https://www.w3.org/TR/2012/WD-html-markup-20121025/elements.html">The W3C spec</a> | |
| 11 | */ | |
| 12 | public enum TagName { | |
| 13 | A(false), ABBR(false), ADDRESS(false), AREA(true), ARTICLE(false), | |
| 14 | ASIDE(false), AUDIO(false), B(false), BASE(true), BDI(false), | |
| 15 | BDO(false), BLOCKQUOTE(false), BODY(false), BR(true), BUTTON(false), CANVAS(false), | |
| 16 | CAPTION(false), CITE(false), CODE(false), COL(true), COLGROUP(false), | |
| 17 | COMMAND(true), DATALIST(false), DD(false), DEL(false), DETAILS(false), | |
| 18 | DFN(false), DIV(false), DL(false), DT(false), EM(false), EMBED(true), | |
| 19 | FIELDSET(false), FIGCAPTION(false), FIGURE(false), FOOTER(false), | |
| 20 | FORM(false), H1(false), H2(false), H3(false), H4(false), H5(false), | |
| 21 | H6(false), HEAD(false), HEADER(false), HGROUP(false), HR(true), | |
| 22 | HTML(false), I(false), IFRAME(false), IMG(true), INPUT(true), | |
| 23 | INS(false), KBD(false), KEYGEN(true), LABEL(false), LEGEND(false), | |
| 24 | LI(false), LINK(true), MAP(false), MARK(false), MENU(false), | |
| 25 | META(true), METER(false), NAV(false), NOSCRIPT(false), OBJECT(false), | |
| 26 | OL(false), OPTGROUP(false), OPTION(false), OUTPUT(false), P(false), | |
| 27 | PARAM(true), PRE(false), PROGRESS(false), Q(false), RP(false), | |
| 28 | RT(false), RUBY(false), S(false), SAMP(false), SCRIPT(false), | |
| 29 | SECTION(false), SELECT(false), SMALL(false), SOURCE(true), | |
| 30 | SPAN(false), STRONG(false), STYLE(false), SUB(false), SUMMARY(false), | |
| 31 | SUP(false), TABLE(false), TBODY(false), TD(false), TEMPLATE(false), TEXTAREA(false), | |
| 32 | TFOOT(false), TH(false), THEAD(false), TIME(false), TITLE(false), | |
| 33 | TR(false), TRACK(true), U(false), UL(false), VAR(false), VIDEO(false), | |
| 34 | WBR(true),SVG(false),MATH(false), | |
| 35 | ||
| 36 | /** | |
| 37 | * In HTML, the doctype is the required preamble found at the top of | |
| 38 | * all documents. Its sole purpose is to prevent a browser from | |
| 39 | * switching into so-called "quirks mode" when rendering a document; | |
| 40 | * that is, it ensures that the browser makes a best-effort attempt at | |
| 41 | * following the relevant specifications, rather than using a | |
| 42 | * different rendering mode that is incompatible with some specifications. | |
| 43 | */ | |
| 44 | DOCTYPE(true), | |
| 45 | ||
| 46 | ||
| 47 | /** | |
| 48 | * A special tag, meant for cases where we are scanning through unfamiliar | |
| 49 | * namespaces, like svg or math. | |
| 50 | */ | |
| 51 | UNRECOGNIZED(false), | |
| 52 | ||
| 53 | /** | |
| 54 | * Used to indicate no tag | |
| 55 | */ | |
| 56 | NULL(false) | |
| 57 | ; | |
| 58 | ||
| 59 | /** | |
| 60 | * Void elements are disallowed to have closing tags | |
| 61 | */ | |
| 62 | public final boolean isVoidElement; | |
| 63 | ||
| 64 | /** | |
| 65 | * If this is a void element, then it is disallowed to have | |
| 66 | * a closing tag. (see <a href="https://www.w3.org/TR/2011/WD-html-markup-20110113/syntax.html#void-element">void elements</a>) | |
| 67 | */ | |
| 68 | TagName(boolean isVoidElement) { | |
| 69 | this.isVoidElement = isVoidElement; | |
| 70 | } | |
| 71 | ||
| 72 | public static TagName findMatchingTagname(String tagNameString) { | |
| 73 |
1
1. findMatchingTagname : replaced return value with null for com/renomad/minum/htmlparsing/TagName::findMatchingTagname → KILLED |
return SearchUtils.findExactlyOne( |
| 74 | Arrays.stream(TagName.values()), | |
| 75 |
2
1. lambda$findMatchingTagname$0 : replaced boolean return with false for com/renomad/minum/htmlparsing/TagName::lambda$findMatchingTagname$0 → KILLED 2. lambda$findMatchingTagname$0 : replaced boolean return with true for com/renomad/minum/htmlparsing/TagName::lambda$findMatchingTagname$0 → KILLED |
x -> x.toString().equalsIgnoreCase(tagNameString), |
| 76 |
1
1. lambda$findMatchingTagname$1 : replaced return value with null for com/renomad/minum/htmlparsing/TagName::lambda$findMatchingTagname$1 → KILLED |
() -> UNRECOGNIZED); |
| 77 | } | |
| 78 | } | |
Mutations | ||
| 73 |
1.1 |
|
| 75 |
1.1 2.2 |
|
| 76 |
1.1 |