Linux native client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.3 KiB

from imwald.core.md_render import markdown_html_fragment, markdown_plain_summary, preprocess_standalone_image_urls
def test_plain_summary_strips_markdown_noise() -> None:
s = markdown_plain_summary("# Title\n\nHello **world**", max_len=80)
assert "Title" in s and "world" in s
assert "**" not in s and "#" not in s
def test_markdown_renders_strong() -> None:
html = markdown_html_fragment("Hello **world**")
assert "<strong>world</strong>" in html or "<b>world</b>" in html
def test_markdown_fenced_code() -> None:
html = markdown_html_fragment("```\n1 + 1\n```")
assert "<pre>" in html and "<code>" in html
def test_preprocess_turns_bare_image_url_into_markdown_image() -> None:
md = "hello\nhttps://example.com/x.png\nbye"
out = preprocess_standalone_image_urls(md)
assert "![](https://example.com/x.png)" in out
def test_markdown_image_wrapped_for_fullsize_link() -> None:
html = markdown_html_fragment("![](https://example.com/wide.png)")
assert "imwald-fullimg" in html
assert "https://example.com/wide.png" in html
assert "<img" in html
def test_nh3_preserves_imwald_profile_href() -> None:
pk = "c" * 64
html = markdown_html_fragment(f"[profile](imwald://pub/{pk})")
assert f'href="imwald://pub/{pk}"' in html