mirror of
https://github.com/vlang/v.git
synced 2025-09-11 08:25:42 -04:00
vdoc: improve html tag escape (#19266)
This commit is contained in:
parent
0e154bbbfd
commit
dac6f0b0c9
@ -20,6 +20,9 @@ const (
|
|||||||
single_quote = "'"
|
single_quote = "'"
|
||||||
double_quote = '"'
|
double_quote = '"'
|
||||||
no_quotes_replacement = [single_quote, '', double_quote, '']
|
no_quotes_replacement = [single_quote, '', double_quote, '']
|
||||||
|
|
||||||
|
html_tag_escape_replacement = ['<', '<', '>', '>']
|
||||||
|
html_tag_escape_re = regex.regex_opt(r'`.+[(<)(>)].+`') or { panic(err) }
|
||||||
)
|
)
|
||||||
|
|
||||||
enum HighlightTokenTyp {
|
enum HighlightTokenTyp {
|
||||||
@ -450,8 +453,8 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn html_tag_escape(str string) string {
|
fn html_tag_escape(str string) string {
|
||||||
escaped_string := str.replace_each(['<', '<', '>', '>'])
|
escaped_string := str.replace_each(html_tag_escape_replacement)
|
||||||
mut re := regex.regex_opt(r'`.+[(<)(>)].+`') or { regex.RE{} }
|
mut re := html_tag_escape_re
|
||||||
if re.find_all_str(escaped_string).len > 0 {
|
if re.find_all_str(escaped_string).len > 0 {
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user