mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: Parse markdown within html block elements
By default, markdown within an HTML block element is not parsed. Add markdown extension to support markdown text within block elements. With this we can annotate our element with a "markdown" attribute: E.g. <details markdown>*Markdown*</details> And thus indicate that the content should be parsed. Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
parent
1ba9e6eb44
commit
a0b2e826be
2 changed files with 17 additions and 0 deletions
|
@ -151,6 +151,7 @@ def update_comment_render(comment: PackageComment) -> None:
|
|||
html = markdown.markdown(
|
||||
text,
|
||||
extensions=[
|
||||
"md_in_html",
|
||||
"fenced_code",
|
||||
LinkifyExtension(),
|
||||
FlysprayLinksExtension(),
|
||||
|
|
|
@ -105,6 +105,22 @@ def test_markdown_conversion(user: User, pkgbase: PackageBase):
|
|||
assert comment.RenderedComment == expected
|
||||
|
||||
|
||||
def test_markdown_in_html_block(user: User, pkgbase: PackageBase):
|
||||
# without "markdown" attribute
|
||||
text = "<details><summary>test</summary>*Hello*</details>"
|
||||
comment = create_comment(user, pkgbase, text)
|
||||
expected = "<details><summary>test</summary>*Hello*</details>"
|
||||
assert comment.RenderedComment == expected
|
||||
|
||||
# with "markdown" attribute
|
||||
text = "<details markdown><summary>test</summary>*Hello*</details>"
|
||||
comment = create_comment(user, pkgbase, text)
|
||||
expected = (
|
||||
"<details>\n<p></p><summary>test</summary><em>Hello</em><p></p>\n</details>"
|
||||
)
|
||||
assert comment.RenderedComment == expected
|
||||
|
||||
|
||||
def test_markdown_strikethrough(user: User, pkgbase: PackageBase):
|
||||
text = "*~~Hello~~world*~~!~~"
|
||||
comment = create_comment(user, pkgbase, text)
|
||||
|
|
Loading…
Add table
Reference in a new issue