New file |
| | |
| | | -- Dieses Skript iteriert durch die übergebenen Markdown-Dateien |
| | | -- und verändert die Gliederungstiefe der Überschrift |
| | | -- anhand der Ordnertiefe. |
| | | -- Es wird als Reader aufgerufen mit der --from/-f Option: |
| | | -- pandoc -f project.lua |
| | | -- |
| | | -- Danke an Albert Krewinkel aus der pandoc Mailingliste |
| | | |
| | | local format = 'markdown+smart' |
| | | |
| | | function Reader (sources, opts) |
| | | local doc = pandoc.Pandoc{} |
| | | for _, source in ipairs(sources) do |
| | | local path_components = #pandoc.path.split(source.name) |
| | | -- last path component is the filename |
| | | local depth = path_components - 1 |
| | | doc = doc .. pandoc.read(source, format, opts):walk { |
| | | Header = function (h) |
| | | h.level = h.level + depth |
| | | return h |
| | | end |
| | | } |
| | | end |
| | | return doc |
| | | end |
| | | |
| | | if PANDOC_VERSION <= {2, 18} then |
| | | local mt = debug.getmetatable(pandoc.Pandoc{}) |
| | | mt.__concat = function (a, b) |
| | | local result = pandoc.Pandoc(a.blocks, a.meta) |
| | | result.blocks:extend(b.blocks) |
| | | for k, v in ipairs(b.meta) do |
| | | result.meta[k] = v |
| | | end |
| | | return result |
| | | end |
| | | end |
| | | |