Skip to content

Commit e7b0bcf

Browse files
committed
迭代design doc
1 parent 21fd3b1 commit e7b0bcf

2 files changed

Lines changed: 77 additions & 2 deletions

File tree

‎.github/workflows/md-to-pdf.yml‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# 将 docs/DARE_FRAMEWORK_DESIGN.md 转为 PDF(含 Mermaid 图渲染)并上传为 Artifact
2+
name: Build design doc PDF
3+
4+
on:
5+
push:
6+
branches: [main, master, detailed_doc]
7+
paths:
8+
- 'docs/DARE_FRAMEWORK_DESIGN.md'
9+
workflow_dispatch:
10+
11+
jobs:
12+
md-to-pdf:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install Chromium dependencies (for mermaid-cli)
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y \
28+
ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 \
29+
libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 \
30+
libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 \
31+
libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 \
32+
libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 \
33+
libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
34+
lsb-release wget xdg-utils
35+
36+
- name: Install mermaid-cli (mmdc)
37+
run: npm install -g @mermaid-js/mermaid-cli
38+
39+
- name: Setup Python and pandoc-mermaid filter
40+
run: |
41+
sudo apt-get install -y python3 python3-venv python3-pip
42+
python3 -m venv .venv
43+
.venv/bin/pip install pandoc-mermaid-filter
44+
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
45+
echo "PATH=$GITHUB_WORKSPACE/.venv/bin:$PATH" >> $GITHUB_ENV
46+
47+
- name: Install Pandoc and LaTeX (XeLaTeX + CJK)
48+
run: |
49+
sudo apt-get install -y \
50+
pandoc \
51+
texlive-xetex \
52+
texlive-fonts-recommended \
53+
texlive-lang-chinese \
54+
fonts-noto-cjk
55+
56+
- name: Build PDF (with Mermaid rendered as images)
57+
run: |
58+
pandoc docs/DARE_FRAMEWORK_DESIGN.md \
59+
-o DARE_FRAMEWORK_DESIGN.pdf \
60+
--pdf-engine=xelatex \
61+
-V CJKmainfont="Noto Serif CJK SC" \
62+
-V geometry:margin=2.5cm \
63+
-V colorlinks=true \
64+
--toc \
65+
--toc-depth=3 \
66+
--filter pandoc-mermaid
67+
env:
68+
LC_ALL: en_US.UTF-8
69+
70+
- name: Upload PDF artifact
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: DARE_FRAMEWORK_DESIGN-pdf
74+
path: DARE_FRAMEWORK_DESIGN.pdf

‎docs/DARE_FRAMEWORK_DESIGN.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ sequenceDiagram
12491249

12501250
## 附录 B:PDF 导出
12511251

1252-
- Typora:打开本 MD 后导出 PDF。
1253-
- Pandoc:`pandoc docs/DARE_FRAMEWORK_DESIGN.md -o out.pdf --pdf-engine=xelatex -V CJKmainfont=\"SimSun\"`
1252+
- **GitHub Actions**:推送 `docs/DARE_FRAMEWORK_DESIGN.md` 到 `main`/`master`/`detailed_doc` 或在 Actions 页手动触发 workflow「Build design doc PDF」;流水线会使用 pandoc-mermaid 将 Mermaid 代码块渲染为图片后生成 PDF,完成后在对应 run 的 Artifacts 中下载 `DARE_FRAMEWORK_DESIGN-pdf`。
1253+
- **Typora**:打开本 MD 后导出 PDF(可正确渲染 Mermaid)。
1254+
- **Pandoc 本地**:安装 `mmdc`(mermaid-cli)与 `pandoc-mermaid-filter` 后执行 `pandoc docs/DARE_FRAMEWORK_DESIGN.md -o out.pdf --pdf-engine=xelatex -V CJKmainfont="Noto Serif CJK SC" --filter pandoc-mermaid`,可得到含 Mermaid 图的 PDF。
12541255

0 commit comments

Comments
 (0)