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:
@@ -57,4 +57,6 @@ uv run --with weasyprint scripts/batch_convert.py *.md --output-dir ./pdfs
|
||||
|
||||
**weasyprint import error**: Run with `uv run --with weasyprint` or use `--backend chrome` instead.
|
||||
|
||||
**CJK text in code blocks garbled (weasyprint)**: The script auto-detects code blocks containing Chinese/Japanese/Korean characters and converts them to styled divs with CJK-capable fonts. If you still see issues, use `--backend chrome` which has native CJK support. Alternatively, convert code blocks to markdown tables before generating the PDF.
|
||||
|
||||
**Chrome header/footer appearing**: The script passes `--no-pdf-header-footer`. If it still appears, your Chrome version may not support this flag — update Chrome.
|
||||
|
||||
Reference in New Issue
Block a user