From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32976 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christophe Demko Newsgroups: gmane.text.pandoc Subject: Re: Converting reference footnotes to inline footnotes (md -> md if poss.) Date: Wed, 19 Jul 2023 11:43:54 -0700 (PDT) Message-ID: <7d7d33f9-dc97-4b3e-b3f0-efcaac2bd324n@googlegroups.com> References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_15000_1367193060.1689792234850" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21824"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDN5TJEC4AEBB3G54CSQMGQEORKNZ2Q-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jul 19 20:44:03 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f59.google.com ([209.85.161.59]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qMC9Y-0005Oz-GF for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 19 Jul 2023 20:44:00 +0200 Original-Received: by mail-oo1-f59.google.com with SMTP id 006d021491bc7-5662c34e5cdsf68570eaf.0 for ; Wed, 19 Jul 2023 11:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1689792239; x=1690397039; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=gdOxh8Zz4v53lRv5N2Q2eejBkiQumKl6vu76z3Ahmno=; b=l7SVeIOuV3HN8xachgYlmJ2+9Z9QjLmijH2+6vhJc0aprGj6LtghKqo7G2yNqSpp6j rL9zeay+rKNcSM0hwBFBg75wsTn6VY2AD4CPjnw2umR9BqJuFB/QgmGY+e24cyIWtfu4 VcSe6mKgjLYYCSy0NvWWGteXZI+dAtDRypYEhHYTMeC9dV73TsM0/nqEtct+SS+aa4qj 3ORHuXcEnGpT/hI5ebnlJOKECEZA0hQVTDgw5yh3N0g2OD/us8/Xpzyasy32reRQ+0Ef auYet2k7erhFcKBPc99v4ge3Vij+nGDWWPPqILVwtDGasuL9Xym/VSF46VWWReLqvOkI NY7Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689792239; x=1690397039; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=gdOxh8Zz4v53lRv5N2Q2eejBkiQumKl6vu76z3Ahmno=; b=N4YxdgWrTj5GQnhDLEKlHH48Ezn5XjvRhOE0O/YadnwueqB7BmvQfdXDYeotBymfLv 9nkqNWRXzBTG2963R0noF1dMhEcP9M/WNYtyHhm8lKQ9txj5LQyZ+t8DBFGC+vRDkCY2 wSAuS+jFNtmW7vj6lgfsgNytWf60n46x/a4Q+uoeTEhKif+mCfDct2WPAQ54a3jm09oW Gycj4E6s1RG4ichBhV+l5cg6utbLz90WkQdMfIKVZBFvIMZhIV5r3GRLpgDG+wOuz4Qx GqGPmBhIvVD1KFuhDUKVLCUdSNkJdXjSxbT6j6JfBJBY63gu3eq+UoP3tGeKSRwi3L9W rYuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689792239; x=1690397039; 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-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=gdOxh8Zz4v53lRv5N2Q2eejBkiQumKl6vu76z3Ahmno=; b=jCrKc6O2Dk1Er1VkmJBFDom/0J47/O7kzZIIg854I3JuNsEC+16F6NGL963boY1fvg KHvdU6U0MHjLBd/Lqe0OVMgaBwt9rr9BpCy1uBj1npUEluWxx9Q//3K5DdPbioUlyq2N o3VKHWjaLMwE7XzVd/8VoU1/f7wyrMioYTb/cNIiAgSskbJzkEhp2JvtF8I6H+Hn3sWw fYs8HpvqKFBkJDHvPfKAg2jJYzurQDD5EpZ27d2F1dpA4I+d7RVrjnqHhKNl+aG968vC 31mQY/4KWvFGHh+xnuqA1y6zJGdwf5duzwGQhmZvRatjWFQB60 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ABy/qLZnN1O7U+AqqYWpJaPH3sAR22hr2FA5rpfsEYJgMDwwA1c5pj1i 8MaHe+rUYqf/ZWIdinkWiqU= X-Google-Smtp-Source: APBJJlGWfwsiz8JKwC4Ko6RsjrQBmQiIlYPrENc2UdCyvwGnk352tmcgqbyKVYJGZrGELouuqaUNLg== X-Received: by 2002:a4a:2c90:0:b0:564:e465:5d5c with SMTP id o138-20020a4a2c90000000b00564e4655d5cmr470605ooo.2.1689792239134; Wed, 19 Jul 2023 11:43:59 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a4a:4b01:0:b0:566:a929:67e7 with SMTP id q1-20020a4a4b01000000b00566a92967e7ls4089652ooa.2.-pod-prod-09-us; Wed, 19 Jul 2023 11:43:55 -0700 (PDT) X-Received: by 2002:a05:6808:2219:b0:3a4:87eb:da2c with SMTP id bd25-20020a056808221900b003a487ebda2cmr2624369oib.0.1689792235468; Wed, 19 Jul 2023 11:43:55 -0700 (PDT) In-Reply-To: X-Original-Sender: chdemko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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:32976 Archived-At: ------=_Part_15000_1367193060.1689792234850 Content-Type: multipart/alternative; boundary="----=_Part_15001_1170656731.1689792234850" ------=_Part_15001_1170656731.1689792234850 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable May be you have some complex content in your footnotes. Try this note.lua file: function Note(note) if #note.content =3D=3D 1 then table.insert(note.content[1].content, 1, pandoc.Str "%%opening%%") table.insert(note.content[1].content, pandoc.Str "%%closing%%") return note.content[1].content end return note end Le mercredi 19 juillet 2023 =C3=A0 19:59:23 UTC+2, Christophe Demko a =C3= =A9crit : > Can you post the files which cause an issue ? > > Le mercredi 19 juillet 2023 =C3=A0 18:44:09 UTC+2, 'o-Dzin Tridral a =C3= =A9crit : > >> Hi Christophe, >> >> I'm sorry to follow up again, but I get an error with my large md file >> >> The filter fails with the error >> >> attempt to concatenate a nil value (field 'text') >> >> The error doesn't mention where the failure happens or what text is=20 >> causing the problem. If you have any advice re how to get more informat= ion=20 >> from pandoc or lua I would very much appreciate it.=20 >> >> I entirely understand if you don't have time to look at this of course. >> >> best regards, >> >> '=C3=B6-Dzin >> >> =20 >> >> >> =E0=BD=A0=E0=BD=BC=E0=BD=91=E0=BC=8B=E0=BD=A0=E0=BD=9B=E0=BD=B2=E0=BD=93= =E0=BC=8B=E0=BD=91=E0=BE=B2=E0=BD=B2=E0=BC=8B=E0=BD=96=E0=BE=B2=E0=BD=A3 >> '=C3=B6-Dzin Tridral >> [image: https://]about.me/tridral >> >> >> =E2=98=B8=20 >> *Drala Jong Appeal - creating a Buddhist retreat centre in Wales:=20 >> https://www.drala-jong.org/ *=E2=98=B8 >> >> =E2=98=B8 Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan -= fydd=20 >> gen ti ddim esgus - Meinir Gwilym =E2=98=B8 >> >> >> On Wed, 19 Jul 2023 at 17:19, 'o-Dzin Tridral wrote: >> >>> Hi Christophe, >>> >>> Thank you very much for your reply. >>> >>> I've not used lua filters before. It took me a while to realise how to= =20 >>> make a command line with the input file and output file. >>> >>> I thought I'd write back and include tis for the benefit of any novices= =20 >>> like me. >>> >>> I've now done this with your script, inserting the* '-i' *for the input= =20 >>> file and using output redirection '*>' *for the output file >>> >>> pandoc --lua-filter note.lua -t markdown -i ** | sed -e= =20 >>> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g' > ** >>> >>> This works on my small example file. >>> >>> Thank you once again. >>> >>> '=C3=B6-Dzin >>> >>> =20 >>> >>> >>> =E0=BD=A0=E0=BD=BC=E0=BD=91=E0=BC=8B=E0=BD=A0=E0=BD=9B=E0=BD=B2=E0=BD= =93=E0=BC=8B=E0=BD=91=E0=BE=B2=E0=BD=B2=E0=BC=8B=E0=BD=96=E0=BE=B2=E0=BD=A3 >>> '=C3=B6-Dzin Tridral >>> [image: https://]about.me/tridral >>> >>> >>> =E2=98=B8=20 >>> *Drala Jong Appeal - creating a Buddhist retreat centre in Wales:=20 >>> https://www.drala-jong.org/ *=E2=98=B8 >>> >>> =E2=98=B8 Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan = - fydd=20 >>> gen ti ddim esgus - Meinir Gwilym =E2=98=B8 >>> >>> >>> On Wed, 19 Jul 2023 at 14:36, Christophe Demko wrote= : >>> >>>> You can use a lua filter: >>>> >>>> $ pandoc --lua-filter note.lua -t markdown | sed -e=20 >>>> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g' >>>> >>>> with this note.lua file >>>> >>>> function Note(note) >>>> note.content[1].content[1].text =3D "%%opening%%" ..=20 >>>> note.content[1].content[1].text >>>> note.content[1].content[#note.content[1].content].text =3D=20 >>>> note.content[1].content[#note.content[1].content].text .. "%%closing%%= " >>>> return note.content[1].content >>>> end >>>> Le dimanche 16 juillet 2023 =C3=A0 17:35:38 UTC+2, tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a= =20 >>>> =C3=A9crit : >>>> >>>>> Is it possible to use Pandoc to convert an md file that has reference= =20 >>>>> footnotes to one that has inline footnotes - just by going from md ->= md,=20 >>>>> but failing that via another format. >>>>> >>>>> I have a file containing reference footnotes like this >>>>> ---- >>>>> Example[^1] line of text. >>>>> >>>>> [^1]: Example footnote >>>>> ---- >>>>> >>>>> I would like to convert them all to inline footnotes like this >>>>> >>>>> ---- >>>>> Example^[Example footnote] line of text. >>>>> ---- >>>>> >>>>> Thank you for any help >>>>> >>>>> '=C3=B6-Dzin >>>>> >>>> --=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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To view this discussion on the web visit=20 >>>> https://groups.google.com/d/msgid/pandoc-discuss/dabd9a50-de23-47d9-97= 1e-cfc8d1b92e0dn%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/7d7d33f9-dc97-4b3e-b3f0-efcaac2bd324n%40googlegroups.com. ------=_Part_15001_1170656731.1689792234850 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
May be you have some complex content in your footnotes.
Try = this note.lua file:

function Note(note)
=C2= =A0 if #note.content =3D=3D 1 then
=C2=A0 =C2=A0 table.insert(note.con= tent[1].content, 1, pandoc.Str "%%opening%%")
=C2=A0 =C2=A0 table.inse= rt(note.content[1].content, pandoc.Str "%%closing%%")
=C2=A0 =C2=A0 re= turn note.content[1].content
=C2=A0 end
=C2=A0 return note
e= nd

Le mercredi 19 juillet 2023 =C3=A0 19:59:23 UTC+2, Christophe De= mko a =C3=A9crit=C2=A0:
Can you post the files which cause an issue ?

Le mercredi 19 jui= llet 2023 =C3=A0 18:44:09 UTC+2, 'o-Dzin Tridral a =C3=A9crit=C2=A0:
Hi Christophe,

I'm sorry to follow up again, but I get an error with my larg= e md file

The filter= fails with the error

=C2=A0 attempt to concatenate a nil value (= field 'text')

The error doesn't mention= where the failure happens or what text is causing the problem.=C2=A0 If yo= u have any advice re how to get more information from pandoc or lua I would= very much appreciate it.

I entirely und= erstand if you don't have time to look at this of course.=

best regards,

'=C3=B6-Dzin

=

=E2=98=B8=C2= =A0Achos pan ddaw y Pedwar Marchog i o= fyn a roist ti o dy gyfan - fydd gen ti ddim esgus - Meinir Gwilym=C2=A0=E2= =98=B8
<= /div>


On Wed, 19 Jul 2023 at 17:19, 'o-Dzin Tri= dral <tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi Christophe,

Thank you very much for your reply.

I've not used lua filte= rs before.=C2=A0 It took me a while to realise how to make a command line w= ith the input file and output file.

I thought I'd write back and include tis fo= r the benefit of any novices like me.
I've now done this with your script, = inserting the '-i' for the input file and using output redir= ection '>'=C2=A0 for the output file

=C2=A0=C2=A0 pandoc --lua-filter note.lua -t markdown -i <inpu= t file> | sed -e 's/%%opening%%/\^\[/g' | sed -e 's/%%cl= osing%%/\]/g' > <output file>
<= /div>
This works on my small example = file.

Th= ank you once again.

<= div dir=3D"ltr">
'=C3=B6-Dzin

=

=E2=98=B8=C2=A0<= font>Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - = fydd gen ti ddim esgus - Meinir Gwilym=C2=A0=E2=98=B8

On Wed, 19 Jul 2023 at 14:36, Christophe Demko <ch= d...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
You can use a lua filter:

$ pan= doc --lua-filter note.lua -t markdown | sed -e 's/%%opening%%/\^\[/g= 9; | sed -e 's/%%closing%%/\]/g'

with this= note.lua file

function Note(note)
=C2=A0 note.= content[1].content[1].text =3D "%%opening%%" .. note.content[1].c= ontent[1].text
=C2=A0 note.content[1].content[#note.content[1].content].= text =3D note.content[1].content[#note.content[1].content].text .. "%%= closing%%"
=C2=A0 return note.content[1].content
end
Le dimanche= 16 juillet 2023 =C3=A0 17:35:38 UTC+2, tri...-Re5JQEeQqe8@public.gmane.org= m a =C3=A9crit=C2=A0:
Is it possible to use Pandoc to convert an md file that has= reference footnotes to one that has inline footnotes - just by going from = md -> md, but failing that via another format.

= I have a file containing reference footnotes like this
----
=C2=A0=C2=A0=C2=A0 Example[^1] line of text.

=C2=A0=C2=A0= =C2=A0 [^1]: Example footnote
----

I wou= ld like to convert them all to inline footnotes like this

----
=C2=A0=C2=A0=C2=A0 Example^[Example footnote] line o= f text.
----

Thank you for any help<= /div>

'=C3=B6-Dzin

--
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 pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/dabd9a50-de2= 3-47d9-971e-cfc8d1b92e0dn%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/pandoc-discuss/7d7d33f9-dc97-4b3e-b3f0-efcaac2bd324n%40googlegroups.= com.
------=_Part_15001_1170656731.1689792234850-- ------=_Part_15000_1367193060.1689792234850--