mirror of
https://github.com/vlang/v.git
synced 2025-09-17 19:36:35 -04:00
vdoc: fix indentation in module readmes (#21220)
This commit is contained in:
parent
19ef7689a6
commit
6a3d8d28b5
@ -18,7 +18,6 @@ const link_svg = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0
|
||||
const single_quote = "'"
|
||||
const double_quote = '"'
|
||||
const no_quotes_replacement = [single_quote, '', double_quote, '']
|
||||
const md_script_escape_seq = ['<script>', '`', '</script>', '`']
|
||||
|
||||
enum HighlightTokenTyp {
|
||||
unone
|
||||
@ -500,13 +499,12 @@ fn html_highlight(code string, tb &ast.Table) string {
|
||||
fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool, tb &ast.Table) string {
|
||||
mut dnw := strings.new_builder(200)
|
||||
head_tag := if head { 'h1' } else { 'h2' }
|
||||
comments := dn.merge_comments_without_examples()
|
||||
// Allow README.md to go through unescaped except for script tags
|
||||
escaped_html := if head && is_module_readme(dn) {
|
||||
// Strip markdown [TOC] directives, since we generate our own.
|
||||
comments.replace('[TOC]', '').replace_each(md_script_escape_seq)
|
||||
dn.comments[0].text
|
||||
} else {
|
||||
comments
|
||||
dn.merge_comments()
|
||||
}
|
||||
mut renderer := markdown.HtmlRenderer{
|
||||
transformer: &MdHtmlCodeHighlighter{
|
||||
|
@ -7,7 +7,7 @@ This is a [link](https://vlang.io/) to the main V site.
|
||||
|
||||
This is a <b>bold text</b>.
|
||||
|
||||
This is a script <script>console.log('hi from README.md');</script> .
|
||||
This is a script `<script>console.log('hi from README.md');</script>` .
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -3,7 +3,7 @@ This is an example of a an .md file, used for adding more rich text
|
||||
documentation in a project or module.
|
||||
This is a link to the main V site.
|
||||
This is a bold text.
|
||||
This is a script console.log('hi from README.md'); .
|
||||
This is a script <script>console.log('hi from README.md');</script> .
|
||||
Examples
|
||||
Processing command line args
|
||||
import os
|
||||
@ -68,7 +68,7 @@ fn auth_verify(secret string, token string) bool {
|
||||
|
||||
This is a <b>bold text</b>.
|
||||
|
||||
This is a script <script>console.log('hi from README.md');</script> .
|
||||
This is a script `<script>console.log('hi from README.md');</script>` .
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<section id="readme_main" class="doc-node">
|
||||
<div class="title"><h1> main <a href="#readme_main">#</a></h1></div>
|
||||
<h2>Description</h2><p>This is an example of a an .md file, used for adding more rich text documentation in a project or module.</p><p>This is a <a href="https://vlang.io/">link</a> to the main V site.</p><p>This is a <b>bold text</b>.</p><p>This is a script <code>console.log('hi from README.md');</code> .</p><h2>Examples</h2><h3>Processing command line args</h3><pre><code class="language-v"><span class="token keyword">import</span> os
|
||||
<h2>Description</h2><p>This is an example of a an .md file, used for adding more rich textdocumentation in a project or module.</p><p>This is a <a href="https://vlang.io/">link</a> to the main V site.</p><p>This is a <b>bold text</b>.</p><p>This is a script <code><script>console.log('hi from README.md');</script></code> .</p><h2>Examples</h2><h3>Processing command line args</h3><pre><code class="language-v"><span class="token keyword">import</span> os
|
||||
|
||||
<span class="token keyword">fn</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||||
<span class="token keyword">dump</span><span class="token punctuation">(</span>os<span class="token punctuation">.</span>args<span class="token punctuation">)</span>
|
||||
|
@ -7,7 +7,7 @@ module main
|
||||
|
||||
This is a <b>bold text</b>.
|
||||
|
||||
This is a script <script>console.log('hi from README.md');</script> .
|
||||
This is a script `<script>console.log('hi from README.md');</script>` .
|
||||
|
||||
## Examples
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user