summaryrefslogtreecommitdiff
path: root/filters/strip-solutions.lua
blob: 2bba42f3597d281aebe5205805ce301654e7946b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- Pandoc filter which strips "solution" blocks when the environment variable
-- "STRIP_SOLUTIONS" is set, or wrap them in a block quote otherwise.
-- Useful to generate public and private handouts from the same source.
--
-- Author: Pacien TRAN-GIRARD
-- Licence: EUPL-1.2

strip_solutions = os.getenv('STRIP_SOLUTIONS')

return {
  {
    Div = function(elem)
      if elem.classes[1] == 'solution' then
        if strip_solutions then
          return pandoc.Null()
        else
          return pandoc.BlockQuote(elem.content)
        end
      else
        return elem
      end
    end,
  }
}