mirror of https://gitlab.com/bashrc2/epicyon
Show html code within manual
parent
e6f7402479
commit
73a7618da6
12
markdown.py
12
markdown.py
|
@ -7,6 +7,8 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Web Interface"
|
__module_group__ = "Web Interface"
|
||||||
|
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
|
|
||||||
def _markdown_get_sections(markdown: str) -> []:
|
def _markdown_get_sections(markdown: str) -> []:
|
||||||
"""Returns a list of sections for markdown
|
"""Returns a list of sections for markdown
|
||||||
|
@ -275,6 +277,7 @@ def _markdown_replace_code(markdown: str) -> str:
|
||||||
line_ctr = 0
|
line_ctr = 0
|
||||||
changed = False
|
changed = False
|
||||||
section_active = False
|
section_active = False
|
||||||
|
urlencode = False
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if not line.strip():
|
if not line.strip():
|
||||||
# skip blank lines
|
# skip blank lines
|
||||||
|
@ -282,13 +285,22 @@ def _markdown_replace_code(markdown: str) -> str:
|
||||||
continue
|
continue
|
||||||
if line.startswith('```'):
|
if line.startswith('```'):
|
||||||
if not section_active:
|
if not section_active:
|
||||||
|
if 'html' in line or 'xml' in line or 'rdf' in line:
|
||||||
|
urlencode = True
|
||||||
start_line = line_ctr
|
start_line = line_ctr
|
||||||
section_active = True
|
section_active = True
|
||||||
else:
|
else:
|
||||||
lines[start_line] = '<code>'
|
lines[start_line] = '<code>'
|
||||||
lines[line_ctr] = '</code>'
|
lines[line_ctr] = '</code>'
|
||||||
|
if urlencode:
|
||||||
|
lines[start_line] = '<pre>'
|
||||||
|
lines[line_ctr] = '</pre>'
|
||||||
|
for line_num in range(start_line + 1, line_ctr):
|
||||||
|
lines[line_num] = \
|
||||||
|
urllib.parse.quote_plus(lines[line_num])
|
||||||
section_active = False
|
section_active = False
|
||||||
changed = True
|
changed = True
|
||||||
|
urlencode = False
|
||||||
line_ctr += 1
|
line_ctr += 1
|
||||||
|
|
||||||
if not changed:
|
if not changed:
|
||||||
|
|
Loading…
Reference in New Issue