feat: pelican plugin
This commit is contained in:
parent
970e0da9bc
commit
370fdfb067
33 changed files with 2274 additions and 0 deletions
55
pelican-mews/tests/conftest.py
Normal file
55
pelican-mews/tests/conftest.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"""Shared helpers: build a tiny Pelican site for one fixture case.
|
||||
|
||||
Each case is a directory under tests/fixtures holding the Markdown input
|
||||
and the expected page. The test theme renders a Mews page skeleton that
|
||||
includes the plugin's mews/head.html partial.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from pelican import Pelican
|
||||
from pelican.settings import read_settings
|
||||
|
||||
TESTS = Path(__file__).parent
|
||||
FIXTURES = TESTS / "fixtures"
|
||||
THEME = TESTS / "theme"
|
||||
|
||||
BASE_SETTINGS = {
|
||||
"ARTICLE_PATHS": [],
|
||||
"MARKDOWN": {"output_format": "xhtml"},
|
||||
"PAGE_PATHS": ["pages"],
|
||||
"PAGE_SAVE_AS": "{slug}.xhtml",
|
||||
"PAGE_URL": "{slug}.xhtml",
|
||||
"PLUGINS": ["pelican.plugins.mews"],
|
||||
"SITEURL": "",
|
||||
"STATIC_PATHS": [],
|
||||
"TIMEZONE": "UTC",
|
||||
}
|
||||
|
||||
|
||||
def build_case(case: str, root: Path, **override) -> Path:
|
||||
"""Build the fixture site for one case; return its output directory."""
|
||||
pages = root / "content" / "pages"
|
||||
pages.mkdir(parents=True)
|
||||
shutil.copy(FIXTURES / case / "input.md", pages / "input.md")
|
||||
settings = read_settings(
|
||||
override={
|
||||
**BASE_SETTINGS,
|
||||
"PATH": str(root / "content"),
|
||||
"OUTPUT_PATH": str(root / "output"),
|
||||
"THEME": str(THEME),
|
||||
**override,
|
||||
}
|
||||
)
|
||||
Pelican(settings).run()
|
||||
return root / "output"
|
||||
|
||||
|
||||
def normalize(data: bytes) -> str:
|
||||
"""Canonical form of a Mews page, indifferent to whitespace."""
|
||||
return etree.canonicalize(xml_data=data.decode("utf-8"), strip_text=True)
|
||||
Loading…
Add table
Add a link
Reference in a new issue