mirror of https://gitlab.com/bashrc2/epicyon
Escape html code
parent
31017ab46d
commit
32be2a8f55
12
markdown.py
12
markdown.py
|
@ -276,6 +276,13 @@ def _markdown_replace_code(markdown: str) -> str:
|
||||||
changed = False
|
changed = False
|
||||||
section_active = False
|
section_active = False
|
||||||
urlencode = False
|
urlencode = False
|
||||||
|
html_escape_table = {
|
||||||
|
"&": "&",
|
||||||
|
'"': """,
|
||||||
|
"'": "'",
|
||||||
|
">": ">",
|
||||||
|
"<": "<"
|
||||||
|
}
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if not line.strip():
|
if not line.strip():
|
||||||
# skip blank lines
|
# skip blank lines
|
||||||
|
@ -293,7 +300,10 @@ def _markdown_replace_code(markdown: str) -> str:
|
||||||
if urlencode:
|
if urlencode:
|
||||||
lines[start_line] = '<pre>\n<code>'
|
lines[start_line] = '<pre>\n<code>'
|
||||||
lines[line_ctr] = '</code>\n</pre>'
|
lines[line_ctr] = '</code>\n</pre>'
|
||||||
|
for line_num in range(start_line + 1, line_ctr):
|
||||||
|
lines[line_num] = \
|
||||||
|
"".join(html_escape_table.get(char, char)
|
||||||
|
for char in lines[line_num])
|
||||||
section_active = False
|
section_active = False
|
||||||
changed = True
|
changed = True
|
||||||
urlencode = False
|
urlencode = False
|
||||||
|
|
Loading…
Reference in New Issue