syntax-tree / mdast-util-gfm-strikethrough

mdast extension to parse and serialize GFM strikethrough
https://unifiedjs.com
MIT License
5 stars 4 forks source link

Code element generated instead of strikethrough #1

Closed RichardFevrier closed 4 years ago

RichardFevrier commented 4 years ago

Consider the following markdown:

"~~~~"

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.2", (latest)
"mdast-util-gfm-task-list-item": "0.1.5", (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("~~~~", {
   extensions: [strikethroughSyntax(), tasklistitemSyntax],
   mdastExtensions: [strikethrough.fromMarkdown, tasklistitem.fromMarkdown]
});

Here is the result of mdtree:

{
   "type":"root",
   "children":[
      {
         "type":"code",
         "lang":null,
         "meta":null,
         "value":"",
         "position":{
            "start":{
               "line":1,
               "column":1,
               "offset":0
            },
            "end":{
               "line":1,
               "column":5,
               "offset":4
            }
         }
      }
   ],
   "position":{
      "start":{
         "line":1,
         "column":1,
         "offset":0
      },
      "end":{
         "line":1,
         "column":5,
         "offset":4
      }
   }
}

Problem: The empty strikethrough text is generated into a code element

wooorm commented 4 years ago

That’s expected: https://spec.commonmark.org/dingus/?text=~~~~

RichardFevrier commented 4 years ago

Effectively I'm sorry I didn't know that one.

wooorm commented 4 years ago

hah, no problem.

But: checking first with CommonMark (the dingus) and GitHub (a private gist) would be appreciated in the future ;)

RichardFevrier commented 4 years ago

Totally 🙏