Closed tripodsan closed 3 years ago
This is related to how to serialize mdast, which is done by mdast-util-gfm-strikethrough, because:
or suppressed by gfm-to-markdown automatically.
How we parse matches github:
Hello, world. stray ~~~~
the empty strikethrough node should not be lost when reparsing.
How could we not loose it? As an empty strikethrough (or emphasis, strong, inline code, paragraph) can’t be made with markdown, we can only change something when roundtripping:
~~a~~
~~~~
(current behavior and imo best behavior: that’s what your tree says to do)There are several other cases where we can’t serialize trees to make sense: e.g., it’s documented here, a similar case is this one. Or, what to do with a heading in a heading? 🤷♂️
Could you sort this out on your side? How are you getting an empty strikethrough node? Maybe it’s a bug there. Or: if for you empty emphasis/strong/delete can be removed, remove them from the tree yourself?
I see the problem - I just stating the fact. you could generate an empty node. if someone really want to have a ~~~~
he can escape it with \~~~~
. but nevermind :-)
Could you sort this out on your side? How are you getting an empty strikethrough node? Maybe it’s a bug there. Or: if for you empty emphasis/strong/delete can be removed, remove them from the tree yourself?
yes, of course. we are transforming a google-doc to mdast... the google-doc has an empty node with a strikethrough style. but we can remove all empty format nodes.
Oh good to hear that you’re in control of the transform to mdast. In that case, it’s more of a bug there, than how we’re handling that mdast. 👍
it's actually more tricky :-)
│ └─4 delete[1]
│ └─0 text ""
It sounds like you‘re using gdocs2md
first, but as that makes serialized markdown, then how are you getting an empty text node? 🤔
It sounds like you‘re using
gdocs2md
first, but as that makes serialized markdown, then how are you getting an empty text node? 🤔
no, we use our own gdocs2mdast library...
Ah. interesting. Is that open source somewhere?
Ah. interesting. Is that open source somewhere?
not (yet).
Subject of the issue
try to roundtrip the following mdast:
stringify produces:
parsing this again produces:
Your environment
Steps to reproduce
Expected behavior
the empty strikethrough node should not be lost when reparsing.
Actual behavior
the empty strikethrough node is converted to text.
Workaround
since the empty strikethrough nodes have no semantic meaning, they could be removed from the mdast prior to serialization, or suppressed by gfm-to-markdown automatically.