mirror of
https://github.com/Findus23/RPGnotes.git
synced 2024-09-19 15:43:45 +02:00
20 lines
376 B
Python
20 lines
376 B
Python
|
import bleach
|
||
|
import markdown
|
||
|
from bleach_allowlist import markdown_tags, markdown_attrs
|
||
|
|
||
|
|
||
|
def md_to_html(md: str) -> str:
|
||
|
html = markdown.markdown(
|
||
|
md,
|
||
|
output_format="html",
|
||
|
extensions=[
|
||
|
"nl2br",
|
||
|
]
|
||
|
)
|
||
|
html = bleach.clean(
|
||
|
html,
|
||
|
tags=markdown_tags,
|
||
|
attributes=markdown_attrs
|
||
|
)
|
||
|
return html
|