From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31180 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, 5 Aug 2022 22:43:09 +0200 Message-ID: <1485f3b9-f893-c00d-6546-904732bf64ae@gmail.com> References: <97765931b0a740ed8a84ba4337bed661@unibe.ch> <90c69f14-e16a-44d6-91ec-a6f6dca3ca45n@googlegroups.com> <8976ce00-3fbe-bf27-898f-0470cba1fec1@gmail.com> <0e10379f-d1c0-4024-b98a-5c7ba703f561n@googlegroups.com> <83a04bea-2e09-61d2-de0d-f399beb2ef79@gmail.com> <76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n@googlegroups.com> <7ead9a3f-3aa9-fb2e-5ad5-c069d2aee315@gmail.com> <5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n@googlegroups.com> <28ac6c29-817d-41b6-891e-915ea28bdf3bn@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------Advikji45YQRJ4Z10QRPhIcf" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7801"; 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.1.0 To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDIN5YV3SMDBBYMBW2LQMGQE3GWGC2Y-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Aug 05 22:43:18 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f59.google.com ([209.85.128.59]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oK4A9-0001ow-3K for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 05 Aug 2022 22:43:17 +0200 Original-Received: by mail-wm1-f59.google.com with SMTP id v130-20020a1cac88000000b003a4f057ed9fsf1689178wme.7 for ; Fri, 05 Aug 2022 13:43:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1659732196; cv=pass; d=google.com; s=arc-20160816; b=ZFtH5M+2PibNmOGyY8XWNJdUEXvCh/v0hqCUue5B/WNd9qUZAUY0DEOWyNGZlUWPEk LOe4t1gMbBiJ0GOw2vYw8xhlrapO7MB003aUKsHBj5Dcpa0SsnyWQP/S2NJ19DLvwUz5 rCOB75HvJq2sKBREps6jQBrB139LSpGP2KqXCbafGG1Wb+HgJtnWT5Z6QKfaNdF6DVvk MJjFtm20DXLC5nTF0qAYmHImG2U9GR2vBzXTWddtd4y4Trl+BTC+Bg9b7SH55N9o03lg oXg+6koNUfCSVWI+ApI7ilOfom11YOZlZY005eT9cBqlXJ32A6bFEyUZkfo2UjfCTPxD sA1A== 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 :content-language:references:to:subject:user-agent:mime-version:date :message-id:sender:dkim-signature:dkim-signature; bh=VFeOmIDyUw1S0sqr5JZPr5g9AuWLzl65VGge9cjsCaM=; b=QxfWFNKyCLu/CMQZNUhnvA4S9cfcztq+NAwZ42H0xU9Lj6UopU8nfG0GHfcNVysWfX GSa7j5mmexqrOeHme5lBRN2GhncC/mpXVCs8TByAX+4d5O7Z/euqU8wxFAP6D+4eyslN mFRNQqr78/GntNN+tUnh46owuQ/YWcQmbhVmMbiFejDzdQI9tYi6+V4uP8Ek/YabcJt/ jvoaJQjpECUa+91IfyM9XA3yA9a93l0wUf61K2Y3rYY2MeWY978AOLN1LZSj3cv94j+A eCKDuCh3nJ0nmw1NiR4VdAVH5Os5+YV3wLJqPaT3Kxv1GRARmWh9UH1uVwKilwoyumxH iUTw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bvYxo39K; spf=pass (google.com: domain of sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::42f 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:content-language:references:to:subject:user-agent:mime-version :date:message-id:sender:from:to:cc; bh=VFeOmIDyUw1S0sqr5JZPr5g9AuWLzl65VGge9cjsCaM=; b=MSTmoLX0rlvcmgyFx9z7MDSpzZBpYkbcZ8KWT3qPMfZOXzDcxWOEto3mQfWi0uO5gI +w4KMKfHEugcDnglCIJbRDNspb8xnSK4sz9sVDMcBf49uQT7kz1+YZikddwTsD9Q/laM 5o/8UpMHbu493KFgzAneJTObDhBFrP1Yh7nruPhvTWjmaCw8e+WY6ehEstnNgdn9Rxe6 hjkyMCcnspDBzq+F+SLZjhLC2HQ5EOtQCyEDZyw4ObCfLMBMJMH6C6d/wJo0/6R6xsoj zgLdcxaZ6vhlpFGIjcjGzKqlvApRIGRK6oKJi1qPjk0bdLbpvju9oxwdGSN4thwxeGCy Li7Q== 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:content-language:references:to:subject:user-agent:mime-version :date:message-id:from:to:cc; bh=VFeOmIDyUw1S0sqr5JZPr5g9AuWLzl65VGge9cjsCaM=; b=CRiD0qpQ7GUkEvXSN+0o8rIzEac4g/j17JBPqe8f3wqrvd/xIYiupVoDswdGuZEEY9 uwomOazTqmSgAcHmwS+u2A7X9Xs90lfB31mhtcTESqtvS9JuQ9NEPVWEtIPX4vzfq5ET 1RNJVfXMUpkpVsrG4pr0LsFQQDGWlpOGR6OgwJvbs7ZYPp2MVVTMTEcp2Fbp9odIyeYJ H1rDJ6O9IzkChkOz+lr+4pbi4GwtSbXyCdmNHEBTkKoXYVuCR6HVLym+GaCqNqrxvIjL 5sNpGtI7vMWNsBu171SN6JUYR+ODsU7ujL1d4Ps5ixRoMUiMnuslCGIsH7zU85GnNjG3 9Cpg== 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:content-language:references:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:sender:from:to:cc; bh=VFeOmIDyUw1S0sqr5JZPr5g9AuWLzl65VGge9cjsCaM=; b=zR+cTf1OtytL//1jzyAg1bL00nAlVQvlIvfJmLGD1pyE+TOo6MoSVrCfszzZpwI53f vpuYWqsUo2DH+9gmaQboE4HioX+Ycfd9sM5fsWL+LeZNLcYdk12Zixtu9dcwG8gMDDys pLQV6AoBcaXE7TynY9Ty/waa1pvKLIX+Zl8gocruk3wFKNbAD4xD+LifBr4OC6nAqrmx p6fqf1E5qVjZnRQJYMGDrLEoxi7/+cULQdUwQeIuzmrNnV4bFS8bhfJveoSnydXR2WXI Sg9UjgOc5ADLS1Ihgz1krFxLaZlSuIlIgM8qnbUx4nz3pTuVbDlqM7moNteka Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ACgBeo2p46rs2vG/W0psy7ye9l5krLOrHxb2GGvZs07xgO7xKkoA/NGS 8XfeOZK+5KcSbJhGl9ELwf0= X-Google-Smtp-Source: AA6agR4LRrso6uJHQCIcwoL2LiMaAGjKFn9sp3+HV6m1WQsdgtSyaFvp/eFmCV1O3eZgw7kj7IEqqA== X-Received: by 2002:a5d:4b89:0:b0:220:732b:2ddd with SMTP id b9-20020a5d4b89000000b00220732b2dddmr5292278wrt.588.1659732196518; Fri, 05 Aug 2022 13:43:16 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:adf:d236:0:b0:21e:e644:c8 with SMTP id k22-20020adfd236000000b0021ee64400c8ls127164wrh.3.-pod-prod-gmail; Fri, 05 Aug 2022 13:43:12 -0700 (PDT) X-Received: by 2002:a5d:6b10:0:b0:21e:4bbd:e893 with SMTP id v16-20020a5d6b10000000b0021e4bbde893mr5321242wrw.613.1659732192419; Fri, 05 Aug 2022 13:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659732192; cv=none; d=google.com; s=arc-20160816; b=bHOkIyNH8Ulw7cN7xOVwi8zhzBxVCJllmafRpVKo8glQWdNF1FlGz+BPxBtGUPMDAm WqtxmFFg5j74cPSPPRGTzehX6VW+TmC7cxLU0W/WjX19JiVDu+1kO0A9Q23Ok5L1p/Oz 1hD0hyE3ZNZKaWhYqPuJo2iVPC4dhhEjLPX84sXvZle8Tux2k0qbIKxiqb34VQG3ii9v WCfWum3LFUR+/ceuKkWMeNxzYkzjAmYHpUoPu0hv3Ibs2TmopgLc5YXxAbplRfhKYQzp 5Msx2oU1efBPmk2taIa7hRBxeSFD+7iG5kpdzkSbrArMJjzpRkbNsHpIX6Io1rsSyw6r xNZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=v2qD9202FfBVMs2kwsdhjANsvCXR2ZE5TTfzQU2y9lQ=; b=Jyx1cXPjXygOYZliYG3SLVnBgK7eTQxk8p0vdlHoKw5oXheMoEiWkYaNzMpsq31AHv x2vL+rsSx63dCosTFphRd06LiCZ849WsrVvlbDe3uaiAfvvHa+crk/Y20jj+5d8rF6IB SfOM7JJHKAkUewt6o92+5FE9bCBfDjtg292b66JPRD1JIiJ2ucfuFs7ijZelHyNPmCIw 2P9YSKb0HPtVi4YmDfLBcthQnN5O0FtM2PEVW5fUYlJr8lATTXG8yrHjjbaiZDdz6xAb 8Wp0tU/yQYRNTCC5hq7lQWgZaY7kUL2IrooU9dd6A4GkQsl4AwRljXNqJYqn4hh8BSzF xxDA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bvYxo39K; spf=pass (google.com: domain of sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::42f 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-wr1-x42f.google.com (mail-wr1-x42f.google.com. [2a00:1450:4864:20::42f]) by gmr-mx.google.com with ESMTPS id 189-20020a1c19c6000000b003a31bb11cdfsi477089wmz.2.2022.08.05.13.43.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Aug 2022 13:43:12 -0700 (PDT) Received-SPF: pass (google.com: domain of sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::42f as permitted sender) client-ip=2a00:1450:4864:20::42f; Original-Received: by mail-wr1-x42f.google.com with SMTP id bv3so4445916wrb.5 for ; Fri, 05 Aug 2022 13:43:12 -0700 (PDT) X-Received: by 2002:adf:dc87:0:b0:21e:ecad:a6bc with SMTP id r7-20020adfdc87000000b0021eecada6bcmr5156981wrj.218.1659732191713; Fri, 05 Aug 2022 13:43:11 -0700 (PDT) Original-Received: from [192.168.1.23] (157.red-79-149-225.dynamicip.rima-tde.net. [79.149.225.157]) by smtp.gmail.com with ESMTPSA id 6-20020a1c1906000000b003a511e92abcsm5931818wmz.34.2022.08.05.13.43.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Aug 2022 13:43: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=bvYxo39K; spf=pass (google.com: domain of sukiletxe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::42f 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:31180 Archived-At: This is a multi-part message in MIME format. --------------Advikji45YQRJ4Z10QRPhIcf Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable I think `doc`'s fields and methods aren't documented, that's why I=20 didn't think of that. Good call! El 05/08/2022 a las 16:36, BPJ escribi=C3=B3: > But doc.blocks, which is the actual content of the doc, is a list of=20 > blocks, which you can pass to blocks_to_inlines. Don't forget to pass=20 > `{pandoc.Space()}` as the second argument! > > Den fre 5 aug. 2022 13:08Lyndon Drake skrev: > > Not really, because the issue is that Pandoc returns a doc, not a > list of blocks. So blocks_to_inlines doesn't actually work. But > the gsub trick works well enough to get around the issue, thankfully. > > On Monday, 1 August 2022 at 14:48:59 UTC+1 BP wrote: > > Can you convert the blocks to inlines with blocks_to_inlines? > > https://pandoc.org/lua-filters.html#pandoc.utils.blocks_to_inline= s > > Den l=C3=B6r 30 juli 2022 15:54Lyndon Drake s= krev: > > Nice, the :gsub does the trick (once I replaced \n* with > \n+). > > Thanks again, really appreciate the help with all this. > Hopefully I can start to build some more Lua > filters/writers now. It's a great system (thanks John > MacFarlane!). > > On Saturday, 30 July 2022 at 14:06:10 UTC+1 > suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > I believe you can't create a pandoc document without > any block. Two possibilities come to mind: > > 1. Round tripping: After fixing the citation, read it > as LaTeX, and maybe, run > pandoc.utils.blocks_to_inlines. (Hey, I never said it > wouldn't be messy). May not work, even. > > 2. Simply delete all paragraph markers: in your case > with: citetext:gsub("\n*", " ") > > Hth, > > Sukil > > > > El 30/07/2022 a las 14:39, Lyndon Drake escribi=C3=B3: > >> Hi Sukil, >> >> Thanks, you were quite correct about the second >> problem. I've amended that and it now works, at least >> in the sense that it is altering the output in the >> general way I want. >> >> On the first problem, I can just pandoc.stringify the >> prefix and suffix, and concatenate. The problem with >> that is I will then lose any Markdown formatting, >> which is not entirely uncommon in a prefix, and even >> occasionally in a suffix. I can work around it for >> this document, I guess, by just being careful not to >> use any Markdown formatting in these instances, but >> I'd love to find a way to take a set of Inlines and >> convert it to a format without adding a block. >> >> On Friday, 29 July 2022 at 19:04:51 UTC+1 >> suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: >> >> Hi, >> >> For your first problem, when you do pandoc.write, >> as a minimum a block is created, which, I >> believe, is normally a paragraph. So, don't call >> pandoc.write. I guess you can concatenate the >> prefix, citation and suffix and pass them to the >> pandoc.RawInline function. >> >> >> For your second problem, I am guessing you are >> using --citeproc in your defaults file. If that >> is the case, try: 1) putting the defaults file >> after the filter; or 2) specifying --citeproc >> manually, also after the filter. >> >> Hth, >> >> Sukil >> >> >> El 29/07/2022 a las 16:58, Lyndon Drake escribi=C3= =B3: >>> Thanks for all the help - definitely getting >>> somewhere now! >>> >>> I guess what I want to avoid is replicating in >>> my not-great-Lua code all the work Pandoc >>> already has to take a string of Markdown and >>> convert it to LaTeX. I'm using pandoc.write to >>> attempt that, and it seems to be working to some >>> degree. The code as it is now is below. I have >>> two problems: >>> >>> 1. This Markdown input [@Haran1982 165 n. 9, >>> 172] gets converted by my calling of >>> pandoc.write into: >>> >>> ``` >>> \cite[165 >>> >>> n.~9, >>> >>> 172]{Haran1982} >>> ``` >>> >>> and I can't figure out why the blank lines are >>> turning up. I imagine I need to do something >>> more clever with the Inlines? >>> >>> >>> 2. Despite the fact that my output in the >>> terminal shows that I am constructing the >>> citetext variable as I am intending to, and I >>> have this line of code: >>> >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 return >>> pandoc.RawInline('latex', citetext) >>> >>> The output .tex file still has the normal Pandoc >>> citations. In other words, my writer is >>> constructing a nice LaTeX string with what I >>> want in it, and then discards it in favour of >>> the normal Pandoc code, which is a little bit >>> depressing. >>> >>> Can anyone spot what I'm missing now? >>> >>> Best, >>> Lyndon >>> >>> ``` >>> function Writer(doc, opts) >>> =C2=A0 =C2=A0 local filter =3D { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Note =3D function(el) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return el= :walk { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Cite =3D function(el) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 -- processing logic >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 local citetext =3D "" >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 if #el.citations > 1 then >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if el.citations[1].mode >>> =3D=3D "AuthorInText" then >>> citetext =3D '\\textcites*' >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elseif >>> el.citations[1].mode =3D=3D "SuppressAuthor" then >>> citetext =3D '\\cites*' >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elseif >>> el.citations[1].mode =3D=3D "NormalCitation" then >>> citetext =3D '\\cites' >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 else >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if el.citations[1].mode >>> =3D=3D "AuthorInText" then >>> citetext =3D '\\textcite*' >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elseif >>> el.citations[1].mode =3D=3D "SuppressAuthor" then >>> citetext =3D '\\cite*' >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elseif >>> el.citations[1].mode =3D=3D "NormalCitation" then >>> citetext =3D '\\cite' >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 end >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 for _, c in >>> pairs(el.citations) do >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if #c.prefix > 0 then >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local doc =3D >>> pandoc.Pandoc(c.prefix) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local citeprefix =3D >>> pandoc.write(doc, 'latex') >>> citetext =3D citetext .. '[' .. citeprefix .. ']' >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if #c.suffix > 0 then >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local doc =3D >>> pandoc.Pandoc(c.suffix) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local citesuffix =3D >>> pandoc.write(doc, 'latex') >>> citetext =3D citetext .. '[' .. citesuffix .. ']' >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D citetext .. >>> '{' .. c.id .. '}' >>> print(citetext) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 end >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 return >>> pandoc.RawInline('latex', citetext) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 end >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 end >>> =C2=A0 =C2=A0 } >>> =C2=A0 =C2=A0 return pandoc.write(doc:walk(filter), >>> 'latex', opts) >>> end >>> ``` >>> >>> On Friday, 29 July 2022 at 10:49:18 UTC+1 >>> suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: >>> >>> 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-...-/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/temp= lates/book.latex >>>> --lua-filter=3D/Users/lyndon/.local/sh= are/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 mar= kdown >>>> 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#mo= difying-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#t= ype-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/pand= oc-discuss/bc06a6d8-9a34-4ca9-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/pand= oc-discuss/d25cee8b-7cb2-4fe9-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/pand= oc-discuss/90c69f14-e16a-44d6-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/pand= oc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%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-discu= ss/a1e38719-d239-44af-84b0-67a1764dbb70n%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/0e= 10379f-d1c0-4024-b98a-5c7ba703f561n%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/76a7fa0= b-752b-496e-98a3-cc6ee8ef68b0n%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/5d1a1315-d0d= f-4e28-b13b-8eb8e8d7f9c7n%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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-8= 91e-915ea28bdf3bn%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/CADAJKhBDo-Ya3Wabo27CQd%= 3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%40mail.gmail.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/1485f3b9-f893-c00d-6546-904732bf64ae%40gmail.com. --------------Advikji45YQRJ4Z10QRPhIcf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

I think `doc`'s fields and methods aren't documented, that's why I didn't think of that. Good call!


El 05/08/2022 a las 16:36, BPJ escribi=C3=B3:
But doc.blocks, which is the actual content of the doc, is a list of blocks, which you can pass to blocks_to_inlines. Don't forget to pass `{pandoc.Space()}` as the second argument!

Den fre 5 aug. 2022 13:08Lyndon Drake <isengu= ard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
Not really, because the issue is that Pandoc returns a doc, not a list of blocks. So blocks_to_inlines doesn't actually work. But the gsub trick works well enough to get around the issue, thankfully.

On Monday, 1 August 2022 at 14:48:59 UTC+1 BP wrote:
Can you convert the blocks to inlines with blocks_to_inlines?


Den l=C3=B6r 30 juli = 2022 15:54Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
Nice, the :gsub does the trick (once I replaced \n* with \n+).

Thanks again, really appreciate the help with all this. Hopefully I can start to build some more Lua filters/writers now. It's a great system (thanks John MacFarlane!).

On Saturday, 30 July 2022 at 14:06:10 UTC+1 suki.= ..@gmail.com wrote:

I believe you can't create a pandoc document without any block. Two possibilities come to mind:

1. Round tripping: After fixing the citation, read it as LaTeX, and maybe, run pandoc.utils.blocks_to_inlines. (Hey, I never said it wouldn't be messy). May not work, even.

2. Simply delete all paragraph markers: in your case with: citetext:gsub("\n*", " ")

Hth,

Sukil



El 30/07/2022 a las 14:39, Lyndon Drake escribi=C3=B3:

Hi Sukil,

Thanks, you were quite correct about the second problem. I've amended that and it now works, at least in the sense that it is altering the output in the general way I want.

On the first problem, I can just pandoc.stringify the prefix and suffix, and concatenate. The problem with that is I will then lose any Markdown formatting, which is not entirely uncommon in a prefix, and even occasionally in a suffix. I can work around it for this document, I guess, by just being careful not to use any Markdown formatting in these instances, but I'd love to find a way to take a set of Inlines and convert it to a format without adding a block.

On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<= /a> wrote:

Hi,

For your first problem, when you do pandoc.write, as a minimum a block is created, which, I believe, is normally a paragraph. So, don't call pandoc.write. I guess you can concatenate the prefix, citation and suffix and pass them to the pandoc.RawInline function.


For your second problem, I am guessing you are using --citeproc in your defaults file. If that is the case, try: 1) putting the defaults file after the filter; or 2) specifying --citeproc manually, also after the filter.

Hth,

Sukil


El 29/07/2022 a las 16:58, Lyndon Drake escribi=C3=B3:
Thanks for all the help - definitely getting somewhere now!

I guess what I want to avoid is replicating in my not-great-Lua code all the work Pandoc already has to take a string of Markdown and convert it to LaTeX. I'm using pandoc.write to attempt that, and it seems to be working to some degree. The code as it is now is below. I have two problems:

1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my calling of pandoc.write into:

```
\cite[165

n.~9,

172]{Haran1982}
```

and I can't figure out why the blank lines are turning up. I imagine I need to do something more clever with the Inlines?


2. Despite the fact that my output in the terminal shows that I am constructing the citetext variable as I am intending to, and I have this line of code:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return pandoc.RawInline('latex', citetext)

The output .tex file still has the normal Pandoc citations. In other words, my writer is constructing a nice LaTeX string with what I want in it, and then discards it in favour of the normal Pandoc code, which is a little bit depressing.

Can anyone spot what I'm missing now?

Best,
Lyndon

```
function Writer(doc, opts)
=C2=A0 =C2=A0 local filter =3D {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Note =3D = function(el)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 return el:walk {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 Cite =3D function(el)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -- processing logic
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local citetext =3D ""
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if #el.citations > 1 then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if el.citations[1].mode =3D=3D "AuthorInText" then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D '\\textcites*'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elseif el.citations[1].mode =3D=3D "SuppressAuthor" then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D '\\cites*'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elseif el.citations[1].mode =3D=3D "NormalCitation" then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D '\\cites'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if el.citations[1].mode =3D=3D "AuthorInText" then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D '\\textcite*'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elseif el.citations[1].mode =3D=3D "SuppressAuthor" then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D '\\cite*'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elseif el.citations[1].mode =3D=3D "NormalCitation" then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D '\\cite'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for _, c in pairs(el.citations) do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if #c.prefix > 0 then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local doc =3D pandoc.Pandoc(c.prefix)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local citeprefix =3D pandoc.write(doc, 'latex')
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D citetext .. '[' .. citeprefix .. ']'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if #c.suffix > 0 then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local doc =3D pandoc.Pandoc(c.suffix)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local citesuffix =3D pandoc.write(doc, 'latex')
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D citetext .. '[' .. citesuffix .. ']'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 citetext =3D citetext .. '{' ..
c.id .. '}'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print(citetext)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return pandoc.RawInline('latex', citetext)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 }
=C2=A0 =C2=A0 return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

= On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...@gm= ail.com wrote:

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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 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/shar= e/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-...-/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 =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" the= n
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" the= n
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<http://c.id> .. '}'
end
return pandoc.RawInline('latex', citation)
end
}
end
}
return pandoc.write(doc:walk(fil= ter), '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#modifyi= ng-pandocs-manual.txt-for-man-pages

Or : the new style writer
https://pandoc.org/custom-writers.html#exam= ple-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(fil= ter), 'latex', opts)
end
```

I don=E2=80=99t 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-bl= ock: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-di= scuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%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.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-di= scuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%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.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-di= scuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%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<mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-di= scuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%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= -discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
--
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 pa= ndoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
--
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...@googl= egroups.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-di= scus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
--
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@goog= legroups.com.
To view this discussion on the web visit h= ttps://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915= ea28bdf3bn%40googlegroups.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-dis= cuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-d= iscuss/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%40mail.gmail= .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/1485f3b9-f893-c00d-6546-904732bf64ae%40gmail.com.
--------------Advikji45YQRJ4Z10QRPhIcf--