mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vdoc: fix wrong escaping in HTML docs (#10638)
This commit is contained in:
parent
6674d65397
commit
0f09228adb
@ -4,6 +4,7 @@ import os
|
||||
import net.urllib
|
||||
import strings
|
||||
import markdown
|
||||
import regex
|
||||
import v.scanner
|
||||
import v.ast
|
||||
import v.token
|
||||
@ -493,7 +494,12 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
|
||||
}
|
||||
|
||||
fn html_tag_escape(str string) string {
|
||||
return str.replace_each(['<', '<', '>', '>'])
|
||||
excaped_string := str.replace_each(['<', '<', '>', '>'])
|
||||
mut re := regex.regex_opt(r'`.+[(<)(>)].+`') or { regex.RE{} }
|
||||
if re.find_all_str(excaped_string).len > 0 {
|
||||
return str
|
||||
}
|
||||
return excaped_string
|
||||
}
|
||||
|
||||
/*
|
||||
|
6
cmd/tools/vdoc/html_tag_escape_test.v
Normal file
6
cmd/tools/vdoc/html_tag_escape_test.v
Normal file
@ -0,0 +1,6 @@
|
||||
module main
|
||||
|
||||
fn test_html_tag_escape() {
|
||||
assert html_tag_escape('<abc>') == '<abc>'
|
||||
assert html_tag_escape('`<abc>`') == '`<abc>`'
|
||||
}
|
Loading…
Reference in New Issue
Block a user