Closed NickSto closed 3 years ago
Okay apparently what I'm missing is that '\\\n'
is another, valid syntax for a break
?
For some reason my system isn't rendering a <br/>
there.* In any case, I feel like the double-space syntax is far more common. An option to prefer that would be nice.
* I'm using @gridsome/transformer-remark, which apparently just uses remark-parse
and remark-html
, which doesn't omit the <br/>
when I test it in isolation. Not sure why that happens.
Yep, that’s valid markdown:
a\
b
^-- a break.
Before commonmark, you had to use two spaces. But that’s quite a bad idea imo.
Indeed, it’s Gridsome using old remark. You might pass commonmark: true
to that version of remark to support it though (being spec compliant used to be an option, before the spec got widely supported).
But it might be better to get gridsome to update. Or use remark directly / through something else?
Initial checklist
Affected packages and versions: mdast-util-to-markdown 0.6.5
Steps to reproduce
Input:
Code used:
Expected behavior
Expected output:
Actual behavior
Actual output:
I'm not sure why it's joining these lines with a backslash + line break. That's like the opposite of a break.
I don't think it's an issue with the parser; the tree seems correct as far as I can tell:
Is there something I'm missing?
The
break
handler seems to have'\\\n'
hardcoded, and in no case will return what I expect (' \n'
). Am I misunderstanding what abreak
is supposed to be? If so, why isremark-parse
returning it for a double-spaced line ending?I could apparently fix this by giving it the option
{handlers: {'break': _ => ' \n'}}
but I assume this isn't the default for a reason?Environment
mdast-util-to-markdown: 0.6.5 remark-stringify: 9.0.1 remark-parse: 9.0.0 yarn: 1.22.10 node: v14.15.1 OS: Ubuntu 20.04.2