From: Lyndon Drake <isenguard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Changing LaTeX output for citations inside footnotes
Date: Thu, 28 Jul 2022 22:15:08 -0700 (PDT) [thread overview]
Message-ID: <c4609f20-77f3-4427-83ae-6c79ba48ed5bn@googlegroups.com> (raw)
In-Reply-To: <b1e75d01e60647dc89b599683996c6b1-NSENcxR/0n0@public.gmane.org>
[-- Attachment #1.1: Type: text/plain, Size: 9219 bytes --]
My command line is:
pandoc -dbookends-latex --template
/Users/lyndon/.local/share/pandoc/templates/book.latex
--lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua
-s -o thesis_jeremiah_32.tex jer-32-thesis.md
It's definitely picking up the lua file because if I have a syntax error,
pandoc tells me. But I don't get any output.
On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
> How do you run this ?
>
> I’ve tested with a minimal markdown file :
>
>
>
> ```markdown
>
> asdf
>
> ```
>
>
>
> Run with :
>
> pandoc asdf.md -t mylatex.lua
>
>
>
> Result :
>
> got here
>
> asdf
>
>
>
> So, it prints the first print statement of the writer.
>
>
>
> Denis
>
>
>
> *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> *Im
> Auftrag von *Lyndon Drake
> *Gesendet:* Donnerstag, 28. Juli 2022 19:17
> *An:* pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> *Betreff:* Re: Changing LaTeX output for citations inside footnotes
>
>
>
> Thanks for this - exactly what I needed. I've added my attempt at the code
> below, but I must be missing some basic part of it because it doesn't do
> anything. I added a couple of print statements that never get executed:
>
>
>
> ```
>
> function Writer(doc, opts)
> print "got here"
> local filter = {
> Note = function(el)
> return el:walk {
> Cite = function(el)
> -- processing logic
> print "got further"
> local citation = ""
> if #el.citations > 1 then
> if citations[1].mode == "AuthorInText" then
> citation = '\\textcites*'
> elseif citations[1].mode == "SuppressAuthor" then
> citation = '\\cites*'
> elseif citations[1].mode == "NormalCitation" then
> citation = '\\cites'
> end
> else
> if citations[1].mode == "AuthorInText" then
> citation = '\\textcite*'
> elseif citations[1].mode == "SuppressAuthor" then
> citation = '\\cite*'
> elseif citations[1].mode == "NormalCitation" then
> citation = '\\cite'
> end
> end
> for c in el.citations do
> if c.prefix ~= "" then
> citation = citation .. '[' .. c.prefix .. ']'
> end
> if c.suffix ~= "" then
> citation = citation .. '[' .. c.suffix .. ']'
> end
> citation = citation .. '{' .. c.id .. '}'
> end
> return pandoc.RawInline('latex', citation)
> end
> }
> end
> }
> return pandoc.write(doc:walk(filter), 'latex', opts)
> end
>
> ```
>
>
>
> Apologies for what must be a very basic question, but what am I missing
> here?
>
> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>
> What kind of example do you need? I only know about the examples in the
> documentation.
>
>
>
> I think this here is a nice one :
>
>
> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>
>
>
> Or : the new style writer
>
> https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>
>
>
> So, something like this here could be start:
>
>
>
> ```
>
> function Writer(doc, opts)
>
> local filter = {
>
> Note = function(el)
>
> return el:walk {
>
> Cite = function(el)
>
> -- processing logic
>
> return pandoc.RawInline('latex',
> '\\cite[prenote][postnote]{key}')
>
> end
>
> }
>
> end
>
> }
>
> return pandoc.write(doc:walk(filter), 'latex', opts)
>
> end
>
> ```
>
>
>
> I don’t think you can get the current writer in Lua.
>
>
>
>
>
> *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> *Im
> Auftrag von *Lyndon Drake
> *Gesendet:* Dienstag, 26. Juli 2022 11:00
> *An:* pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> *Betreff:* Re: Changing LaTeX output for citations inside footnotes
>
>
>
> Thanks for this. I can see how that could work.
>
>
>
> Can you point me to another example that uses the walk function?
>
>
>
> Regarding a new-style Lua writer, is there a way to get the current LaTeX
> writer as Lua code? Or is it just the Haskell code? (I once knew Haskell
> but that was rather a long time ago.)
>
> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>
> I can't come up with a code example now, bit you can use the walk function
> (https://pandoc.org/lua-filters.html#type-block:walk) to modify the
> citations with a given mode inside notes. You'll need to build the citation
> via Pandoc.RawInline
> Maybe that would be a good example of a new style Lua writer.
> ________________________________________
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag
> von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Gesendet: Montag, 25. Juli 2022 21:46:28
> An: pandoc-discuss
> Betreff: Changing LaTeX output for citations inside footnotes
>
> Hi,
>
> So this is a slightly odd request, which really comes because of the
> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In
> that style, \textcite inside a footnote produces an unwanted result. \cite
> produces the expected output. I have generally just gone through and
> hand-edited my Pandoc-produced LaTeX files when they get to the final copy
> stage, but that's painful, and I also thought that maybe this is possible
> to do in a Lua filter.
>
> But I don't quite know where to start - obviously this is a bit different
> from the internal Pandoc citations. I'm going to begin the filter with
> this:
>
> if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3>
> function
>
> but what would the function be? If it is Footnote, then I don't really
> want the AST, I want the LaTeX that forms the footnote contents, and I
> suppose then I can just replace any occurrences of the string \textcite
> with the string \cite?
>
> Any help would be awesome!
>
> Best,
> Lyndon
>
> --
> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com.
[-- Attachment #1.2: Type: text/html, Size: 20566 bytes --]
next prev parent reply other threads:[~2022-07-29 5:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AQHYoF9B2NW7S0SeqEyMpv5fXcG4hq2PkarPgACoPYCAAacucIACCGuAgABXaOCAAHEpAIAAKRxZ>
[not found] ` <AQHYoF9B2NW7S0SeqEyMpv5fXcG4hq2PkarPgACoPYCAAacucIACCGuAgABXaOA=>
[not found] ` <AQHYoF9B2NW7S0SeqEyMpv5fXcG4hq2PkarPgACoPYCAAacucA==>
[not found] ` <AQHYoF9B2NW7S0SeqEyMpv5fXcG4hq2PkarP>
2022-07-25 19:46 ` Lyndon Drake
[not found] ` <bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-25 21:02 ` AW: " denis.maier-NSENcxR/0n0
[not found] ` <ea8df9c4b2d1418882909bb8a789d95f-NSENcxR/0n0@public.gmane.org>
2022-07-26 9:00 ` Lyndon Drake
[not found] ` <d25cee8b-7cb2-4fe9-b44d-f288a8fef728n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-27 10:27 ` AW: " denis.maier-NSENcxR/0n0
[not found] ` <97765931b0a740ed8a84ba4337bed661-NSENcxR/0n0@public.gmane.org>
2022-07-28 17:17 ` Lyndon Drake
[not found] ` <90c69f14-e16a-44d6-91ec-a6f6dca3ca45n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-28 20:31 ` AW: " denis.maier-NSENcxR/0n0
[not found] ` <b1e75d01e60647dc89b599683996c6b1-NSENcxR/0n0@public.gmane.org>
2022-07-29 5:15 ` Lyndon Drake [this message]
[not found] ` <c4609f20-77f3-4427-83ae-6c79ba48ed5bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-29 5:44 ` denis.maier-NSENcxR/0n0
[not found] ` <ae44d2fa18454bbf80aa666040dee1f7-NSENcxR/0n0@public.gmane.org>
2022-07-29 8:51 ` Lyndon Drake
[not found] ` <e578ff2f-aab9-45da-93ef-d8b5705b14f8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-29 8:58 ` Lyndon Drake
[not found] ` <a1e38719-d239-44af-84b0-67a1764dbb70n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-29 9:49 ` Sukil Etxenike arizaleta
[not found] ` <8976ce00-3fbe-bf27-898f-0470cba1fec1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-07-29 14:58 ` Lyndon Drake
[not found] ` <0e10379f-d1c0-4024-b98a-5c7ba703f561n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-29 18:04 ` Sukil Etxenike arizaleta
[not found] ` <83a04bea-2e09-61d2-de0d-f399beb2ef79-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-07-30 12:39 ` Lyndon Drake
[not found] ` <76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-30 13:06 ` Sukil Etxenike arizaleta
[not found] ` <7ead9a3f-3aa9-fb2e-5ad5-c069d2aee315-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-07-30 13:53 ` Lyndon Drake
[not found] ` <5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-08-01 13:48 ` BPJ
[not found] ` <CADAJKhCZYd1B8244+ZUN_DpRqEFG43zx_DQU3+OzCKHhFdYdnQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-05 11:08 ` Lyndon Drake
[not found] ` <28ac6c29-817d-41b6-891e-915ea28bdf3bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-08-05 14:36 ` BPJ
[not found] ` <CADAJKhBDo-Ya3Wabo27CQd=t6JGtkzmYOoqbcCW2tkK=GKd7FA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-05 20:43 ` Sukil Etxenike arizaleta
[not found] ` <1485f3b9-f893-c00d-6546-904732bf64ae-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-08-05 20:47 ` Sukil Etxenike arizaleta
[not found] ` <67cbd620-a60e-2518-24fd-e618ece65d5c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-08-06 10:56 ` Lyndon Drake
[not found] ` <7404c6ef-789f-4fec-bf16-be469839b935n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-09-14 20:14 ` AW: " denis.maier-NSENcxR/0n0
[not found] ` <c72e9e361aa946dd83f2fc8cc9cb1f85-NSENcxR/0n0@public.gmane.org>
2022-09-15 18:53 ` Lyndon Drake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c4609f20-77f3-4427-83ae-6c79ba48ed5bn@googlegroups.com \
--to=isenguard-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).