Skip to content

Commit

Permalink
tools: fix v doc not converting <s> in plain code blocks into encod…
Browse files Browse the repository at this point in the history
…ed html entities in its .html output
  • Loading branch information
spytheman committed Sep 11, 2024
1 parent 1c992de commit 715dc31
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/html.v
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ 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 {
if f.language == '' {
return text
return html.escape(text)
}
output := html_highlight(text, f.table)
// Reset the language, so that it will not persist between blocks,
Expand Down
10 changes: 10 additions & 0 deletions cmd/tools/vdoc/testdata/output_formats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,14 @@ A code block without a specific language should be rendered verbatim:
└── main.v
```

The s tags here in the code block, should be rendered verbatim, not interpreted as HTML ones:
```
h:m:s // 5:02:33
m:s.mi<s> // 2:33.015
s.mi<s> // 33.015s
mi.mc<ms> // 15.007ms
mc.ns<ns> // 7.234us
ns<ns> // 234ns
```

The End.
18 changes: 18 additions & 0 deletions cmd/tools/vdoc/testdata/output_formats/main.ansi
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ A code block without a specific language should be rendered verbatim:
│ └── main.js
└── main.v

The s tags here in the code block, should be rendered verbatim, not interpreted as HTML ones:
h:m:s // 5:02:33
m:s.mi<s> // 2:33.015
s.mi<s> // 33.015s
mi.mc<ms> // 15.007ms
mc.ns<ns> // 7.234us
ns<ns> // 234ns

The End.
module main
## Description
Expand Down Expand Up @@ -281,6 +289,16 @@ The End.
└── main.v
```

The s tags here in the code block, should be rendered verbatim, not interpreted as HTML ones:
```
h:m:s // 5:02:33
m:s.mi<s> // 2:33.015
s.mi<s> // 33.015s
mi.mc<ms> // 15.007ms
mc.ns<ns> // 7.234us
ns<ns> // 234ns
```

The End.

const omega = 3 // should be first
Expand Down
6 changes: 6 additions & 0 deletions cmd/tools/vdoc/testdata/output_formats/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ <h2>Description</h2><p>This is an example of a an .md file, used for adding more
│ └── js/
│ └── main.js
└── main.v
</code></pre><p>The s tags here in the code block, should be rendered verbatim, not interpreted as HTML ones:</p><pre><code>h:m:s // 5:02:33
m:s.mi&lt;s&gt; // 2:33.015
s.mi&lt;s&gt; // 33.015s
mi.mc&lt;ms&gt; // 15.007ms
mc.ns&lt;ns&gt; // 7.234us
ns&lt;ns&gt; // 234ns
</code></pre><p>The End.</p>

</section>
Expand Down
10 changes: 10 additions & 0 deletions cmd/tools/vdoc/testdata/output_formats/main.text
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ module main
└── main.v
```

The s tags here in the code block, should be rendered verbatim, not interpreted as HTML ones:
```
h:m:s // 5:02:33
m:s.mi<s> // 2:33.015
s.mi<s> // 33.015s
mi.mc<ms> // 15.007ms
mc.ns<ns> // 7.234us
ns<ns> // 234ns
```

The End.

const omega = 3 // should be first
Expand Down

0 comments on commit 715dc31

Please sign in to comment.