summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2022-11-30 21:38:44 +0100
committerpacien2022-11-30 21:38:44 +0100
commit0749847aeab2dcaab43f50956f9cf0b21c31943b (patch)
tree45514d319037ceaae85b86b2037c88df800b95fe
parentf1b105571b35b72f5f32c6e2e9c645580b17c0bc (diff)
downloadmarkdown-course-website-0749847aeab2dcaab43f50956f9cf0b21c31943b.tar.gz
add example content, compile to site and pdf
-rw-r--r--.gitignore4
-rw-r--r--_quarto.yml25
-rw-r--r--exercises/01-first-exercise-sheet.md24
-rw-r--r--filters/strip-solutions.lua24
-rw-r--r--flake.nix70
-rw-r--r--index.md13
-rw-r--r--lectures/01-first-lecture.md32
-rw-r--r--readme.md20
8 files changed, 199 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index 368c110..db28229 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
1# Nix 1# Nix
2result/ 2result
3result-*/ 3result-*
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 @@
1book:
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
12project:
13 type: book
14 preview:
15 port: 4200
16 browser: false
17
18format:
19 html:
20 theme: cosmo
21 number-sections: false
22 shift-heading-level-by: 1
23
24filters:
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---
2title: "First exercises sheet"
3documentclass: scrartcl
4---
5
6# Intro
7
8This 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
13Versions with solutions are also generated but kept private for the teaching
14assistants.
15
16
17# Exercise 1
18
191. Prove either $P = NP$ or $P \neq NP$.
20
21::: solution
22$P = 0$ or $N = 1$.
23Quite 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
8strip_solutions = os.getenv('STRIP_SOLUTIONS')
9
10return {
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}
diff --git a/flake.nix b/flake.nix
index e465964..aa5c073 100644
--- a/flake.nix
+++ b/flake.nix
@@ -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---
2title: "About"
3---
4
5# About this site
6
7This is an example of course website, divided into two parts: lectures and
8exercises 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---
2title: "First lecture"
3theme: metropolis
4---
5
6# First chapter
7
8## Intro
9
10This 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
21LaTeX 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
27An example of code listing with syntax highlighting:
28
29```python
30def 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
3This is an example of course website, divided into two parts: lectures and
4exercises sheets.
5
6Everything is generated from Markdown source files into static files which can
7then be served through by any web server.
8
9For convenience, the compilation and deployment can be automated through GitLab