From f7d84b4f0fa22813dd1fe482cedfac14de043f4e Mon Sep 17 00:00:00 2001 From: Mikkeli Matlock Date: Thu, 11 Jun 2026 00:02:02 +0900 Subject: [PATCH] =?UTF-8?q?fix(tech):=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 Co-Authored-By: Claude Sonnet 4.6 --- pipelines/tech/README.md | 3 +-- pipelines/tech/SCHEMA.md | 8 +++----- pipelines/tech/publish.py | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pipelines/tech/README.md b/pipelines/tech/README.md index 2f9523e..2050bcd 100644 --- a/pipelines/tech/README.md +++ b/pipelines/tech/README.md @@ -8,8 +8,7 @@ Publishes tech blog posts from `mikkeli/tech-blogs` to `https://wiki.novoyuuparo ## v1 scope - YAML frontmatter parsing per [SCHEMA.md](SCHEMA.md) -- Pandoc-based markdown → wikitext body rendering -- First-line h1 stripping +- Pandoc-based markdown → wikitext body rendering (h1 elements preserved) - Auto-generated banner (`{{Auto-generated|source=...|commit=}}`) - Category injection: `[[Category:Tech blog]]` on every page; `[[Category:Blog:]]` from `date` field; `[[Category:]]` per tag entry - No title prefix — pages live at their bare title diff --git a/pipelines/tech/SCHEMA.md b/pipelines/tech/SCHEMA.md index baa5867..e5dc9c4 100644 --- a/pipelines/tech/SCHEMA.md +++ b/pipelines/tech/SCHEMA.md @@ -60,15 +60,14 @@ tags: ## Body -Plain markdown. The renderer strips the first-line `# Heading` if present (it duplicates the wiki page title), then passes the body through Pandoc. +Plain markdown. The body is passed through Pandoc as-is — the first-line `# Heading` is not stripped, so you can use h1 elements freely. ## 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:Tech blog]]`; `[[Category:Blog:]]` if `date` is set; `[[Category:]]` for each tag. 6. Read the current wiki page content; if identical, skip the write (idempotency). @@ -78,8 +77,7 @@ For each `.md` with `wiki.publish: true`: ## Implemented scope - Frontmatter parsing and validation -- Pandoc-based markdown → wikitext rendering -- First-line h1 stripping +- Pandoc-based markdown → wikitext rendering (h1 elements preserved) - Banner template injection - `Category:Tech blog` on every published page - `Category:Blog:` from `date` field diff --git a/pipelines/tech/publish.py b/pipelines/tech/publish.py index 7fc5d91..97da4c3 100644 --- a/pipelines/tech/publish.py +++ b/pipelines/tech/publish.py @@ -11,7 +11,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: @@ -56,7 +56,7 @@ def publish_one(abs_path: Path, source_dir: Path, post, site: mwclient.Site, sou fm = post.metadata title = str(fm["title"]) - 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)