Skip to content

Commit 9c0d1e8

Browse files
authored
add scripts to generate pdf (#72)
1 parent 741a9ff commit 9c0d1e8

10 files changed

Lines changed: 670 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and release PDF
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install build dependencies
18+
env:
19+
DEBIAN_FRONTEND: noninteractive
20+
run: |
21+
sudo apt-get install pandoc texlive-latex-base texlive-xetex fonts-inter
22+
23+
- name: Build PDF
24+
run: |
25+
./pdf/build.sh
26+
27+
- name: Create release
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
REVIEW_DATE="`cat LAST_MAJOR_REVIEW.txt`"
32+
GENERATED_DATE=`date -u '+%Y-%m-%d'`
33+
gh release create release-${{ github.sha }} \
34+
--notes "PDF generated: $GENERATED_DATE | Last major curriculum review: $REVIEW_DATE" \
35+
--target ${{ github.sha }} \
36+
--title $GENERATED_DATE \
37+
pdf/MDN-Curriculum.pdf

LAST_MAJOR_REVIEW.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2024-02-01

pdf/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pdf

pdf/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
First, ensure you've got the appropriate packages installed. For Ubuntu:
2+
3+
```sh
4+
sudo apt install pandoc texlive-latex-base texlive-xetex fonts-inter
5+
```
6+
7+
Then generate the PDF:
8+
9+
```sh
10+
./build.sh
11+
```

pdf/adjust-links.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function Link(el)
2+
local id = el.target
3+
4+
-- Fix relative links
5+
if id:sub(1,1) == "." then
6+
if id:find("#") then
7+
-- before: "../foo.md#bar"
8+
-- after: "#bar"
9+
id = id:match("(#.*)")
10+
else
11+
-- before: "../foo.md"
12+
-- after: "#foo"
13+
id = id:match(".*/(.*).md")
14+
id = "#" .. id
15+
end
16+
end
17+
18+
-- Fix section header links
19+
if id:sub(1,1) == '#' then
20+
-- before: "#2.1_foo_bar"
21+
-- after: "#foo-bar"
22+
id = id:gsub("_", "-")
23+
id = id:gsub("^[^a-zA-Z]+", "")
24+
id = "#" .. id
25+
end
26+
27+
el.target = id
28+
return el
29+
end

pdf/build.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env sh
2+
3+
cd "$(dirname "$0")"
4+
5+
export GENERATED_DATE=$(date -u "+%B %d, %Y")
6+
export REVIEW_DATE=$(date -d $(cat ../LAST_MAJOR_REVIEW.txt) "+%B, %Y")
7+
8+
pandoc header.md ../curriculum/**/*.md -s \
9+
-o MDN-Curriculum.pdf \
10+
--metadata review_date="$REVIEW_DATE" \
11+
--template=template.tex \
12+
--pdf-engine=xelatex \
13+
--lua-filter=adjust-links.lua \
14+
--include-in-header=header.tex

pdf/header.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# See: https://pandoc.org/MANUAL.html#variables
3+
title: MDN Curriculum
4+
subtitle: The essential skillset for new front-end developers
5+
author-meta: The MDN Team
6+
toc: true
7+
include-before: |
8+
```{=latex}
9+
PDF generated: \today
10+
11+
Last major curriculum review: \reviewdate
12+
```
13+
14+
> **MDN recommends Scrimba**
15+
>
16+
> We recommend [The Frontend Developer Career Path](https://v2.scrimba.com/the-frontend-developer-career-path-c0j?via=mdn) from our learning partner, [Scrimba](https://scrimba.com/?via=mdn). This course provides a fun, interactive learning experience that teaches all of the MDN Curriculum Core and more.
17+
>
18+
> [Check it out](https://v2.scrimba.com/the-frontend-developer-career-path-c0j?via=mdn)
19+
geometry:
20+
- a4paper
21+
- margin=2cm
22+
linkcolor: link
23+
urlcolor: link
24+
mainfont: Inter
25+
---

pdf/header.tex

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
\definecolor{link}{HTML}{0069C2}
2+
\definecolor{quote-bg}{HTML}{fcefe2}
3+
4+
\usepackage{mdframed}
5+
\renewenvironment{quote}
6+
{\vspace{1em}\begin{mdframed}[
7+
backgroundcolor=quote-bg,
8+
linewidth=0em,
9+
innerleftmargin=1.5em,
10+
innerrightmargin=1.5em,
11+
innertopmargin=1.5em,
12+
innerbottommargin=1.5em,
13+
skipabove=0,
14+
skipbelow=0,
15+
nobreak=true
16+
]\raggedright
17+
}
18+
{\end{mdframed}\vspace{1em}}
19+
20+
\linespread{1.3}
21+
22+
\usepackage{enumitem}
23+
\setlist[itemize,1]{label=\textbullet}
24+
\setlist[itemize,2]{label=\textbullet}
25+
\setlist[itemize,3]{label=\textbullet}
26+
\setlist[itemize,4]{label=\textbullet}
27+
28+
\usepackage{graphicx}
29+
30+
\usepackage{fancyhdr}
31+
\pagestyle{fancy}
32+
33+
\renewcommand{\headrulewidth}{0pt}
34+
\fancyhead{}
35+
\fancyhead[L]{\href{https://developer.mozilla.org/en-US/curriculum/}{\includegraphics[height=0.5cm]{logo.png}}}
36+
37+
\fancyfoot[L]{PDF generated: \today}
38+
\fancyfoot[R]{Curriculum reviewed: \reviewdate}
39+
40+
\usepackage{titling}
41+
\setlength{\droptitle}{-2.5cm}
42+
\pretitle{\begin{flushleft}\href{https://developer.mozilla.org/en-US/curriculum/}{\includegraphics[height=0.5cm]{logo.png}}\\[2cm]\bfseries\LARGE}
43+
\posttitle{\end{flushleft}}
44+
45+
\preauthor{\begin{flushleft}}
46+
\postauthor{\end{flushleft}}
47+
48+
\predate{\begin{flushleft}}
49+
\postdate{\end{flushleft}}
50+
51+
\raggedright

pdf/logo.png

5.01 KB
Loading

0 commit comments

Comments
 (0)