fix: fix preprocessor paths for v1/v2 mdbook builds (#495)

mdbook runs preprocessor commands from the book root directory (where
book.toml lives). The v1/v2 book.toml files had incorrect relative
paths to the preprocessor scripts, causing them to silently fail and
leaving raw rst directives (.. raw:: html, toc blocks) unprocessed.

Fix by using correct relative paths in book.toml (../tools/ for
top-level books, ../../../tools/ for books/zh/) and changing build
scripts to cd into book directories before running mdbook build.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Yeqi Huang
2026-03-12 14:01:24 +00:00
committed by GitHub
parent d953030747
commit ea4d0d178e
6 changed files with 8 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ fi
--summary-output "${ROOT}/v1/en_chapters/SUMMARY.md" \
--placeholder-prefix "[TODO: src = zh_chapters/"
mdbook build "${ROOT}/v1"
cd "${ROOT}/v1" && mdbook build .
# ── Chinese v1 ────────────────────────────────────────────────────────────────
"${PYTHON_BIN}" "${ROOT}/tools/ensure_book_resources.py" --chapter-dir "${ROOT}/v1/zh_chapters"
@@ -29,4 +29,4 @@ mdbook build "${ROOT}/v1"
--source "${ROOT}/v1/zh_chapters" \
--summary-output "${ROOT}/v1/zh_chapters/SUMMARY.md"
mdbook build "${ROOT}/v1/books/zh"
cd "${ROOT}/v1/books/zh" && mdbook build .

View File

@@ -21,7 +21,7 @@ fi
--summary-output "${ROOT}/v2/en_chapters/SUMMARY.md" \
--placeholder-prefix "[TODO: src = zh_chapters/"
mdbook build "${ROOT}/v2"
cd "${ROOT}/v2" && mdbook build .
# ── Chinese v2 ────────────────────────────────────────────────────────────────
"${PYTHON_BIN}" "${ROOT}/tools/ensure_book_resources.py" --chapter-dir "${ROOT}/v2/zh_chapters"
@@ -29,4 +29,4 @@ mdbook build "${ROOT}/v2"
--source "${ROOT}/v2/zh_chapters" \
--summary-output "${ROOT}/v2/zh_chapters/SUMMARY.md"
mdbook build "${ROOT}/v2/books/zh"
cd "${ROOT}/v2/books/zh" && mdbook build .

View File

@@ -9,7 +9,7 @@ build-dir = "../.mdbook-v1/book"
create-missing = false
[preprocessor.openmlsys]
command = "python3 tools/mdbook_preprocessor.py"
command = "python3 ../tools/mdbook_preprocessor.py"
[output.html]
mathjax-support = true

View File

@@ -9,7 +9,7 @@ build-dir = "../../../.mdbook-v1-zh/book"
create-missing = false
[preprocessor.openmlsys-zh]
command = "python3 tools/mdbook_zh_preprocessor.py"
command = "python3 ../../../tools/mdbook_zh_preprocessor.py"
[output.html]
mathjax-support = true

View File

@@ -9,7 +9,7 @@ build-dir = "../.mdbook-v2/book"
create-missing = false
[preprocessor.openmlsys]
command = "python3 tools/mdbook_preprocessor.py"
command = "python3 ../tools/mdbook_preprocessor.py"
[output.html]
mathjax-support = true

View File

@@ -9,7 +9,7 @@ build-dir = "../../../.mdbook-v2-zh/book"
create-missing = false
[preprocessor.openmlsys-zh]
command = "python3 tools/mdbook_zh_preprocessor.py"
command = "python3 ../../../tools/mdbook_zh_preprocessor.py"
[output.html]
mathjax-support = true