vdoc: minor cleanup (#21258)

This commit is contained in:
Turiiya 2024-04-12 09:34:13 +02:00 committed by GitHub
parent 433f914388
commit 313c3bc49d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 9 deletions

View file

@ -476,7 +476,7 @@ fn html_highlight(code string, tb &ast.Table) string {
buf.write_string('<span class="token ${final_tok_typ}">')
if tok_typ == .string {
// Make sure to escape html in strings. Otherwise it will rendered in the
// Make sure to escape html in strings. Otherwise it will be rendered in the
// html documentation outputs / its style rules will affect the readme.
buf.write_string("'${html.escape(tok.lit.str())}'")
} else {
@ -514,11 +514,10 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
for i := 0; i < readme_lines.len - 1; i++ {
l := readme_lines[i]
nl := readme_lines[i + 1]
is_codeblock_divider := l.trim_left('\x01').trim_space().starts_with('```')
if is_codeblock_divider {
if l.trim_left('\x01').trim_space().starts_with('```') {
is_codeblock = !is_codeblock
}
if !is_codeblock && !is_codeblock_divider && l != '' && nl != ''
if !is_codeblock && l != '' && nl != ''
&& !nl.trim_left('\x01').trim_space().starts_with('```') {
merged_lines << '${l} ${nl}'
i++