Is it possible, when running a command like 'pandoc 1.md 2.md', for a lua filter to know from which input file a given AST element came (note: an element might come from multiple input docs)? I rather thought that this wasn't possible (but have half a feeling that I've seen something about this recently).

A trick like this might work for you (with a lua filter that looks for divs with class 'new-file')?

% for file in files/*.md; do echo "::: {.new-file file=$file} :::"; cat $file; echo ":::"; echo; done | pandoc
<div class="new-file" data-file="files/1.md">
<p>This is 1.md.</p>
</div>
<div class="new-file" data-file="files/2.md">
<p>And this is 2.md</p>
</div>


On Sun, 7 Aug 2022 at 12:58, Jiří Wolker <woljiri-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hello,

> in a Markdown > HTML workflow, I am looking for a way to create “index”
> pages for a page set that will contain linked lists of block elements (e.g.
> all headings or figures) in that set.
>
> So I’ll have 1.md, 2.md etc. converted to HTML (1.htm), and I’d like to
> generate e.g. a “h1_index.htm” with links to ID’d H1 headings:
>
> <li>1<ul>
> <li><a href="1.htm#first-heading">First Heading</a></li>
> <li><a href="1.htm#second-heading">Second Heading</a></li>
> </ul></li>
> <li>2<ul>
> <li><a href="2.htm#first-heading">First Heading</a></li>
> <li><a href="2.htm#second-heading">Second Heading</a></li>
> </ul></li>
>
> Same for other block elements such as <figcaption> to generate a linked
> list of illustrations.
>
> Can someone suggest how to approach this using only Pandoc (filters)
> instead of using a separate tool?

I would avoid constraining myself to using only Pandoc for everything.
Even Pandoc uses external software package LaTeX for generating PDFs.

I would create a script (or rather a set of scripts) that processes the
files, extracts heading and figure information and creates input file(s)
for Pandoc with the indices.

You can also use custom Lua writer to produce files with indices.
Another option is creating a filter, but this seems to me like slightly
weird way for doing that.

Write me (or to the list) which solution would you like.

Jiří.

--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/9ee132fd-6023-0bf6-02f5-5f72e56392fb%40gmail.com.

--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxjZeP8dhJnVnQuXCvYvnZ84RKbjpKjvQcEVdXbPhTyCCA%40mail.gmail.com.