summaryrefslogtreecommitdiff
path: root/filters/strip-solutions.lua
blob: 24221d4e01931d7480eef29a615bc506d752898a (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: CC BY-NC 4.0

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,
  }
}