aboutsummaryrefslogtreecommitdiff
path: root/pandoc/filters/div-class-to-env.lua
blob: 1a87777b2c55cbda10dc9914da6ebdb7bc250c50 (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
25
26
27
28
29
30
31
--- div-class-to-env.lua – filter to convert classes to LaTeX environments
---
--- Copyright: © 2026 Florian Fischer
--- License:   MIT – see LICENSE file for details

if FORMAT:match('beamer') then
  function Div(d)
    -- ignore code blocks which are not of class "env".
    if not d.classes:includes 'env' then
      return
    end

    local env
    for _, v in ipairs(d.classes) do
      if v ~= 'env' then
        env = v
        break
      end
    end

    if not env then
      return
    end

    return {
      pandoc.RawInline('latex', '\\begin{'..env..'}'),
      d,
      pandoc.RawInline('latex', '\\end{'..env..'}')
    }
  end
end