diff --git a/external-resources/commit.md b/external-resources/commit.md index cea52d6d..4ae1aa7b 100644 --- a/external-resources/commit.md +++ b/external-resources/commit.md @@ -1,2 +1,2 @@ -https://github.com/html5lib/html5lib-tests.git 224991ec10db04f056a89eed8b0bd8695fd2950e -https://github.com/web-platform-tests/wpt.git a1e59538d34f1721ffa52e2a8c78a308012800c8 +https://github.com/html5lib/html5lib-tests.git c777c408b61078ea2eb4acefc2535f54dbc8b28a +https://github.com/web-platform-tests/wpt.git 97fe10c5d0e12e4a9d90f77b8db0602c64f3ad2d diff --git a/external-resources/html5lib-tests/tokenizer/README.md b/external-resources/html5lib-tests/tokenizer/README.md index 66b81e8f..996d1e6f 100644 --- a/external-resources/html5lib-tests/tokenizer/README.md +++ b/external-resources/html5lib-tests/tokenizer/README.md @@ -76,6 +76,7 @@ tokens are: ["StartTag", name, {attributes}] ["EndTag", name] ["Comment", data] + ["ProcessingInstruction", data] ["Character", data] `public_id` and `system_id` are either strings or `null`. `correctness` diff --git a/external-resources/html5lib-tests/tokenizer/test2.test b/external-resources/html5lib-tests/tokenizer/test2.test index c29e4c31..edbec4b5 100644 --- a/external-resources/html5lib-tests/tokenizer/test2.test +++ b/external-resources/html5lib-tests/tokenizer/test2.test @@ -183,19 +183,17 @@ { "code": "invalid-first-character-of-tag-name", "line": 1, "col": 3 } ]}, -{"description":"Simili processing instruction", +{"description":"Processing instruction", "input":"", -"output":[["Comment", "?namespace"]], -"errors":[ - { "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 } -]}, +"output":[["ProcessingInstruction", "namespace", ""]]}, -{"description":"A bogus comment stops at >, even if preceded by two dashes", -"input":"", -"output":[["Comment", "?foo--"]], -"errors":[ - { "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 } -]}, +{"description":"A processing instruction delimited by ?> doesn't contain the delimiting ?", +"input":"", +"output":[["ProcessingInstruction", "foo", "bar"]]}, + +{"description":"A processing instruction's data delimited by ?> contains the correct amount of ?", +"input":"", +"output":[["ProcessingInstruction", "foo", "bar?"]]}, {"description":"Unescaped <", "input":"foo < bar", diff --git a/external-resources/html5lib-tests/tokenizer/test3.test b/external-resources/html5lib-tests/tokenizer/test3.test index 901a581e..7a6a1b90 100644 --- a/external-resources/html5lib-tests/tokenizer/test3.test +++ b/external-resources/html5lib-tests/tokenizer/test3.test @@ -8954,16 +8954,184 @@ {"description":"", "input":"", "output":[["Comment", "?"]], "errors":[ - { "code": "unexpected-question-mark-instead-of-tag-name", "line": 1, "col": 2 } + { "code": "invalid-first-character-of-processing-instruction-target", "line": 1, "col": 3 } ]}, {"description":" | | + +#data +xy +#errors + * (1,32) adoption agency: formatting element is not the current node + * (1,33) unexpected end of file +#document +| +| +| +| +| +| +| +| "x" +| "y" + +#data +x

yz +#errors + * (1,34) unexpected start tag a implies end tag a + * (1,35) unexpected end of file +#document +| +| +| +| +| +| +| +| "x" +|

+| +| "y" +| +| "z" + +#data +

  • a
  • b +#errors + * (1,35) unexpected end of file +#document +| +| +| +| +|
  • +| "a" +| +|
  • +| "b" + +#data +
    a
    b +#errors + * (1,35) unexpected end of file +#document +| +| +| +| +|
    +| "a" +| +|
    +| "b" + +#data +y +#errors + * (1,30) unexpected end tag x + * (1,31) unexpected end of file +#document +| +| +| +| +| +| +| "y" diff --git a/external-resources/wpt/html/syntax/parsing/resources/tests19.dat b/external-resources/wpt/html/syntax/parsing/resources/tests19.dat index 20cdeabc..761a4878 100644 --- a/external-resources/wpt/html/syntax/parsing/resources/tests19.dat +++ b/external-resources/wpt/html/syntax/parsing/resources/tests19.dat @@ -605,6 +605,56 @@ |

    | "a" +#data +� +#errors +(1,26): unexpected-start-tag +(1,33): unexpected-start-tag-ignored +#document +| +| +| +| +| "�" + +#data +� +#errors +(1,33): unexpected-start-tag +(1,40): unexpected-start-tag-ignored +#document +| +| +| +| +| "�" + +#data +� +#errors +(1,19): null-character-reference +(1,29): unexpected-start-tag +(1,36): unexpected-start-tag-ignored +#document +| +| +| +| +| "�" + +#data +� +#errors +(1,44): unexpected-start-tag +(1,51): unexpected-start-tag-ignored +#document +| +| +| +| +| +| "�" + #data

    #errors diff --git a/src/main/java/ch/digitalfondue/jfiveparse/Common.java b/src/main/java/ch/digitalfondue/jfiveparse/Common.java index 8cf93df2..b93a7512 100644 --- a/src/main/java/ch/digitalfondue/jfiveparse/Common.java +++ b/src/main/java/ch/digitalfondue/jfiveparse/Common.java @@ -493,37 +493,37 @@ static int tagNameToID(String tagName) { static final int ELEMENT_PLAINTEXT_ID = 60; static final int ELEMENT_PRE_ID = 61; static final int ELEMENT_SCRIPT_ID = 62; - static final int ELEMENT_SECTION_ID = 63; - static final int ELEMENT_SELECT_ID = 64; - static final int ELEMENT_SOURCE_ID = 65; - static final int ELEMENT_STYLE_ID = 66; - static final int ELEMENT_SUMMARY_ID = 67; - static final int ELEMENT_TABLE_ID = 68; - static final int ELEMENT_TBODY_ID = 69; - static final int ELEMENT_TD_ID = 70; - static final int ELEMENT_TEMPLATE_ID = 71; - static final int ELEMENT_TEXTAREA_ID = 72; - static final int ELEMENT_TFOOT_ID = 73; - static final int ELEMENT_TH_ID = 74; - static final int ELEMENT_THEAD_ID = 75; - static final int ELEMENT_TITLE_ID = 76; - static final int ELEMENT_TR_ID = 77; - static final int ELEMENT_TRACK_ID = 78; - static final int ELEMENT_UL_ID = 79; - static final int ELEMENT_WBR_ID = 80; - static final int ELEMENT_XMP_ID = 81; - // end this order is the SPECIAL_ELEMENTS_HTML container from 1 to 81 - static final int ELEMENT_OPTGROUP_ID = 82; - static final int ELEMENT_OPTION_ID = 83; - static final int ELEMENT_RB_ID = 84; - static final int ELEMENT_RP_ID = 85; - static final int ELEMENT_RT_ID = 86; - static final int ELEMENT_RTC_ID = 87; + static final int ELEMENT_SEARCH_ID = 63; + static final int ELEMENT_SECTION_ID = 64; + static final int ELEMENT_SELECT_ID = 65; + static final int ELEMENT_SOURCE_ID = 66; + static final int ELEMENT_STYLE_ID = 67; + static final int ELEMENT_SUMMARY_ID = 68; + static final int ELEMENT_TABLE_ID = 69; + static final int ELEMENT_TBODY_ID = 70; + static final int ELEMENT_TD_ID = 71; + static final int ELEMENT_TEMPLATE_ID = 72; + static final int ELEMENT_TEXTAREA_ID = 73; + static final int ELEMENT_TFOOT_ID = 74; + static final int ELEMENT_TH_ID = 75; + static final int ELEMENT_THEAD_ID = 76; + static final int ELEMENT_TITLE_ID = 77; + static final int ELEMENT_TR_ID = 78; + static final int ELEMENT_TRACK_ID = 79; + static final int ELEMENT_UL_ID = 80; + static final int ELEMENT_WBR_ID = 81; + static final int ELEMENT_XMP_ID = 82; + // end this order is the SPECIAL_ELEMENTS_HTML container from 1 to 82 + static final int ELEMENT_OPTGROUP_ID = 83; + static final int ELEMENT_OPTION_ID = 84; + static final int ELEMENT_RB_ID = 85; + static final int ELEMENT_RP_ID = 86; + static final int ELEMENT_RT_ID = 87; + static final int ELEMENT_RTC_ID = 88; // - static final int ELEMENT_A_ID = 88; + static final int ELEMENT_A_ID = 89; // - static final int ELEMENT_DIALOG_ID = 89; - static final int ELEMENT_SEARCH_ID = 90; + static final int ELEMENT_DIALOG_ID = 90; static final int ELEMENT_B_ID = 91; static final int ELEMENT_BIG_ID = 92; static final int ELEMENT_CODE_ID = 93; diff --git a/src/test/java/ch/digitalfondue/jfiveparse/EnsureCommonElementIDTest.java b/src/test/java/ch/digitalfondue/jfiveparse/EnsureCommonElementIDTest.java index 986cbe26..493dbe7e 100644 --- a/src/test/java/ch/digitalfondue/jfiveparse/EnsureCommonElementIDTest.java +++ b/src/test/java/ch/digitalfondue/jfiveparse/EnsureCommonElementIDTest.java @@ -73,6 +73,7 @@ void ensureCommonElementIDRanges() { ELEMENT_PLAINTEXT_ID, ELEMENT_PRE_ID, ELEMENT_SCRIPT_ID, + ELEMENT_SEARCH_ID, ELEMENT_SECTION_ID, ELEMENT_SELECT_ID, ELEMENT_SOURCE_ID, diff --git a/src/test/java/ch/digitalfondue/jfiveparse/Token.java b/src/test/java/ch/digitalfondue/jfiveparse/Token.java index 670da4ce..adc3c075 100644 --- a/src/test/java/ch/digitalfondue/jfiveparse/Token.java +++ b/src/test/java/ch/digitalfondue/jfiveparse/Token.java @@ -108,4 +108,21 @@ public String toString() { return Arrays.asList(TokenType.endTag, name).toString(); } } + + class ProcessingInstruction implements Token { + + final String target; + final String data; + + public ProcessingInstruction(String target, String data) { + this.target = target; + this.data = data; + } + + + @Override + public String toString() { + return Arrays.asList(TokenType.processingInstruction, target, data).toString(); + } + } } diff --git a/src/test/java/ch/digitalfondue/jfiveparse/TokenSaver.java b/src/test/java/ch/digitalfondue/jfiveparse/TokenSaver.java index 95d47028..81a831be 100644 --- a/src/test/java/ch/digitalfondue/jfiveparse/TokenSaver.java +++ b/src/test/java/ch/digitalfondue/jfiveparse/TokenSaver.java @@ -60,6 +60,11 @@ public void emitEndTagToken(ResizableCharBuilder name) { tokens.add(new Token.EndTagToken(name.toLowerCase())); } + @Override + void emitProcessingInstructionToken(String processingInstructionTokenTarget, String processingInstructionTokenData) { + tokens.add(new Token.ProcessingInstruction(processingInstructionTokenTarget, processingInstructionTokenData)); + } + @Override public void emitStartTagToken(ResizableCharBuilder name, Attributes attrs, boolean selfClosing) { Map m = new LinkedHashMap<>(); diff --git a/src/test/java/ch/digitalfondue/jfiveparse/TokenType.java b/src/test/java/ch/digitalfondue/jfiveparse/TokenType.java index b8d049d7..5d44508d 100644 --- a/src/test/java/ch/digitalfondue/jfiveparse/TokenType.java +++ b/src/test/java/ch/digitalfondue/jfiveparse/TokenType.java @@ -23,5 +23,6 @@ interface TokenType { String doctype = "DOCTYPE"; String startTag = "StartTag"; String endTag = "EndTag"; + String processingInstruction = "ProcessingInstruction"; String EOF = "EOF"; } diff --git a/src/test/java/ch/digitalfondue/jfiveparse/TokenizerTest.java b/src/test/java/ch/digitalfondue/jfiveparse/TokenizerTest.java index 13a2e533..13dfc888 100644 --- a/src/test/java/ch/digitalfondue/jfiveparse/TokenizerTest.java +++ b/src/test/java/ch/digitalfondue/jfiveparse/TokenizerTest.java @@ -81,6 +81,7 @@ public static List data() throws IOException { record ToSkip(String path, String description) {} + /* private static final Set TO_SKIPS = Set.of( new ToSkip("test2.test", "Simili processing instruction"), new ToSkip("test2.test", "A bogus comment stops at >, even if preceded by two dashes"), @@ -93,7 +94,7 @@ record ToSkip(String path, String description) {} new ToSkip("test3.test", "