Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/utils.py
Show First 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | Args: | ||||
rst: A string containing a reStructuredText document | rst: A string containing a reStructuredText document | ||||
Returns: | Returns: | ||||
Body content of the produced HTML conversion. | Body content of the produced HTML conversion. | ||||
""" | """ | ||||
settings = { | settings = { | ||||
"initial_header_level": 2, | "initial_header_level": 2, | ||||
"halt_level": 4, | |||||
"traceback": True, | |||||
} | } | ||||
pp = publish_parts(rst, writer=_HTML_WRITER, settings_overrides=settings) | pp = publish_parts(rst, writer=_HTML_WRITER, settings_overrides=settings) | ||||
return f'<div class="swh-rst">{pp["html_body"]}</div>' | return f'<div class="swh-rst">{pp["html_body"]}</div>' | ||||
def prettify_html(html: str) -> str: | def prettify_html(html: str) -> str: | ||||
""" | """ | ||||
Prettify an HTML document. | Prettify an HTML document. | ||||
Args: | Args: | ||||
html: Input HTML document | html: Input HTML document | ||||
Returns: | Returns: | ||||
The prettified HTML document | The prettified HTML document | ||||
""" | """ | ||||
return BeautifulSoup(html, "lxml").prettify() | return BeautifulSoup(html, "lxml").prettify() |