From 230a3badc30ab710c0d41cf92caff66110fe176d Mon Sep 17 00:00:00 2001 From: Mikkeli Matlock Date: Thu, 11 Jun 2026 00:00:08 +0900 Subject: [PATCH] =?UTF-8?q?fix(ses):=20preserve=20h1=20elements=20?= =?UTF-8?q?=E2=80=94=20do=20not=20strip=20first=20heading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Songs always carries a # Song title line so stripping makes sense there, but SES body structure is freeform and may use h1 deliberately. Co-Authored-By: Claude Sonnet 4.6 --- pipelines/ses/README.md | 1 - pipelines/ses/SCHEMA.md | 10 ++++------ pipelines/ses/publish.py | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pipelines/ses/README.md b/pipelines/ses/README.md index 138f83c..4490a35 100644 --- a/pipelines/ses/README.md +++ b/pipelines/ses/README.md @@ -10,7 +10,6 @@ Publishes SES light novel pages from `mikkeli/ses-light-novel` to `https://wiki. - YAML frontmatter parsing per [SCHEMA.md](SCHEMA.md) - `SES:` title prefix — all pages live in the SES MediaWiki namespace - Pandoc-based markdown → wikitext body rendering -- First-line h1 stripping - Auto-generated banner (`{{Auto-generated|source=...|commit=}}`) - Category injection: `[[Category:SES]]` + `[[Category:SES:]]` on every page; type from `type:` field, falling back to the file's parent directory name - Additional categories via optional `categories` list diff --git a/pipelines/ses/SCHEMA.md b/pipelines/ses/SCHEMA.md index d5c78a4..33e6b75 100644 --- a/pipelines/ses/SCHEMA.md +++ b/pipelines/ses/SCHEMA.md @@ -20,7 +20,7 @@ wiki: ... body markdown ... ``` -The renderer parses the frontmatter, validates required fields, strips the first `# Heading` line if present, then hands the body to Pandoc. +The renderer parses the frontmatter, validates required fields, then hands the body to Pandoc. The first-line `# Heading` is preserved — use it if you want an h1 on the rendered page. ## Fields @@ -69,15 +69,14 @@ categories: ## Body -Plain markdown. The renderer strips the first-line `# Heading` if present, then passes the body through Pandoc. Do not embed raw wikitext (`{{Template}}`, raw `[[Wikilinks]]`, etc.) unless you intend the literal output. +Plain markdown. The body is passed through Pandoc as-is — the first-line `# Heading` is not stripped, so you can use h1 elements freely. Do not embed raw wikitext (`{{Template}}`, raw `[[Wikilinks]]`, etc.) unless you intend the literal output. ## Renderer behaviour For each `.md` with `wiki.publish: true`: 1. Parse and validate frontmatter. -2. Strip the leading `# Heading` from the body if present. -3. Pipe the body through `pandoc -f markdown -t mediawiki`. +2. Pipe the body through `pandoc -f markdown -t mediawiki`. 4. Prepend the auto-generated banner: `{{Auto-generated|source=|commit=}}`. 5. Append category tags: `[[Category:SES]]`, `[[Category:SES:]]`, and any entries from `categories`. 6. Read the current wiki page content via the MediaWiki API; if identical to the generated output, skip the write (idempotency). @@ -88,8 +87,7 @@ For each `.md` with `wiki.publish: true`: - Frontmatter parsing and validation - `SES:` title prefix -- Pandoc-based markdown → wikitext body rendering -- First-line h1 stripping +- Pandoc-based markdown → wikitext body rendering (h1 elements preserved) - Banner template injection - `Category:SES` + `Category:SES:` injection (type from frontmatter, fallback to parent directory) - Additional categories via `categories` list diff --git a/pipelines/ses/publish.py b/pipelines/ses/publish.py index 179089c..7f5f2e1 100644 --- a/pipelines/ses/publish.py +++ b/pipelines/ses/publish.py @@ -10,7 +10,7 @@ import frontmatter import mwclient sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent)) -from lib.wiki import AUTO_BANNER_PREFIX, connect_wiki, markdown_to_wikitext, strip_first_h1 +from lib.wiki import AUTO_BANNER_PREFIX, connect_wiki, markdown_to_wikitext def validate(fm: dict, path: Path) -> None: @@ -58,7 +58,7 @@ def publish_one(abs_path: Path, source_dir: Path, post, site: mwclient.Site, sou title = get_page_title(fm) page_type = get_page_type(fm, abs_path, source_dir) - body_wikitext = markdown_to_wikitext(strip_first_h1(post.content)) + body_wikitext = markdown_to_wikitext(post.content) source_url = f"{gitea_repo_url}/src/commit/{source_ref}/{rel}" page_content = build_wikitext(fm, body_wikitext, source_url, source_ref, page_type)