feat: let a site choose which suffix the plugin treats as Mews

This commit is contained in:
randogoth 2026-10-11 21:07:07 +03:00
parent 0d9cf1ed26
commit 5e2e709496
3 changed files with 53 additions and 2 deletions

View file

@ -28,6 +28,44 @@ def test_written_page_matches_expected(tmp_path, case):
assert normalize(page) == normalize(expected)
def test_a_site_can_choose_its_own_suffix(tmp_path):
"""A site that is Mews throughout writes .html, so servers send text/html."""
output = build_case(
"basic",
tmp_path,
MEWS_SUFFIX=".html",
PAGE_SAVE_AS="{slug}.html",
PAGE_URL="{slug}.html",
# With .html the plugin sees every page Pelican writes, including the
# index, tags and archives it falls back to when the theme has no
# template for them. Those fallbacks are HTML, not XML, so a site
# using .html has to give every direct template a Mews template or
# switch the lot off, as here.
DIRECT_TEMPLATES=[],
)
page = (output / "page.html").read_bytes()
assert normalize(page) == normalize(
(FIXTURES / "basic" / "expected.xhtml").read_bytes()
)
def test_the_default_suffix_leaves_other_html_alone(tmp_path):
"""Left at its default the plugin must not touch a plain HTML page."""
output = build_case(
"strip",
tmp_path,
PAGE_SAVE_AS="{slug}.html",
PAGE_URL="{slug}.html",
INDEX_SAVE_AS="",
)
# The strip fixture carries a <span>, a class and a comment, all three of
# which the plugin removes. Untouched, every one of them survives.
written = (output / "page.html").read_bytes()
assert b"<span" in written
assert b'class="big"' in written
assert b"stray comment" in written
@pytest.mark.parametrize("case", ["basic", "strip", "cssdir", "structure"])
def test_css_is_copied(tmp_path, case):
"""The bundled stylesheet lands under the configured directory."""