syntax-tree / mdast-util-to-markdown

mdast utility to serialize markdown
http://unifiedjs.com
MIT License
100 stars 20 forks source link

Regression (?): 0.6.5 removes line breaks after `\` #27

Closed tripodsan closed 3 years ago

tripodsan commented 3 years ago

the following mdast:

root[1]
└─0 paragraph[6]
    ├─0 text "hello, world"
    ├─1 break
    ├─2 html " "
    ├─3 text "  no code"
    ├─4 break
    └─5 text "end."

was stringified with 0.5.3:

hello, world\
   no code\
end.

but with 0.6.5:

hello, world\    no code\
end.

note the difference in github:


hello, world\   no code\ end.


hello, world\   no code\ end.


wooorm commented 3 years ago

Yes this changed, because actual html at the start of a line in a paragraph, is almost always seen as block html.

A) why is the character reference an html node? That's not what they're for 🤔 and it's coming from some plugin you use? B) why have a nbsp there?

tripodsan commented 3 years ago

A) why is the character reference an html node? That's not what they're for 🤔 and it's coming from some plugin you use?

is there a better way to do this?

B) why have a nbsp there?

for our use case, we want to suppress code-blocks in markdown when prefixed with 4 spaces, because authors sometimes use them to format / align the text to make it look nicer (the old add many spaces instead of using tab-stops problem).

but I just realized, that consecutive spaces are anyways collated to 1 space when rendered, so we can do this differently.

wooorm commented 3 years ago

Where's the code where you inject those? Markdown let's you indent text as much as you want (but not on the first line of the paragraph)

wooorm commented 3 years ago

You can also inject the actual nbsp character in text, instead of as a reference?

tripodsan commented 3 years ago

the source is a word-document that we convert to mdast. but I think for our use case, we can just collapse the spaces.