fix(pdf-creator): resolve CJK text garbled in weasyprint code blocks

weasyprint renders <pre> blocks with monospace fonts that lack CJK glyphs,
causing Chinese/Japanese/Korean characters to display as garbled text.

Fix: add _fix_cjk_code_blocks() preprocessor that detects CJK in <pre><code>
and converts to <div class="cjk-code-block"> with inherited body font.
Pure-ASCII code blocks are left untouched.

Also adds code/pre/pre-code CSS rules to both themes (default + warm-terra)
that were previously missing entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
daymade
2026-04-08 15:01:13 +08:00
parent 9242af5fcb
commit edaeaa89f4
5 changed files with 115 additions and 2 deletions

View File

@@ -416,7 +416,7 @@
"description": "Create PDF documents from markdown with Chinese font support. Supports theme system (default for formal docs, warm-terra for training materials) and dual backend (weasyprint or Chrome). Triggers include convert to PDF, generate PDF, markdown to PDF, or printable documents",
"source": "./",
"strict": false,
"version": "1.2.0",
"version": "1.3.0",
"category": "document-conversion",
"keywords": [
"pdf",
@@ -425,6 +425,7 @@
"chrome",
"themes",
"chinese-fonts",
"cjk",
"document-generation",
"legal",
"reports",