oh a 'filters' subdir! Thanks. So now the pdf gets created w/o error, but there are not footnotes.

neither of these:
    pandoc -L links-with-page-number.lua -o test.pdf test.html
    pandoc -V links-as-notes -L links-with-page-number.lua -o test.pdf test.html
...creates pdf w/ footnotes, so there's no footnote to contain the page number of the linked-to page.

Something undesireable does happen though... I changed the paragraph with the link to:
<p>Here is a link to <a href="#thetarget">important words about the target</a>.</p>
...and the "important words about the target" get removed altogether. Those should not be removed, just the <a> tags around them should be removed.

Thanks for the help so far. I'm excited to see a lua filter in action for my first time. Very curious about the api... I presume pandoc is looking for functions with particular names like Link and Span? Would you mind confirming... this https://pandoc.org/lua-filters.html#type-link is the proper spot in the docs for referencing Link in this context... right?

I imagine this working example produce footnotes w/ page numbers for you in your environment...? Any idea what I could inspect to try to get it working in mine?
On Sunday, November 27, 2022 at 3:57:02 AM UTC-5 Bastien Dumont wrote:
Place the file under `~/.local/share/pandoc/filters`. You don't need the executable flag.

Le Saturday 26 November 2022 à 02:30:58PM, user account a écrit :
> Thanks I wish that worked. I don't know what I'm doing wrong, here's what I've
> got…
>
> `pandoc --version` says user data dir is `~/.local/share/pandoc` so I placed
> this file there as `~/.local/share/pandoc/links-with-page-number.lua` and did
> (just in case) `chmod +x` on it.
>
> `pandoc -o test.pdf test.html` produces a 2page pdf as expected with no
> footnotes.
>
> `pandoc -L links-with-page-number.lua -o test.pdf test.html` fails to produce
> pdf file with:
> ```
> Error running filter links-with-page-number.lua:
> links-with-page-number.lua: openBinaryFile: does not exist (No such file or
> directory)
> ```
>
> There's no typo in my script name or command invocation. Using ~/.pandoc
> instead of ~/.local/share/pandoc doesn't make any difference, still get that
> same error.
>
> Any ideas?
>
> On Saturday, November 26, 2022 at 12:34:15 PM UTC-5 Bastien Dumont wrote:
>
> Please find attached a basic implementation. As in the attached sample HMTL
> file, I suppose that the targets are marked with ids on spans and that you
> link to it via empty <a> elements. If you have a LaTeX installation, simply
> do `pandoc -L links-with-page-number.lua -o test.pdf test.html` to see the
> result.
>
> Le Saturday 26 November 2022 à 05:21:25AM, user account a écrit :
> > Thanks! Yeah injecting html in the intermediary document doesn't sound
> very
> > promising either (again, because the pages have to be built first before
> > footnotes updated with page #s) so maybe I'll abandon weasyprint in this
> case,
> > if this would be easy to do with a *Tex pdf engine. In that case... how
> would
> > one go about this? Would a lua filter be more capable with a different
> pdf
> > engine or would a different mechanism be used?
> >
> > On Saturday, November 26, 2022 at 5:28:31 AM UTC-5 Bastien Dumont wrote:
> >
> > The problem is that Pandoc does not produce the PDF document: it produces
> > the intermediary HTML document that is processed by weasyprint to produce
> > the PDF. So you cannot get page numbers in a Lua filter.
> >
> > However, you can inject raw HTML code in the intermediary file (or in
> your
> > CSS) that will make weasyprint print the page numbers. The question is
> > whether such HTML code exists. It certainly would be possible to do this
> if
> > you converted to PDF via LaTeX, ConTeXt or groff, but I don't know if it
> is
> > possible via weasyprint.
> >
> > Le Friday 25 November 2022 à 04:33:05PM, user account a écrit :
> > > Using pandoc with weasyprint pdf engine to turn the markdown files from
> a
> > blog
> > > (static site generator does the html conversion) into a pdf for print.
> > >
> > > Would it be possible, perhaps with a custom lua filter or some other
> > mechanism,
> > > to add the page number of the linked-to page? The page numbers won't be
> > known
> > > until pandoc has already created the document, and I don't know where
> in
> > 'the
> > > pipeline' the lua filter intervenes compared to when the pages
> exist...?
> > And
> > > If the pages exist with their numbers earlier enough, is there an
> object
> > or
> > > something from which lua can get the page number?
> > >
> > > I haven't found anything about page numbers in [1][1]https://pandoc.org
> /
> > > lua-filters.html#module-pandoc.utils ...am I looking in the wrong
> place?
> > Can
> > > anyone tell me anything about this?
> > >
> > > It's an intimidating rabbit hole for me, particularly because I see no
> > mention
> > > of "page number" there in the docs, which makes it seem kinda hopeless
> > > actually. But maybe one of you know the way and could point me in that
> > > direction?
> > >
> > > --
> > > 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 [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> > > To view this discussion on the web visit [2][2][2]https://
> groups.google.com/
> > d/msgid/
> > > pandoc-discuss/a93afb43-c939-40c1-868f-1db8eded17d8n%[3]
> > [3]40googlegroups.com.
> > >
> > > References:
> > >
> > > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > > [2] [4][4]https://groups.google.com/d/msgid/pandoc-discuss/
> > a93afb43-c939-40c1-868f-1db8eded17d8n%[5]40googlegroups.com?utm_medium=
> email&
> > utm_source=footer
> >
> >
> > --
> > 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 [5]pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> > To view this discussion on the web visit [6][6]https://groups.google.com/
> d/msgid/
> > pandoc-discuss/2aec84ad-a750-48f2-a0c2-ad7572dcca11n%[7]
> 40googlegroups.com.
> >
> > References:
> >
> > [1] [8]https://pandoc.org/
> > [2] [9]https://groups.google.com/d/msgid/
> > [3] [10]http://40googlegroups.com/
> > [4] [11]https://groups.google.com/d/msgid/pandoc-discuss/
> a93afb43-c939-40c1-868f-1db8eded17d8n%40googlegroups.com?utm_medium=email&
> utm_source=footer
> > [5] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > [6] [12]https://groups.google.com/d/msgid/pandoc-discuss/
> 2aec84ad-a750-48f2-a0c2-ad7572dcca11n%40googlegroups.com?utm_medium=email&
> utm_source=footer
>
>
> --
> 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 [13]pandoc-discus...@googlegroups.com.
> To view this discussion on the web visit [14]https://groups.google.com/d/msgid/
> pandoc-discuss/480d0274-2324-43d7-9f74-1bbfc08fcbd0n%40googlegroups.com.
>
> References:
>
> [1] https://pandoc.org/
> [2] https://groups.google.com/
> [3] http://40googlegroups.com/
> [4] https://groups.google.com/d/msgid/pandoc-discuss/
> [5] http://40googlegroups.com/?utm_medium=email&
> [6] https://groups.google.com/d/msgid/
> [7] http://40googlegroups.com/
> [8] https://pandoc.org/
> [9] https://groups.google.com/d/msgid/
> [10] http://40googlegroups.com/
> [11] https://groups.google.com/d/msgid/pandoc-discuss/a93afb43-c939-40c1-868f-1db8eded17d8n%40googlegroups.com?utm_medium=email&utm_source=footer
> [12] https://groups.google.com/d/msgid/pandoc-discuss/2aec84ad-a750-48f2-a0c2-ad7572dcca11n%40googlegroups.com?utm_medium=email&utm_source=footer
> [13] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [14] https://groups.google.com/d/msgid/pandoc-discuss/480d0274-2324-43d7-9f74-1bbfc08fcbd0n%40googlegroups.com?utm_medium=email&utm_source=footer

--
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/e969f1ca-c6bf-4a5e-b53f-86aa0a444db2n%40googlegroups.com.