From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31140 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sukil Etxenike arizaleta Newsgroups: gmane.text.pandoc Subject: Re: Changing LaTeX output for citations inside footnotes Date: Fri, 29 Jul 2022 11:49:09 +0200 Message-ID: <8976ce00-3fbe-bf27-898f-0470cba1fec1@gmail.com> References: <97765931b0a740ed8a84ba4337bed661@unibe.ch> <90c69f14-e16a-44d6-91ec-a6f6dca3ca45n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------wYajYukETo7gGCIsbMertMUN" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21256"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDIN5YV3SMDBBGO2R2LQMGQEQ6DT3VA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Jul 29 11:49:19 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lj1-f183.google.com ([209.85.208.183]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oHMcQ-0005LI-Ji for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 29 Jul 2022 11:49:18 +0200 Original-Received: by mail-lj1-f183.google.com with SMTP id x7-20020a05651c104700b0025e2f0ded1fsf819501ljm.23 for ; Fri, 29 Jul 2022 02:49:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1659088158; cv=pass; d=google.com; s=arc-20160816; b=MxNRHFo/yTAWR+At8AgviZi5ygS+7kSH3FWEVKUCFIJnA7gUW56+s5r+3Cb/t7WzvQ JcD6oSlYR0xf6x8X3t23bNb9bh2Yy5h57CAklB8PNncWYinGOm8U7Wjba9x9okoYEj0F 9D/QsOHXQAbuMkVLuLBECPA95rHfnKy2VV8JMc/fn9lFjO5Yosb3dWKBFiY0afSY781N 6nlBbwNHcBQ5pxnG4rsAFYYxmqZQHqdRqyo0jnwqvVrBBKnTcfO0DRpu8DhUFjw230io rue1DV00VS2trcTPKt/UOm98qh2Fu+uXjR1aJOY4XvMZcw6PhVy4viO21kHbLiKhjOtp b6BA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:sender:dkim-signature:dkim-signature; bh=o/PDoUdqIwf0wZVWgTzzbYjueTKU79mghFzylmXYIwk=; b=BxHUjizEi3ZRPUgTeDPNmkp9vxzfclc3bHfxQ89whdmV8DVBHCYzlrcrtbCg8fZFkE +IEg5nXMolwaWhCjYVwgaIauYa5u1RnKjAKebNvl8hbs2qkbv0sdfhUdglZwICbirJZq UgJ7uEoKGcoYrRmwjmLBGCd8iO2WQktPK3ZCdRWXqVtp19rR/1Kx8aSQQV9c5zPNOMbS nGcZHSoe4n/dRg5gqMePg3KgAI6LtkRNrG7EyqRkZHiXyHilb5PRMU3W4pB2L4QuP2zs ohKDZSVeEQPtO8E0Q52ufZPIui2h4SHpnDeMlfQfmn9bgAFA2bKWvRXN+Z5Hz2vXRPSj cGTA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kkM3+MX1; spf=pass (google.com: domain of sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::32f as permitted sender) smtp.mailfrom=sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:in-reply-to :from:references:to:content-language:subject:user-agent:mime-version :date:message-id:sender:from:to:cc; bh=o/PDoUdqIwf0wZVWgTzzbYjueTKU79mghFzylmXYIwk=; b=Y1rCMaFHJFSfy0XaMn9IV2GKndp7lN0FvbNRKUJn4PwLWZoESjpOrDJuxj1NFLPiBE LVE1qzZLed9QhWkh4qlTlgjPnXYrQr++ImZS3FBmG+VnVuEHGSmr7EtQMagEhVm+LrMq tOX5gd+oAJGq4myBqrDgaClSZP6pM/daTDm3MyeZdiqCQSBwbGs6ZFMAH9H588yrfOqA iDCEK5t6J0qwTZeOe5F77n/ftk33kQ4F+59vxGbfIf0ovW9tja2KqwnU2viAS7A8BK74 QO16oO3RjSz2/iJfahqWhvSMbyi66+EZVZ4OjtE9zOShRx9iKBSzhGWd9IrCSPslrYlj Fx9w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:in-reply-to :from:references:to:content-language:subject:user-agent:mime-version :date:message-id:from:to:cc; bh=o/PDoUdqIwf0wZVWgTzzbYjueTKU79mghFzylmXYIwk=; b=hHvVFHeKr/xLnNWMSwcliWbqE188ZUuz8FD7K9fIgG3AT4sO6perOwtIkNa97YY9y9 22EEJzH1BVCX0nU3uA62b4OW+QSyo60iIX8EwAprZHhxQCaKibh0T9+YfZWs9Nj4Utbr H9nk9nnKdu95Vfyc4j1z66quQjluu6SDhZy9Z3YoibtKs3WLvZBXDvSvqFg0SDo5kfOj IPQ3EUfXl42zAEtXW1U0/HIsaMrOIam+p+mrzvH4BffuGMcZiJbs2jCI8eINxZrrLils k5nAJnxZKp3htkMJHVJY61DpUG4IXJwQSSfm8FhtXoVv7wLpwT5s1RIt2OT3RKW+7DtQ xAHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:in-reply-to :from:references:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:sender:from:to:cc; bh=o/PDoUdqIwf0wZVWgTzzbYjueTKU79mghFzylmXYIwk=; b=hj0Y6aEHVqzHrTqSn3QpXNWvnpfpmK+MF9IDAYQyGyuXimQN1DLA55Dby3MCLfnvBF YkjrnNxMNQfN5L+DMCcBB58w57Fr/zEY2ZRGPbUh8IyBoK36dt4h7GYTNi7B/WqIrG+c +WYE3l8IhvH4xcJT2OJjU4ZqK9yibndpccEqv1FVht3/nc1JTRwoKgnn9Izu62qxU3UO V3XJIxZOG8mhX9XXGb4BdbLjhQv1vjek/cjsCmeo0CLl2rGE8WWslLqBK1rDQNtY7sMs NB+T7VGw9QwhaFX10plKrKi8HNwCMwXQT4z4eDHzMZfE/UPCOg5y+15yUNYM8 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora/Xha0dd2A2FKJrwP9nRqXrazN+ja2EKTZe2b47yiVsrM533lkT uCl+Zuls2YLJ2cw0s2U6LmY= X-Google-Smtp-Source: AGRyM1sUA1g5c6y8Maw5PUs73Ygph2GdX0KEn7p5kGrvny2en8WLwehESuN719+9dWoomGaV1pF2ug== X-Received: by 2002:a05:6512:3503:b0:481:4470:4134 with SMTP id h3-20020a056512350300b0048144704134mr954400lfs.42.1659088157998; Fri, 29 Jul 2022 02:49:17 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6512:3613:b0:48a:c93d:9fde with SMTP id f19-20020a056512361300b0048ac93d9fdels105940lfs.2.-pod-prod-gmail; Fri, 29 Jul 2022 02:49:12 -0700 (PDT) X-Received: by 2002:a05:6512:3dab:b0:48a:9252:bc40 with SMTP id k43-20020a0565123dab00b0048a9252bc40mr1098266lfv.394.1659088152848; Fri, 29 Jul 2022 02:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659088152; cv=none; d=google.com; s=arc-20160816; b=Dj6Ssya73mAekxkME/x+In1So8CFZU12S1Jvpss1rYjhrNhEuKJ2NGMBiKagdh+Fq3 oZEnIOFix2TSGW71yRsdYIYKm/CgJaqDJDthXSJeBmlbXFZTOYHwtyuYEUE5Dgy7RPHA qstj6wFBt2sGdHTsQMVmFErT8EEdAcNAHRgEPg3EQksT032kvGJ6J2lH3sw77e9l+41k fS9Fzok47sy+8SscVWCECPQucIsI0EhmCUPN63wkSoeFbMBrJFz2A/BMFz4+ad16W2hU PPgrivvjRK9vxA0Y2i+DuOJJ4oZ9TXQWiGCqvaMijfKUHdPQRCLZhPvVOukjqfGwS7Do /3uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=yaPjdjgJme8v0bmMw4tjUYCf3Q7HzC9OLqgsSFpz/MA=; b=Ibui0T0DqAGwUipzYuvSVMAduqeZCueWide1jXrFG+gby13D8ObVGeXv+Qs9AVpgYl tJfY/dx1m5UeWyJI1eBs4XHmxsA01KMaGPYLfZWXMNEYUGDdpTiFteE4MImoirnAqsYg 6vGdR93cYyglR2CgZmG3S+DRm7ZdYltGjT0hMmt91bfef0y+YXsjiVAMOBylxeFMekiL bmnEudIb20hHyPjwFtoS5rP3B3Nn6ORLGwDza/APajASJxb0+oimx5iViZMopeYAHVsD 5KQWtSsfSIR4EUfSOVH77M9CVaCSBWiQWNRt7+7D62dZfY4vpw+xszscn21I3JrPwmqp Ejnw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kkM3+MX1; spf=pass (google.com: domain of sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::32f as permitted sender) smtp.mailfrom=sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com. [2a00:1450:4864:20::32f]) by gmr-mx.google.com with ESMTPS id e10-20020a05651236ca00b00489d2421c05si128615lfs.4.2022.07.29.02.49.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Jul 2022 02:49:12 -0700 (PDT) Received-SPF: pass (google.com: domain of sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::32f as permitted sender) client-ip=2a00:1450:4864:20::32f; Original-Received: by mail-wm1-x32f.google.com with SMTP id n185so2270103wmn.4 for ; Fri, 29 Jul 2022 02:49:12 -0700 (PDT) X-Received: by 2002:a05:600c:3c8a:b0:3a0:4ad8:d3c4 with SMTP id bg10-20020a05600c3c8a00b003a04ad8d3c4mr2295372wmb.43.1659088151939; Fri, 29 Jul 2022 02:49:11 -0700 (PDT) Original-Received: from [192.168.1.23] (149.red-79-149-40.dynamicip.rima-tde.net. [79.149.40.149]) by smtp.gmail.com with ESMTPSA id u13-20020a05600c19cd00b003a2e1883a27sm10134745wmq.18.2022.07.29.02.49.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Jul 2022 02:49:11 -0700 (PDT) Content-Language: es-ES In-Reply-To: X-Original-Sender: Sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kkM3+MX1; spf=pass (google.com: domain of sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::32f as permitted sender) smtp.mailfrom=sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:31140 Archived-At: This is a multi-part message in MIME format. --------------wYajYukETo7gGCIsbMertMUN Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable I don't know, but the building blocks you'll need are `pandoc.stringify`=20 which takes any object and converts it into a string, and=20 `pandoc.RawBlock` or `pandoc.RawInline` which convert a string into a=20 raw block or inline, and take the format as first argument and the=20 string as second. Hth, Sukil El 29/07/2022 a las 10:58, Lyndon Drake escribi=C3=B3: > So I have the citation prefix, which I guess I have to convert to a=20 > valid LaTeX string. How can I take an Inlines and LaTeX-ify it to a=20 > string? > > On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote: > > Ah yep, that works. Next thing is I have to debug my obviously > incorrect code :-) > > On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: > > That's the problem. This is a writer, not a filter. So you > need to call it via > -t latex-footcite.lua > ________________________________________ > Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > im Auftrag von Lyndon Drake > Gesendet: Freitag, 29. Juli 2022 07:15:08 > An: pandoc-discuss > Betreff: Re: Changing LaTeX output for citations inside footnotes > > My command line is: > > pandoc -dbookends-latex --template > /Users/lyndon/.local/share/pandoc/templates/book.latex > --lua-filter=3D/Users/lyndon/.local/share/pandoc/filters/latex-fo= otcite.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=E2=80=99ve 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 > Im Auftrag von Lyndon Drake > Gesendet: Donnerstag, 28. Juli 2022 19:17 > An: pandoc-discuss > 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 =3D { > Note =3D function(el) > return el:walk { > Cite =3D function(el) > -- processing logic > print "got further" > local citation =3D "" > if #el.citations > 1 then > if citations[1].mode =3D=3D "AuthorInText" then > citation =3D '\\textcites*' > elseif citations[1].mode =3D=3D "SuppressAuthor" then > citation =3D '\\cites*' > elseif citations[1].mode =3D=3D "NormalCitation" then > citation =3D '\\cites' > end > else > if citations[1].mode =3D=3D "AuthorInText" then > citation =3D '\\textcite*' > elseif citations[1].mode =3D=3D "SuppressAuthor" then > citation =3D '\\cite*' > elseif citations[1].mode =3D=3D "NormalCitation" then > citation =3D '\\cite' > end > end > for c in el.citations do > if c.prefix ~=3D "" then > citation =3D citation .. '[' .. c.prefix .. ']' > end > if c.suffix ~=3D "" then > citation =3D citation .. '[' .. c.suffix .. ']' > end > citation =3D 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 =3D { > Note =3D function(el) > return el:walk { > Cite =3D 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=E2=80=99t think you can get the current writer in Lua. > > > Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > Im Auftrag von Lyndon Drake > Gesendet: Dienstag, 26. Juli 2022 11:00 > An: pandoc-discuss > 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 > im Auftrag von Lyndon Drake > 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 > 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 > > --=20 > 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. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4c= a9-a05d-2526b23c6f6dn%40googlegroups.com >. > > --=20 > 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-4f= e9-b44d-f288a8fef728n%40googlegroups.com >. > > --=20 > 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-44= d6-91ec-a6f6dca3ca45n%40googlegroups.com >. > > > --=20 > 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. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-44= 27-83ae-6c79ba48ed5bn%40googlegroups.com >. > > > --=20 > You received this message because you are subscribed to the Google=20 > Groups "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send=20 > an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-= 67a1764dbb70n%40googlegroups.com=20 > . --=20 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 e= mail 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/8976ce00-3fbe-bf27-898f-0470cba1fec1%40gmail.com. --------------wYajYukETo7gGCIsbMertMUN Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

I don't know, but the building blocks you'll need are `pandoc.stringify` which takes any object and converts it into a string, and `pandoc.RawBlock` or `pandoc.RawInline` which convert a string into a raw block or inline, and take the format as first argument and the string as second.

Hth,

Sukil


El 29/07/2022 a las 10:58, Lyndon Drake escribi=C3=B3:
So I have the citation prefix, which I guess I have to convert to a valid LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?

On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
Ah yep, that works. Next thing is I have to debug my obviously incorrect code :-)

On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org= wrote:
That's the problem. This is a writer, not a filter. So you need to call it via
-t latex-footcite.lua
________________________________________
Von: pandoc-...@= googlegroups.com <pandoc-...@g= ooglegroups.com> im Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Gesendet: Freitag, 29. Juli 2022 07:15:08
An: pandoc-discuss
Betreff: Re: Changing LaTeX output for citations inside footnotes

My command line is:

pandoc -dbookends-latex --template /Users/lyndon/.local/share/pandoc/templates/book.latex --lua-filter=3D/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=E2=80=99ve 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-...@= googlegroups.com <pandoc-...@g= ooglegroups.com> 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 =3D {
Note =3D function(el)
return el:walk {
Cite =3D function(el)
-- processing logic
print "got further"
local citation =3D ""
if #el.citations > 1 then
if citations[1].mode =3D=3D "AuthorInText" then
citation =3D '\\textcites*'
elseif citations[1].mode =3D=3D "SuppressAuthor" then
citation =3D '\\cites*'
elseif citations[1].mode =3D=3D "NormalCitation" then
citation =3D '\\cites'
end
else
if citations[1].mode =3D=3D "AuthorInText" then
citation =3D '\\textcite*'
elseif citations[1].mode =3D=3D "SuppressAuthor" then
citation =3D '\\cite*'
elseif citations[1].mode =3D=3D "NormalCitation" then
citation =3D '\\cite'
end
end
for c in el.citations do
if c.prefix ~=3D "" then
citation =3D citation .. '[' .. c.prefix .. ']'
end
if c.suffix ~=3D "" then
citation =3D citation .. '[' .. c.suffix .. ']'
end
citation =3D citation .. '{' .. c.id<ht= tp://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 :
ht= tps://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-page= s

Or : the new style writer
ht= tps://pandoc.org/custom-writers.html#example-modified-markdown-writer

So, something like this here could be start:

```
function Writer(doc, opts)
local filter =3D {
Note =3D function(el)
return el:walk {
Cite =3D 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=E2=80=99t think you can get the current writer in Lua.


Von: pandoc-...@= googlegroups.com <pandoc-...@g= ooglegroups.com> 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 (ht= tps://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-...@= googlegroups.com <pandoc-...@g= ooglegroups.com> 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 <ht= tps://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<= /a><mailto:pandoc-discus...@= googlegroups.com>.
To view this discussion on the web visit ht= tps://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526= b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/= pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com?utm= _medium=3Demail&utm_source=3Dfooter>.
--
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<= /a>.
To view this discussion on the web visit
ht= tps://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288= a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/= pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com?utm= _medium=3Demail&utm_source=3Dfooter>.
--
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<= /a>.
To view this discussion on the web visit
ht= tps://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6= dca3ca45n%40googlegroups.com<https://groups.google.com/d/msgid/= pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com?utm= _medium=3Demail&utm_source=3Dfooter>.

--
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<= /a><mailto:pandoc-discus...@= googlegroups.com>.
To view this discussion on the web visit ht= tps://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79= ba48ed5bn%40googlegroups.com<https://groups.google.com/d/msgid/= pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com?utm= _medium=3Demail&utm_source=3Dfooter>.
--
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-dis= cuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-d= iscuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/p= andoc-discuss/8976ce00-3fbe-bf27-898f-0470cba1fec1%40gmail.com.
--------------wYajYukETo7gGCIsbMertMUN--