diff --git a/cmd/tools/vdoc/html.v b/cmd/tools/vdoc/html.v
index 07099ca9ac..e253898875 100644
--- a/cmd/tools/vdoc/html.v
+++ b/cmd/tools/vdoc/html.v
@@ -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
}
/*
diff --git a/cmd/tools/vdoc/html_tag_escape_test.v b/cmd/tools/vdoc/html_tag_escape_test.v
new file mode 100644
index 0000000000..64a7d1c9c6
--- /dev/null
+++ b/cmd/tools/vdoc/html_tag_escape_test.v
@@ -0,0 +1,6 @@
+module main
+
+fn test_html_tag_escape() {
+ assert html_tag_escape('') == '<abc>'
+ assert html_tag_escape('``') == '``'
+}