tweag / nickel

Better configuration for less
https://nickel-lang.org/
MIT License
2.23k stars 85 forks source link

Markdown documentation generation: do not insert line breaks #1879

Closed yannham closed 3 months ago

yannham commented 3 months ago

Fixes #1706.

The code generating markdown documentation from a Nickel configuration used to unconditionally insert hard line breaks between a field's signature and the rest of its documentation. However, one can't insert a hard line break immediately followed by a blocks in commonmark (or put differently: it's not representable as a source), and those line breaks were just rendered as spurious backslashes at best, or sometimes interpreted differently (see #1706 for more details).

A bit of experimentation showed that what comes after this line break is always a block in the sense of commonmark (even when it's simple documentation text, it's wrapped as a Markdown paragraph). Thus this PR just removes the line break altogether, which is not useful and never legal anyway.

jneem commented 3 months ago

Doesn't this regress the example in #1520?

yannham commented 3 months ago

Argh, that's a good point. That being said, I feel this time this is really a comrak issue: it should insert a newline between a list and the following block, but it doesn't. @jneem if you have a branch with the latest comrak, could you see if this has changed in the latest version?

Otherwise another solution (which I actually implemented initially) is to check if the next element is a paragraph manually, and insert the hard line only in this case. It's not too hard, but just doesn't feel right after having read the commonmark spec.