Skip to content

Commit

Permalink
add scripts to generate pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Sep 18, 2024
1 parent 741a9ff commit ebd115c
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions pdf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pdf
11 changes: 11 additions & 0 deletions pdf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
First, ensure you've got the appropriate packages installed. For Ubuntu:

```sh
sudo apt install pandoc texlive-latex-base texlive-xetex fonts-inter
```

Then generate the PDF:

```sh
./build.sh
```
23 changes: 23 additions & 0 deletions pdf/adjust-links.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function Link(el)
local id = el.target

-- Fix relative links
if id:sub(1,1) == "." then
if id:find("#") then
id = id:match("(#.*)")
else
id = id:match(".*/(.*).md")
id = "#" .. id
end
end

-- Fix section header links
if id:sub(1,1) == '#' then
id = id:gsub("_", "-")
id = id:gsub("^[^a-zA-Z]+", "")
id = "#" .. id
end

el.target = id
return el
end
10 changes: 10 additions & 0 deletions pdf/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

cd "$(dirname "$0")"

pandoc header.md ../curriculum/**/*.md -s \
-o MDN-Curriculum-`date -u '+%Y-%m'`.pdf \
--metadata date="`date -u '+%Y-%m-%d'`" \
--pdf-engine=xelatex \
--lua-filter=adjust-links.lua \
--include-in-header=header.tex
18 changes: 18 additions & 0 deletions pdf/header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: MDN Curriculum
subtitle: The essential skillset for new front-end developers
author-meta: The MDN Team
toc: true
include-before: |
> **MDN recommends Scrimba**
>
> 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.
>
> [Check it out](https://v2.scrimba.com/the-frontend-developer-career-path-c0j?via=mdn)
geometry:
- a4paper
- margin=2cm
linkcolor: link
urlcolor: link
mainfont: Inter
---
17 changes: 17 additions & 0 deletions pdf/header.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\definecolor{link}{HTML}{0069C2}
\definecolor{quote-bg}{HTML}{fcefe2}

\usepackage{mdframed}
\renewenvironment{quote}
{\begin{mdframed}[
backgroundcolor=quote-bg,
linewidth=0em,
innerleftmargin=1em,
innerrightmargin=1em,
innertopmargin=1em,
innerbottommargin=1em,
skipabove=1em,
skipbelow=1em
]
}
{\end{mdframed}}

0 comments on commit ebd115c

Please sign in to comment.