Skip to content

Add CDL development environment setup scripts #30

Add CDL development environment setup scripts

Add CDL development environment setup scripts #30

Workflow file for this run

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