syntax-tree / mdast-util-gfm-task-list-item

mdast extension to parse and serialize GFM task list items
https://unifiedjs.com
MIT License
5 stars 2 forks source link

Missing content on paragraphs after checkbox #1

Closed RichardFevrier closed 3 years ago

RichardFevrier commented 3 years ago

Consider the following markdown:

"- [ ] task1\n\n task2"

And the following code/configuration:

"mdast-util-from-markdown": "0.8.1", (latest)
"micromark-extension-gfm-strikethrough": "0.6.2", (latest)
"mdast-util-gfm-strikethrough": "0.2.2", (latest)
"micromark-extension-gfm-task-list-item": "0.3.1", (latest)
"mdast-util-gfm-task-list-item": "0.1.4", (latest)
var md2mdast = require('mdast-util-from-markdown');
var strikethroughSyntax = require('micromark-extension-gfm-strikethrough')
var strikethrough = require('mdast-util-gfm-strikethrough');
var tasklistitemSyntax = require('micromark-extension-gfm-task-list-item');
var tasklistitem = require('mdast-util-gfm-task-list-item');

const mdtree = md2mdast("- [ ] task1\n\n  task2", {
   extensions: [strikethroughSyntax(), tasklistitemSyntax],
   mdastExtensions: [strikethrough.fromMarkdown, tasklistitem.fromMarkdown]
});

Here is the result of mdtree:

{
  "type": "root",
  "children": [
    {
      "type": "list",
      "ordered": false,
      "start": null,
      "spread": false,
      "children": [
        {
          "type": "listItem",
          "spread": true,
          "checked": false,
          "children": [
            {
              "type": "paragraph",
              "children": [
                {
                  "type": "text",
                  "value": "task1",
                  "position": {
                    "start": {
                      "line": 1,
                      "column": 7,
                      "offset": 6
                    },
                    "end": {
                      "line": 1,
                      "column": 12,
                      "offset": 11
                    }
                  }
                }
              ],
              "position": {
                "start": {
                  "line": 1,
                  "column": 7,
                  "offset": 6
                },
                "end": {
                  "line": 1,
                  "column": 12,
                  "offset": 11
                }
              }
            },
            {
              "type": "paragraph",
              "children": [
                {
                  "type": "text",
                  "value": "ask2",
                  "position": {
                    "start": {
                      "line": 3,
                      "column": 4,
                      "offset": 16
                    },
                    "end": {
                      "line": 3,
                      "column": 8,
                      "offset": 20
                    }
                  }
                }
              ],
              "position": {
                "start": {
                  "line": 3,
                  "column": 4,
                  "offset": 16
                },
                "end": {
                  "line": 3,
                  "column": 8,
                  "offset": 20
                }
              }
            }
          ],
          "position": {
            "start": {
              "line": 1,
              "column": 1,
              "offset": 0
            },
            "end": {
              "line": 3,
              "column": 8,
              "offset": 20
            }
          }
        }
      ],
      "position": {
        "start": {
          "line": 1,
          "column": 1,
          "offset": 0
        },
        "end": {
          "line": 3,
          "column": 8,
          "offset": 20
        }
      }
    }
  ],
  "position": {
    "start": {
      "line": 1,
      "column": 1,
      "offset": 0
    },
    "end": {
      "line": 3,
      "column": 8,
      "offset": 20
    }
  }
}

Problem: task2 has been cut into ask2

wooorm commented 3 years ago

Thanks, I’m able to reproduce it.

wooorm commented 3 years ago

Fixed in 0.1.5