diff options
Diffstat (limited to 'filters/strip-solutions.lua')
-rw-r--r-- | filters/strip-solutions.lua | 24 |
1 files changed, 24 insertions, 0 deletions
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 | } | ||