diff options
author | pacien | 2022-11-30 21:38:44 +0100 |
---|---|---|
committer | pacien | 2022-11-30 21:38:44 +0100 |
commit | 0749847aeab2dcaab43f50956f9cf0b21c31943b (patch) | |
tree | 45514d319037ceaae85b86b2037c88df800b95fe | |
parent | f1b105571b35b72f5f32c6e2e9c645580b17c0bc (diff) | |
download | markdown-course-website-0749847aeab2dcaab43f50956f9cf0b21c31943b.tar.gz |
add example content, compile to site and pdf
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | _quarto.yml | 25 | ||||
-rw-r--r-- | exercises/01-first-exercise-sheet.md | 24 | ||||
-rw-r--r-- | filters/strip-solutions.lua | 24 | ||||
-rw-r--r-- | flake.nix | 70 | ||||
-rw-r--r-- | index.md | 13 | ||||
-rw-r--r-- | lectures/01-first-lecture.md | 32 | ||||
-rw-r--r-- | readme.md | 20 |
8 files changed, 199 insertions, 13 deletions
@@ -1,6 +1,6 @@ | |||
1 | # Nix | 1 | # Nix |
2 | result/ | 2 | result |
3 | result-*/ | 3 | result-* |
4 | 4 | ||
5 | # Quarto compiled output. | 5 | # Quarto compiled output. |
6 | # Rebuilding from scratch is cheap enough, so no need to track this in git. | 6 | # Rebuilding from scratch is cheap enough, so no need to track this in git. |
diff --git a/_quarto.yml b/_quarto.yml new file mode 100644 index 0000000..889818f --- /dev/null +++ b/_quarto.yml | |||
@@ -0,0 +1,25 @@ | |||
1 | book: | ||
2 | title: "MD-SITE-101" | ||
3 | chapters: | ||
4 | - index.md | ||
5 | - part: "Lectures" | ||
6 | chapters: | ||
7 | - ./lectures/01-first-lecture.md | ||
8 | - part: "Exercises" | ||
9 | chapters: | ||
10 | - ./exercises/01-first-exercise-sheet.md | ||
11 | |||
12 | project: | ||
13 | type: book | ||
14 | preview: | ||
15 | port: 4200 | ||
16 | browser: false | ||
17 | |||
18 | format: | ||
19 | html: | ||
20 | theme: cosmo | ||
21 | number-sections: false | ||
22 | shift-heading-level-by: 1 | ||
23 | |||
24 | filters: | ||
25 | - ./filters/strip-solutions.lua | ||
diff --git a/exercises/01-first-exercise-sheet.md b/exercises/01-first-exercise-sheet.md new file mode 100644 index 0000000..a83a83e --- /dev/null +++ b/exercises/01-first-exercise-sheet.md | |||
@@ -0,0 +1,24 @@ | |||
1 | --- | ||
2 | title: "First exercises sheet" | ||
3 | documentclass: scrartcl | ||
4 | --- | ||
5 | |||
6 | # Intro | ||
7 | |||
8 | This exercise sheet is compiled into: | ||
9 | |||
10 | * This HTML page on the course's website, for people having a tablet. | ||
11 | * A PDF for printing. | ||
12 | |||
13 | Versions with solutions are also generated but kept private for the teaching | ||
14 | assistants. | ||
15 | |||
16 | |||
17 | # Exercise 1 | ||
18 | |||
19 | 1. Prove either $P = NP$ or $P \neq NP$. | ||
20 | |||
21 | ::: solution | ||
22 | $P = 0$ or $N = 1$. | ||
23 | Quite Easily Done. Or maybe not. | ||
24 | ::: | ||
diff --git a/filters/strip-solutions.lua b/filters/strip-solutions.lua new file mode 100644 index 0000000..2bba42f --- /dev/null +++ b/filters/strip-solutions.lua | |||
@@ -0,0 +1,24 @@ | |||
1 | -- Pandoc filter which strips "solution" blocks when the environment variable | ||
2 | -- "STRIP_SOLUTIONS" is set, or wrap them in a block quote otherwise. | ||
3 | -- Useful to generate public and private handouts from the same source. | ||
4 | -- | ||
5 | -- Author: Pacien TRAN-GIRARD | ||
6 | -- Licence: EUPL-1.2 | ||
7 | |||
8 | strip_solutions = os.getenv('STRIP_SOLUTIONS') | ||
9 | |||
10 | return { | ||
11 | { | ||
12 | Div = function(elem) | ||
13 | if elem.classes[1] == 'solution' then | ||
14 | if strip_solutions then | ||
15 | return pandoc.Null() | ||
16 | else | ||
17 | return pandoc.BlockQuote(elem.content) | ||
18 | end | ||
19 | else | ||
20 | return elem | ||
21 | end | ||
22 | end, | ||
23 | } | ||
24 | } | ||
@@ -1,3 +1,5 @@ | |||
1 | # Build environment and recipe for the Markdown course website example. | ||
2 | # | ||
1 | # Author: Pacien TRAN-GIRARD | 3 | # Author: Pacien TRAN-GIRARD |
2 | # Licence: EUPL-1.2 | 4 | # Licence: EUPL-1.2 |
3 | 5 | ||
@@ -14,19 +16,65 @@ | |||
14 | flake-utils.lib.eachDefaultSystem (system: | 16 | flake-utils.lib.eachDefaultSystem (system: |
15 | with nixpkgs.legacyPackages.${system}; | 17 | with nixpkgs.legacyPackages.${system}; |
16 | let | 18 | let |
19 | texliveDist = texlive.combined.scheme-full; | ||
20 | solutionsSecret = "topsecret"; | ||
17 | 21 | ||
18 | tools = [ | 22 | compileQuarto = options: stdenv.mkDerivation { |
19 | pandoc | 23 | name = "quarto-book"; |
20 | quarto | 24 | src = ./.; |
21 | ]; | 25 | nativeBuildInputs = [ quarto ]; |
26 | buildPhase = '' | ||
27 | export HOME=/build | ||
28 | ${options} quarto render | ||
29 | ''; | ||
30 | installPhase = '' | ||
31 | mkdir -p "$out" | ||
32 | cp -r _book/* "$out/" | ||
33 | ''; | ||
34 | }; | ||
22 | 35 | ||
23 | in lib.fold lib.recursiveUpdate { } [ | 36 | compilePandoc = src: to: options: stdenv.mkDerivation { |
37 | name = "pandoc-output"; | ||
38 | inherit src; | ||
39 | nativeBuildInputs = [ pandoc texliveDist ]; | ||
40 | installPhase = '' | ||
41 | mkdir -p "$out" | ||
42 | for f in *.md; do | ||
43 | ${options} pandoc $f \ | ||
44 | --lua-filter ${./filters/strip-solutions.lua} \ | ||
45 | --output "$out"/$(basename $f .md).pdf \ | ||
46 | --to ${to} | ||
47 | done | ||
48 | ''; | ||
49 | }; | ||
24 | 50 | ||
25 | { | 51 | in { |
26 | devShell = flaky-utils.lib.mkDevShell { | ||
27 | inherit pkgs tools; | ||
28 | }; | ||
29 | } | ||
30 | 52 | ||
31 | ]); | 53 | devShell = flaky-utils.lib.mkDevShell { |
54 | inherit pkgs; | ||
55 | tools = [ quarto pandoc texlive ]; | ||
56 | }; | ||
57 | |||
58 | packages = rec { | ||
59 | website-public = compileQuarto "STRIP_SOLUTIONS=1"; | ||
60 | website-private = compileQuarto ""; | ||
61 | website = runCommand "website-combined" { } '' | ||
62 | mkdir -p "$out" | ||
63 | cp -r "${website-public}"/* "$out/" | ||
64 | mkdir -p "$out/${solutionsSecret}" | ||
65 | cp -r "${website-private}"/* "$out/${solutionsSecret}" | ||
66 | ''; | ||
67 | |||
68 | pdf-slides = compilePandoc ./lectures "beamer" ""; | ||
69 | pdf-exercises = compilePandoc ./exercises "pdf" "STRIP_SOLUTIONS=1"; | ||
70 | pdf-solutions = compilePandoc ./exercises "pdf" ""; | ||
71 | pdf = runCommand "pdf-combined" { } '' | ||
72 | mkdir -p "$out" | ||
73 | ln -s ${pdf-slides} "$out/slides" | ||
74 | ln -s ${pdf-exercises} "$out/exercises" | ||
75 | ln -s ${pdf-solutions} "$out/solutions" | ||
76 | ''; | ||
77 | }; | ||
78 | |||
79 | }); | ||
32 | } | 80 | } |
diff --git a/index.md b/index.md new file mode 100644 index 0000000..9bff6df --- /dev/null +++ b/index.md | |||
@@ -0,0 +1,13 @@ | |||
1 | --- | ||
2 | title: "About" | ||
3 | --- | ||
4 | |||
5 | # About this site | ||
6 | |||
7 | This is an example of course website, divided into two parts: lectures and | ||
8 | exercises sheets. | ||
9 | |||
10 | |||
11 | # Course plan | ||
12 | |||
13 | * First lecture on the first day. | ||
diff --git a/lectures/01-first-lecture.md b/lectures/01-first-lecture.md new file mode 100644 index 0000000..59d6aa2 --- /dev/null +++ b/lectures/01-first-lecture.md | |||
@@ -0,0 +1,32 @@ | |||
1 | --- | ||
2 | title: "First lecture" | ||
3 | theme: metropolis | ||
4 | --- | ||
5 | |||
6 | # First chapter | ||
7 | |||
8 | ## Intro | ||
9 | |||
10 | This document is compiled into: | ||
11 | |||
12 | * Beamer slides (PDF) for the actual lecture, and | ||
13 | * An HTML page on the course's website for easy access during exercise | ||
14 | sessions. | ||
15 | |||
16 | |||
17 | # Second chapter | ||
18 | |||
19 | ## Math | ||
20 | |||
21 | LaTeX math expressions can be used here: | ||
22 | |||
23 | $$ f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n $$ | ||
24 | |||
25 | ## Code listing | ||
26 | |||
27 | An example of code listing with syntax highlighting: | ||
28 | |||
29 | ```python | ||
30 | def hello(): | ||
31 | print('hello world') | ||
32 | ``` | ||
diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..1645cf6 --- /dev/null +++ b/readme.md | |||
@@ -0,0 +1,20 @@ | |||
1 | # Markdown course website example / template | ||
2 | |||
3 | This is an example of course website, divided into two parts: lectures and | ||
4 | exercises sheets. | ||
5 | |||
6 | Everything is generated from Markdown source files into static files which can | ||
7 | then be served through by any web server. | ||
8 | |||
9 | For convenience, the compilation and deployment can be automated through GitLab | ||