-
Notifications
You must be signed in to change notification settings - Fork 105
143 lines (114 loc) · 5.9 KB
/
Copy pathbuild-html.yml
File metadata and controls
143 lines (114 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Build HTML Lab Manual
on:
push:
branches: [master]
paths:
- 'lab_manual.tex'
- 'tufte.cfg'
- 'toc.js'
- 'checklist.js'
- 'lab-manual.css'
- '.github/workflows/build-html.yml'
pull_request:
branches: [master]
paths:
- 'lab_manual.tex'
- 'tufte.cfg'
- 'toc.js'
- 'checklist.js'
- 'lab-manual.css'
workflow_dispatch: # Allow manual triggering
permissions:
contents: read
pages: write
id-token: write
# Only allow one deployment at a time
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build-html:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install TeX Live
run: |
sudo apt-get update
sudo apt-get install -y texlive-latex-extra texlive-fonts-extra texlive-plain-generic tex4ht texlive-luatex
- name: Run tex4ht conversion
run: |
mkdir -p html_output
# htlatex uses set -e, so it stops on first error.
# We need to run the steps manually to continue past LaTeX warnings.
# htlatex does: 3x latex, tex4ht, t4ht
echo "=== Running latex pass 1 ==="
latex -interaction=nonstopmode '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode tufte,mathml,mathjax.a.b.c.\input ' lab_manual.tex || true
echo "=== Running latex pass 2 ==="
latex -interaction=nonstopmode '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode tufte,mathml,mathjax.a.b.c.\input ' lab_manual.tex || true
echo "=== Running latex pass 3 ==="
latex -interaction=nonstopmode '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode tufte,mathml,mathjax.a.b.c.\input ' lab_manual.tex || true
echo "=== Running tex4ht ==="
tex4ht -f/lab_manual -cunihtf -utf8 || true
echo "=== Running t4ht ==="
t4ht -f/lab_manual || true
echo "=== Files after conversion ==="
ls -la
# Move generated files to html_output
mv lab_manual.html html_output/ 2>/dev/null || true
mv lab_manual.css html_output/ 2>/dev/null || true
mv lab_manual*.png html_output/ 2>/dev/null || true
echo "=== html_output contents ==="
ls -la html_output/
- name: Download Tufte CSS assets
run: |
# Download tufte.css
curl -sL -o html_output/tufte.css https://raw.githubusercontent.com/edwardtufte/tufte-css/gh-pages/tufte.css
# Download ET Book fonts - tufte.css expects fonts in subdirectories
# The @font-face rules expect paths like: et-book/et-book-roman-line-figures/et-book-roman-line-figures.woff
for font in et-book-roman-line-figures et-book-roman-old-style-figures et-book-semi-bold-old-style-figures et-book-bold-line-figures et-book-display-italic-old-style-figures; do
mkdir -p "html_output/et-book/${font}"
curl -sL -o "html_output/et-book/${font}/${font}.ttf" "https://github.com/edwardtufte/tufte-css/raw/gh-pages/et-book/${font}/${font}.ttf" 2>/dev/null || true
curl -sL -o "html_output/et-book/${font}/${font}.woff" "https://github.com/edwardtufte/tufte-css/raw/gh-pages/et-book/${font}/${font}.woff" 2>/dev/null || true
done
# Copy lab logo
cp -r lab_logo html_output/
# Copy custom files (toc.js for table of contents, checklist.js for interactive checklist, lab-manual.css for custom styling)
cp toc.js html_output/
cp checklist.js html_output/
cp lab-manual.css html_output/
# Rename main HTML file to index.html if needed
if [ -f html_output/lab_manual.html ] && [ ! -f html_output/index.html ]; then
cp html_output/lab_manual.html html_output/index.html
fi
- name: List output files
run: ls -la html_output/
- name: Upload HTML artifact
uses: actions/upload-artifact@v4
with:
name: html-lab-manual
path: html_output/
retention-days: 30
# Deploy to GitHub Pages only on push to master
deploy:
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: build-html
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: html-lab-manual
path: html_output
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: html_output
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4