Emit code blocks for auto-links in docs

This commit is contained in:
Richard Feldman 2021-08-08 23:25:33 -04:00
parent ea5da5d477
commit 0291d5d0c0

View file

@ -850,7 +850,7 @@ fn markdown_to_html(
Some(&mut broken_link_callback),
)
.fold((0, 0), |(start_quote_count, end_quote_count), event| {
match event {
match &event {
// Replace this sequence (`>>>` syntax):
// Start(BlockQuote)
// Start(BlockQuote)
@ -898,6 +898,23 @@ fn markdown_to_html(
(0, end_quote_count + 1)
}
}
Event::End(Link(LinkType::ShortcutUnknown, _url, _title)) => {
// Replace the preceding Text node with a Code node, so it
// renders as the equivalent of [`List.len`] instead of [List.len]
match docs_parser.pop() {
Some(Event::Text(string)) => {
docs_parser.push(Event::Code(string));
}
Some(first) => {
docs_parser.push(first);
}
None => {}
}
docs_parser.push(event);
(start_quote_count, end_quote_count)
}
_ => {
docs_parser.push(event);
(0, 0)