aboutsummaryrefslogtreecommitdiff
path: root/tools/latex-package-dependencies.lua
blob: aaa8689f8ba5c7a6d37f9b88a62e77bec2f5589d (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
-- Print latex packages needed by pandoc's default latex template.
-- Usage: pandoc lua tools/latex-package-dependencies.lua

local templ = pandoc.template.default("latex")

local packages = {}

templ:gsub("\\usepackage *%b[] *%{([^}]*)%}", function(capt)
  capt:gsub("([^,]+)", function (pkg)
    if not pkg:find("%$") then
      packages[pkg] = true
    end
  end)
end)

templ:gsub("\\usepackage *%{([^}]*)%}", function(capt)
  capt:gsub("([^,]+)", function (pkg)
    if not pkg:find("%$") then
      packages[pkg] = true
    end
  end)
end)

for pkg,_ in pairs(packages) do
  print(pkg)
end