mirror of
https://github.com/vlang/v.git
synced 2025-09-08 23:07:19 -04:00
tools: fix v doc
truncating code blocks, that lack a specific language (fix #22017)
This commit is contained in:
parent
633d5f27be
commit
9238dd6b31
@ -516,7 +516,8 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
|
||||
table: tb
|
||||
}
|
||||
}
|
||||
md_content := markdown.render(dn.merge_comments_without_examples(), mut renderer) or { '' }
|
||||
only_comments_text := dn.merge_comments_without_examples()
|
||||
md_content := markdown.render(only_comments_text, mut renderer) or { '' }
|
||||
highlighted_code := html_highlight(dn.content, tb)
|
||||
node_class := if dn.kind == .const_group { ' const' } else { '' }
|
||||
sym_name := get_sym_name(dn)
|
||||
@ -615,7 +616,16 @@ fn (f &MdHtmlCodeHighlighter) transform_attribute(p markdown.ParentType, name st
|
||||
|
||||
fn (f &MdHtmlCodeHighlighter) transform_content(parent markdown.ParentType, text string) string {
|
||||
if parent is markdown.MD_BLOCKTYPE && parent == .md_block_code {
|
||||
return html_highlight(text, f.table)
|
||||
if f.language == '' {
|
||||
return text
|
||||
}
|
||||
output := html_highlight(text, f.table)
|
||||
// Reset the language, so that it will not persist between blocks,
|
||||
// and will not be accidentally re-used for the next block, that may be lacking ```language :
|
||||
unsafe {
|
||||
f.language = ''
|
||||
}
|
||||
return output
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
13
cmd/tools/vdoc/testdata/output_formats/README.md
vendored
13
cmd/tools/vdoc/testdata/output_formats/README.md
vendored
@ -138,3 +138,16 @@ const html = '<!DOCTYPE html>
|
||||
1. Numbered markdown list point 1
|
||||
2. List point 2
|
||||
3. List point 3
|
||||
|
||||
A code block without a specific language should be rendered verbatim:
|
||||
```
|
||||
.
|
||||
├── static/
|
||||
│ ├── css/
|
||||
│ │ └── main.css
|
||||
│ └── js/
|
||||
│ └── main.js
|
||||
└── main.v
|
||||
```
|
||||
|
||||
The End.
|
||||
|
23
cmd/tools/vdoc/testdata/output_formats/main.ansi
vendored
23
cmd/tools/vdoc/testdata/output_formats/main.ansi
vendored
@ -118,6 +118,17 @@ List point 3
|
||||
Numbered markdown list point 1
|
||||
List point 2
|
||||
List point 3
|
||||
|
||||
A code block without a specific language should be rendered verbatim:
|
||||
.
|
||||
├── static/
|
||||
│ ├── css/
|
||||
│ │ └── main.css
|
||||
│ └── js/
|
||||
│ └── main.js
|
||||
└── main.v
|
||||
|
||||
The End.
|
||||
[94mmodule[39m [32mmain[39m
|
||||
## Description
|
||||
|
||||
@ -259,6 +270,18 @@ List point 3
|
||||
2. List point 2
|
||||
3. List point 3
|
||||
|
||||
A code block without a specific language should be rendered verbatim:
|
||||
```
|
||||
.
|
||||
├── static/
|
||||
│ ├── css/
|
||||
│ │ └── main.css
|
||||
│ └── js/
|
||||
│ └── main.js
|
||||
└── main.v
|
||||
```
|
||||
|
||||
The End.
|
||||
|
||||
[94mconst[39m omega = [94m3[39m [90m// should be first[39m
|
||||
[94mconst[39m alpha = [94m5[39m [90m// should be in the middle[39m
|
||||
|
@ -90,7 +90,14 @@ doc2 <span class="token operator">:=</span> toml<span class="token punctuation">
|
||||
console.log(res);
|
||||
}
|
||||
</script>
|
||||
</html>'</span></code></pre><ul><li>Regular markdown list point 1</li><li>List point 2</li><li>List point 3</li></ul><ol><li>Numbered markdown list point 1</li><li>List point 2</li><li>List point 3</li></ol>
|
||||
</html>'</span></code></pre><ul><li>Regular markdown list point 1</li><li>List point 2</li><li>List point 3</li></ul><ol><li>Numbered markdown list point 1</li><li>List point 2</li><li>List point 3</li></ol><p>A code block without a specific language should be rendered verbatim:</p><pre><code>.
|
||||
├── static/
|
||||
│ ├── css/
|
||||
│ │ └── main.css
|
||||
│ └── js/
|
||||
│ └── main.js
|
||||
└── main.v
|
||||
</code></pre><p>The End.</p>
|
||||
|
||||
</section>
|
||||
|
||||
|
12
cmd/tools/vdoc/testdata/output_formats/main.text
vendored
12
cmd/tools/vdoc/testdata/output_formats/main.text
vendored
@ -139,6 +139,18 @@ module main
|
||||
2. List point 2
|
||||
3. List point 3
|
||||
|
||||
A code block without a specific language should be rendered verbatim:
|
||||
```
|
||||
.
|
||||
├── static/
|
||||
│ ├── css/
|
||||
│ │ └── main.css
|
||||
│ └── js/
|
||||
│ └── main.js
|
||||
└── main.v
|
||||
```
|
||||
|
||||
The End.
|
||||
|
||||
const omega = 3 // should be first
|
||||
const alpha = 5 // should be in the middle
|
||||
|
Loading…
x
Reference in New Issue
Block a user