From a637f17467ff36f55d0fb843cd5affcd5dd05d1f Mon Sep 17 00:00:00 2001 From: Akio Tajima Date: Wed, 22 Dec 2021 14:00:49 +0900 Subject: [PATCH] fix List and ListItem mapping --- src/mapping.js | 5 +- .../element-auto-close-document/index.json | 8 +- .../element-auto-close-fragment/index.json | 8 +- test/ast-test-case/list/config.json | 3 + test/ast-test-case/list/index.html | 8 + test/ast-test-case/list/index.json | 380 ++++++++++++++++++ 6 files changed, 402 insertions(+), 10 deletions(-) create mode 100644 test/ast-test-case/list/config.json create mode 100644 test/ast-test-case/list/index.html create mode 100644 test/ast-test-case/list/index.json diff --git a/src/mapping.js b/src/mapping.js index 5b9aab9..96f001c 100644 --- a/src/mapping.js +++ b/src/mapping.js @@ -2,8 +2,9 @@ "use strict"; export const tagNameToType = { "p": "Paragraph", - "ui": "ListItem", - "li": "List", + "ul": "List", + "ol": "List", + "li": "ListItem", "q": "BlockQuote", "blockquote": "BlockQuote", "code": "CodeBlock", diff --git a/test/ast-test-case/element-auto-close-document/index.json b/test/ast-test-case/element-auto-close-document/index.json index 402bc49..b82a844 100644 --- a/test/ast-test-case/element-auto-close-document/index.json +++ b/test/ast-test-case/element-auto-close-document/index.json @@ -228,7 +228,7 @@ "raw": ">\n" }, { - "type": "Html", + "type": "List", "tagName": "ol", "properties": {}, "children": [ @@ -252,7 +252,7 @@ "raw": "\n " }, { - "type": "List", + "type": "ListItem", "tagName": "li", "properties": {}, "children": [ @@ -293,7 +293,7 @@ "raw": "
  • delta\n
  • " }, { - "type": "List", + "type": "ListItem", "tagName": "li", "properties": {}, "children": [ @@ -383,4 +383,4 @@ 89 ], "raw": "\n Alpha\n\n

    bravo\n

    charlie

    \n
      \n
    1. delta\n
    2. echo\n" -} \ No newline at end of file +} diff --git a/test/ast-test-case/element-auto-close-fragment/index.json b/test/ast-test-case/element-auto-close-fragment/index.json index 402bc49..b82a844 100644 --- a/test/ast-test-case/element-auto-close-fragment/index.json +++ b/test/ast-test-case/element-auto-close-fragment/index.json @@ -228,7 +228,7 @@ "raw": ">\n" }, { - "type": "Html", + "type": "List", "tagName": "ol", "properties": {}, "children": [ @@ -252,7 +252,7 @@ "raw": "\n " }, { - "type": "List", + "type": "ListItem", "tagName": "li", "properties": {}, "children": [ @@ -293,7 +293,7 @@ "raw": "
    3. delta\n
    4. " }, { - "type": "List", + "type": "ListItem", "tagName": "li", "properties": {}, "children": [ @@ -383,4 +383,4 @@ 89 ], "raw": "\n Alpha\n\n

      bravo\n

      charlie

      \n
        \n
      1. delta\n
      2. echo\n" -} \ No newline at end of file +} diff --git a/test/ast-test-case/list/config.json b/test/ast-test-case/list/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/list/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/list/index.html b/test/ast-test-case/list/index.html new file mode 100644 index 0000000..663f584 --- /dev/null +++ b/test/ast-test-case/list/index.html @@ -0,0 +1,8 @@ +
          +
        • first item
        • +
        • second item
        • +
        +
          +
        1. # first item
        2. +
        3. # second item
        4. +
        diff --git a/test/ast-test-case/list/index.json b/test/ast-test-case/list/index.json new file mode 100644 index 0000000..0554505 --- /dev/null +++ b/test/ast-test-case/list/index.json @@ -0,0 +1,380 @@ +{ + "type": "Document", + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 2, + "line": 2 + }, + "start": { + "column": 4, + "line": 1 + } + }, + "range": [ + 4, + 7 + ], + "raw": "\n ", + "type": "Str", + "value": "\n " + }, + { + "children": [ + { + "loc": { + "end": { + "column": 16, + "line": 2 + }, + "start": { + "column": 6, + "line": 2 + } + }, + "range": [ + 11, + 21 + ], + "raw": "first item", + "type": "Str", + "value": "first item" + } + ], + "loc": { + "end": { + "column": 21, + "line": 2 + }, + "start": { + "column": 2, + "line": 2 + } + }, + "properties": {}, + "range": [ + 7, + 26 + ], + "raw": "
      3. first item
      4. ", + "tagName": "li", + "type": "ListItem" + }, + { + "loc": { + "end": { + "column": 2, + "line": 3 + }, + "start": { + "column": 21, + "line": 2 + } + }, + "range": [ + 26, + 29 + ], + "raw": "\n ", + "type": "Str", + "value": "\n " + }, + { + "children": [ + { + "loc": { + "end": { + "column": 17, + "line": 3 + }, + "start": { + "column": 6, + "line": 3 + } + }, + "range": [ + 33, + 44 + ], + "raw": "second item", + "type": "Str", + "value": "second item" + } + ], + "loc": { + "end": { + "column": 22, + "line": 3 + }, + "start": { + "column": 2, + "line": 3 + } + }, + "properties": {}, + "range": [ + 29, + 49 + ], + "raw": "
      5. second item
      6. ", + "tagName": "li", + "type": "ListItem" + }, + { + "loc": { + "end": { + "column": 0, + "line": 4 + }, + "start": { + "column": 22, + "line": 3 + } + }, + "range": [ + 49, + 50 + ], + "raw": "\n", + "type": "Str", + "value": "\n" + } + ], + "loc": { + "end": { + "column": 5, + "line": 4 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "properties": {}, + "range": [ + 0, + 55 + ], + "raw": "
          \n
        • first item
        • \n
        • second item
        • \n
        ", + "tagName": "ul", + "type": "List" + }, + { + "loc": { + "end": { + "column": 0, + "line": 5 + }, + "start": { + "column": 5, + "line": 4 + } + }, + "range": [ + 55, + 56 + ], + "raw": "\n", + "type": "Str", + "value": "\n" + }, + { + "children": [ + { + "loc": { + "end": { + "column": 2, + "line": 6 + }, + "start": { + "column": 4, + "line": 5 + } + }, + "range": [ + 60, + 63 + ], + "raw": "\n ", + "type": "Str", + "value": "\n " + }, + { + "children": [ + { + "loc": { + "end": { + "column": 18, + "line": 6 + }, + "start": { + "column": 6, + "line": 6 + } + }, + "range": [ + 67, + 79 + ], + "raw": "# first item", + "type": "Str", + "value": "# first item" + } + ], + "loc": { + "end": { + "column": 23, + "line": 6 + }, + "start": { + "column": 2, + "line": 6 + } + }, + "properties": {}, + "range": [ + 63, + 84 + ], + "raw": "
      7. # first item
      8. ", + "tagName": "li", + "type": "ListItem" + }, + { + "loc": { + "end": { + "column": 2, + "line": 7 + }, + "start": { + "column": 23, + "line": 6 + } + }, + "range": [ + 84, + 87 + ], + "raw": "\n ", + "type": "Str", + "value": "\n " + }, + { + "children": [ + { + "loc": { + "end": { + "column": 19, + "line": 7 + }, + "start": { + "column": 6, + "line": 7 + } + }, + "range": [ + 91, + 104 + ], + "raw": "# second item", + "type": "Str", + "value": "# second item" + } + ], + "loc": { + "end": { + "column": 24, + "line": 7 + }, + "start": { + "column": 2, + "line": 7 + } + }, + "properties": {}, + "range": [ + 87, + 109 + ], + "raw": "
      9. # second item
      10. ", + "tagName": "li", + "type": "ListItem" + }, + { + "loc": { + "end": { + "column": 0, + "line": 8 + }, + "start": { + "column": 24, + "line": 7 + } + }, + "range": [ + 109, + 110 + ], + "raw": "\n", + "type": "Str", + "value": "\n" + } + ], + "loc": { + "end": { + "column": 5, + "line": 8 + }, + "start": { + "column": 0, + "line": 5 + } + }, + "properties": {}, + "range": [ + 56, + 115 + ], + "raw": "
          \n
        1. # first item
        2. \n
        3. # second item
        4. \n
        ", + "tagName": "ol", + "type": "List" + }, + { + "loc": { + "end": { + "column": 0, + "line": 9 + }, + "start": { + "column": 5, + "line": 8 + } + }, + "range": [ + 115, + 116 + ], + "raw": "\n", + "type": "Str", + "value": "\n" + } + ], + "loc": { + "end": { + "column": 0, + "line": 9 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [ + 0, + 116 + ], + "raw": "
          \n
        • first item
        • \n
        • second item
        • \n
        \n
          \n
        1. # first item
        2. \n
        3. # second item
        4. \n
        \n" +}