From 845ab04adbb0ec68a2fc3eb7f2411246b0e86031 Mon Sep 17 00:00:00 2001 From: Snowball_233 Date: Wed, 21 Jan 2026 23:09:56 +0800 Subject: [PATCH] Add epub and pdf generation via mdbook-pandoc workflow --- .github/workflows/epub.yml | 55 ++++++++++++++++++++++++++++++++++++++ book.toml | 13 +++++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/workflows/epub.yml diff --git a/.github/workflows/epub.yml b/.github/workflows/epub.yml new file mode 100644 index 00000000..182a1479 --- /dev/null +++ b/.github/workflows/epub.yml @@ -0,0 +1,55 @@ +name: epub + +on: + push: + branches: + - epub + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + name: Build EPUB and PDF + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Tectonic + uses: wtfjoke/setup-tectonic@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Pandoc and Fonts + run: | + sudo apt-get update + sudo apt-get install -y pandoc fonts-noto-cjk + + - name: Install mdbook + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: "latest" + + - name: Install mdbook-pandoc + run: | + cargo install mdbook-pandoc + + - name: Build Book + run: mdbook build + + - name: List Output Directory + if: always() + run: find book -maxdepth 4 + + - name: Upload EPUB + uses: actions/upload-artifact@v4 + with: + name: rust-course-epub + path: book/pandoc/epub/rust-course.epub + + - name: Upload PDF + uses: actions/upload-artifact@v4 + with: + name: rust-course-pdf + path: book/pandoc/pdf/rust-course.pdf diff --git a/book.toml b/book.toml index 51595bc1..6a7d433e 100644 --- a/book.toml +++ b/book.toml @@ -21,3 +21,16 @@ copy-js = true [output.html.fold] enable = true level = 0 + +[output.pandoc] +disabled = false + +[output.pandoc.profile.pdf] +output-file = "rust-course.pdf" +pdf-engine = "tectonic" +to = "pdf" +variables = { mainfont = "Noto Sans CJK SC", sansfont = "Noto Sans CJK SC" } + +[output.pandoc.profile.epub] +output-file = "rust-course.epub" +to = "epub3"