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

[Fix] Nickel doc: fix missing newline in markdown output #1880

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ expression: out

- `Hello : Number`
- `Hello | std.string.Stringable`

World\!
14 changes: 13 additions & 1 deletion core/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,10 +895,22 @@ mod doc {
tight: true,
})));

list_item.append(arena.alloc(AstNode::from(NodeValue::Code(NodeCode {
// We have to wrap the content of the list item into a paragraph, otherwise the list won't
// be properly separated from the next block coming after it, producing invalid output (for
// example, the beginning of the documenantation of the current field might be merged with
// the last type or contract item).
//
// We probably shouldn't have to, but afer diving into comrak's rendering engine, it seems
// that some subtle interactions make things work correctly for parsed markdown (as opposed to
// this one being programmatically generated) just because list items are always parsed as
// paragraphs. We thus mimic this unspoken invariant here.
let paragraph = arena.alloc(AstNode::from(NodeValue::Paragraph));

paragraph.append(arena.alloc(AstNode::from(NodeValue::Code(NodeCode {
literal: format!("{ident} {separator} {typ}"),
num_backticks: 1,
}))));
list_item.append(paragraph);

list_item
}
Expand Down
Loading