Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown documentation generation: do not insert line breaks #1879

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

yannham
Copy link
Member

@yannham yannham commented Apr 3, 2024

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.

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
commit just removes the line break altogether, which is not useful and
never legal anyway.
@github-actions github-actions bot temporarily deployed to pull request April 3, 2024 10:21 Inactive
@yannham yannham added this pull request to the merge queue Apr 3, 2024
Merged via the queue into master with commit b4b1779 Apr 3, 2024
5 checks passed
@yannham yannham deleted the fix/doc-spurious-backslashes branch April 3, 2024 11:47
@jneem
Copy link
Member

jneem commented Apr 3, 2024

Doesn't this regress the example in #1520?

@yannham
Copy link
Member Author

yannham commented Apr 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The markdown nickel doc output prints some spurious backslashes
4 participants