Super cool! Den ons 29 juni 2022 14:25Albert Krewinkel skrev: > Dear juh, > > "'juh' via pandoc-discuss" writes: > > > Many markdown-files hierarchically ordered in folders. > > Every file starts with the top-level headline mark "#". > > > > I want to convert these files like this: > > > > pandoc $(cat outline.txt) -o target.html > > > > where outline.txt contains the relative pathes to all files. > > > > > > 00.md > > 01/00.md > > 01/01/00.md > > 01/01/01.md > > 01/01/02.md > > > > Is there a way to tell pandoc that it should regard the headline levels > > according to the folder structure? > > Pandoc can't do this out of the box, but you could use a custom reader > to correct the headings. The below requires the current dev version > (nightly build), but could be rewritten to work with a released version, > too. > > The script > > - iterates over all input files, > - parses their contents as a separate document, > - shifts headers in each document by the number of subdirs the > respective file is in, and > - concatenates the individual per-file documents into a single > document that is then returned. > > Pass the reader file to pandoc via the `--from` parameter. > > ``` lua > 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 > ``` > > -- > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 > > -- > You received this message because you are subscribed to the Google Groups > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/87ilojbqsp.fsf%40zeitkraut.de > . > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhAWO5D23ChNizSGSuO-ouwOibBFTs0MmyBwJPGpQZYsVg%40mail.gmail.com.