public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Converting reference footnotes to inline footnotes (md -> md if poss.)
@ 2023-07-16 15:35 tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found] ` <fa3d8615-1ad8-4034-adb3-5e7daeaa8dden-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2023-07-16 15:35 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 897 bytes --]

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
----
    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

'ö-Dzin

-- 
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/fa3d8615-1ad8-4034-adb3-5e7daeaa8dden%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 1386 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Converting reference footnotes to inline footnotes (md -> md if poss.)
       [not found] ` <fa3d8615-1ad8-4034-adb3-5e7daeaa8dden-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2023-07-19 13:36   ` Christophe Demko
       [not found]     ` <dabd9a50-de23-47d9-971e-cfc8d1b92e0dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe Demko @ 2023-07-19 13:36 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1490 bytes --]

You can use a lua filter:

$ pandoc --lua-filter note.lua -t markdown | sed -e 's/%%opening%%/\^\[/g' 
| sed -e 's/%%closing%%/\]/g'

with this note.lua file

function Note(note)
  note.content[1].content[1].text = "%%opening%%" .. 
note.content[1].content[1].text
  note.content[1].content[#note.content[1].content].text = 
note.content[1].content[#note.content[1].content].text .. "%%closing%%"
  return note.content[1].content
end
Le dimanche 16 juillet 2023 à 17:35:38 UTC+2, tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :

> 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
> ----
>     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
>
> 'ö-Dzin
>

-- 
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/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2236 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Converting reference footnotes to inline footnotes (md -> md if poss.)
       [not found]     ` <dabd9a50-de23-47d9-971e-cfc8d1b92e0dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2023-07-19 15:57       ` Christophe Demko
  2023-07-19 16:19       ` 'o-Dzin Tridral
  1 sibling, 0 replies; 8+ messages in thread
From: Christophe Demko @ 2023-07-19 15:57 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 2022 bytes --]

If you want to adress only footnotes with one paragraph:

function Note(note)
  if #note.content == 1 then
    note.content[1].content[1].text = "%%opening%%" .. 
note.content[1].content[1].text
    note.content[1].content[#note.content[1].content].text = 
note.content[1].content[#note.content[1].content].text .. "%%closing%%"
    return note.content[1].content
  end
  return note
end

Le mercredi 19 juillet 2023 à 15:36:10 UTC+2, Christophe Demko a écrit :

> You can use a lua filter:
>
> $ pandoc --lua-filter note.lua -t markdown | sed -e 's/%%opening%%/\^\[/g' 
> | sed -e 's/%%closing%%/\]/g'
>
> with this note.lua file
>
> function Note(note)
>   note.content[1].content[1].text = "%%opening%%" .. 
> note.content[1].content[1].text
>   note.content[1].content[#note.content[1].content].text = 
> note.content[1].content[#note.content[1].content].text .. "%%closing%%"
>   return note.content[1].content
> end
> Le dimanche 16 juillet 2023 à 17:35:38 UTC+2, tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :
>
>> 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
>> ----
>>     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
>>
>> 'ö-Dzin
>>
>

-- 
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/b680c4f7-0c33-4a3c-9607-1d0fad225ab8n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3058 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Converting reference footnotes to inline footnotes (md -> md if poss.)
       [not found]     ` <dabd9a50-de23-47d9-971e-cfc8d1b92e0dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2023-07-19 15:57       ` Christophe Demko
@ 2023-07-19 16:19       ` 'o-Dzin Tridral
       [not found]         ` <CAD3c=RBZ3r8sXRSebMD2hpX-mbLPubS7NF8nur=sr-z+tf--aQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: 'o-Dzin Tridral @ 2023-07-19 16:19 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 3354 bytes --]

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
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
like me.

I've now done this with your script, inserting the* '-i' *for the input
file and using output redirection '*>'  *for the output file

   pandoc --lua-filter note.lua -t markdown -i *<input file>* | sed -e
's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g' > *<output file>*

This works on my small example file.

Thank you once again.

'ö-Dzin




འོད་འཛིན་དྲི་བྲལ
'ö-Dzin Tridral
[image: https://]about.me/tridral
<https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
☸
*Drala Jong Appeal - creating a Buddhist retreat centre in Wales:
https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸

☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd gen
ti ddim esgus - Meinir Gwilym ☸


On Wed, 19 Jul 2023 at 14:36, Christophe Demko <chdemko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> You can use a lua filter:
>
> $ pandoc --lua-filter note.lua -t markdown | sed -e 's/%%opening%%/\^\[/g'
> | sed -e 's/%%closing%%/\]/g'
>
> with this note.lua file
>
> function Note(note)
>   note.content[1].content[1].text = "%%opening%%" ..
> note.content[1].content[1].text
>   note.content[1].content[#note.content[1].content].text =
> note.content[1].content[#note.content[1].content].text .. "%%closing%%"
>   return note.content[1].content
> end
> Le dimanche 16 juillet 2023 à 17:35:38 UTC+2, tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :
>
>> 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
>> ----
>>     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
>>
>> 'ö-Dzin
>>
> --
> 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/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAD3c%3DRBZ3r8sXRSebMD2hpX-mbLPubS7NF8nur%3Dsr-z%2Btf--aQ%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 12303 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Converting reference footnotes to inline footnotes (md -> md if poss.)
       [not found]         ` <CAD3c=RBZ3r8sXRSebMD2hpX-mbLPubS7NF8nur=sr-z+tf--aQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-07-19 16:43           ` 'o-Dzin Tridral
       [not found]             ` <CAD3c=RDmb_AG=OeuZomhhokhHD0KWOwgZkjm--imw3akac6RhQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: 'o-Dzin Tridral @ 2023-07-19 16:43 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 4537 bytes --]

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 causing
the problem.  If you have any advice re how to get more information from
pandoc or lua I would very much appreciate it.

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

best regards,

'ö-Dzin




འོད་འཛིན་དྲི་བྲལ
'ö-Dzin Tridral
[image: https://]about.me/tridral
<https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
☸
*Drala Jong Appeal - creating a Buddhist retreat centre in Wales:
https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸

☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd gen
ti ddim esgus - Meinir Gwilym ☸


On Wed, 19 Jul 2023 at 17:19, 'o-Dzin Tridral <tridral-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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
> 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
> like me.
>
> I've now done this with your script, inserting the* '-i' *for the input
> file and using output redirection '*>'  *for the output file
>
>    pandoc --lua-filter note.lua -t markdown -i *<input file>* | sed -e
> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g' > *<output file>*
>
> This works on my small example file.
>
> Thank you once again.
>
> 'ö-Dzin
>
>
>
>
> འོད་འཛིན་དྲི་བྲལ
> 'ö-Dzin Tridral
> [image: https://]about.me/tridral
>
> <https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
> ☸
> *Drala Jong Appeal - creating a Buddhist retreat centre in Wales:
> https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸
>
> ☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd gen
> ti ddim esgus - Meinir Gwilym ☸
>
>
> On Wed, 19 Jul 2023 at 14:36, Christophe Demko <chdemko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> You can use a lua filter:
>>
>> $ pandoc --lua-filter note.lua -t markdown | sed -e
>> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g'
>>
>> with this note.lua file
>>
>> function Note(note)
>>   note.content[1].content[1].text = "%%opening%%" ..
>> note.content[1].content[1].text
>>   note.content[1].content[#note.content[1].content].text =
>> note.content[1].content[#note.content[1].content].text .. "%%closing%%"
>>   return note.content[1].content
>> end
>> Le dimanche 16 juillet 2023 à 17:35:38 UTC+2, tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :
>>
>>> 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
>>> ----
>>>     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
>>>
>>> 'ö-Dzin
>>>
>> --
>> 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/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com
>> <https://groups.google.com/d/msgid/pandoc-discuss/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAD3c%3DRDmb_AG%3DOeuZomhhokhHD0KWOwgZkjm--imw3akac6RhQ%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 21546 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Converting reference footnotes to inline footnotes (md -> md if poss.)
       [not found]             ` <CAD3c=RDmb_AG=OeuZomhhokhHD0KWOwgZkjm--imw3akac6RhQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-07-19 17:59               ` Christophe Demko
       [not found]                 ` <fdfa600a-c418-467e-a01b-2f8af160eba9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe Demko @ 2023-07-19 17:59 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 4808 bytes --]

Can you post the files which cause an issue ?

Le mercredi 19 juillet 2023 à 18:44:09 UTC+2, 'o-Dzin Tridral a écrit :

> 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 
> causing the problem.  If you have any advice re how to get more information 
> from pandoc or lua I would very much appreciate it. 
>
> I entirely understand if you don't have time to look at this of course.
>
> best regards,
>
> 'ö-Dzin
>
>  
>
>
> འོད་འཛིན་དྲི་བྲལ
> 'ö-Dzin Tridral
> [image: https://]about.me/tridral
>
> <https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
> ☸ 
> *Drala Jong Appeal - creating a Buddhist retreat centre in Wales: 
> https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸
>
> ☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd gen 
> ti ddim esgus - Meinir Gwilym ☸
>
>
> On Wed, 19 Jul 2023 at 17:19, 'o-Dzin Tridral <tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 
>> 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 
>> like me.
>>
>> I've now done this with your script, inserting the* '-i' *for the input 
>> file and using output redirection '*>'  *for the output file
>>
>>    pandoc --lua-filter note.lua -t markdown -i *<input file>* | sed -e 
>> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g' > *<output file>*
>>
>> This works on my small example file.
>>
>> Thank you once again.
>>
>> 'ö-Dzin
>>
>>  
>>
>>
>> འོད་འཛིན་དྲི་བྲལ
>> 'ö-Dzin Tridral
>> [image: https://]about.me/tridral
>>
>> <https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
>> ☸ 
>> *Drala Jong Appeal - creating a Buddhist retreat centre in Wales: 
>> https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸
>>
>> ☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd 
>> gen ti ddim esgus - Meinir Gwilym ☸
>>
>>
>> On Wed, 19 Jul 2023 at 14:36, Christophe Demko <chd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>
>>> You can use a lua filter:
>>>
>>> $ pandoc --lua-filter note.lua -t markdown | sed -e 
>>> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g'
>>>
>>> with this note.lua file
>>>
>>> function Note(note)
>>>   note.content[1].content[1].text = "%%opening%%" .. 
>>> note.content[1].content[1].text
>>>   note.content[1].content[#note.content[1].content].text = 
>>> note.content[1].content[#note.content[1].content].text .. "%%closing%%"
>>>   return note.content[1].content
>>> end
>>> Le dimanche 16 juillet 2023 à 17:35:38 UTC+2, tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :
>>>
>>>> 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
>>>> ----
>>>>     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
>>>>
>>>> 'ö-Dzin
>>>>
>>> -- 
>>> 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/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com 
>>> <https://groups.google.com/d/msgid/pandoc-discuss/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/fdfa600a-c418-467e-a01b-2f8af160eba9n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 23133 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Converting reference footnotes to inline footnotes (md -> md if poss.)
       [not found]                 ` <fdfa600a-c418-467e-a01b-2f8af160eba9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2023-07-19 18:43                   ` Christophe Demko
       [not found]                     ` <7d7d33f9-dc97-4b3e-b3f0-efcaac2bd324n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe Demko @ 2023-07-19 18:43 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 5364 bytes --]

May be you have some complex content in your footnotes.
Try this note.lua file:

function Note(note)
  if #note.content == 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 à 19:59:23 UTC+2, Christophe Demko a écrit :

> Can you post the files which cause an issue ?
>
> Le mercredi 19 juillet 2023 à 18:44:09 UTC+2, 'o-Dzin Tridral a écrit :
>
>> 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 
>> causing the problem.  If you have any advice re how to get more information 
>> from pandoc or lua I would very much appreciate it. 
>>
>> I entirely understand if you don't have time to look at this of course.
>>
>> best regards,
>>
>> 'ö-Dzin
>>
>>  
>>
>>
>> འོད་འཛིན་དྲི་བྲལ
>> 'ö-Dzin Tridral
>> [image: https://]about.me/tridral
>>
>> <https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
>> ☸ 
>> *Drala Jong Appeal - creating a Buddhist retreat centre in Wales: 
>> https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸
>>
>> ☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd 
>> gen ti ddim esgus - Meinir Gwilym ☸
>>
>>
>> On Wed, 19 Jul 2023 at 17:19, 'o-Dzin Tridral <tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 
>>> 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 
>>> like me.
>>>
>>> I've now done this with your script, inserting the* '-i' *for the input 
>>> file and using output redirection '*>'  *for the output file
>>>
>>>    pandoc --lua-filter note.lua -t markdown -i *<input file>* | sed -e 
>>> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g' > *<output file>*
>>>
>>> This works on my small example file.
>>>
>>> Thank you once again.
>>>
>>> 'ö-Dzin
>>>
>>>  
>>>
>>>
>>> འོད་འཛིན་དྲི་བྲལ
>>> 'ö-Dzin Tridral
>>> [image: https://]about.me/tridral
>>>
>>> <https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
>>> ☸ 
>>> *Drala Jong Appeal - creating a Buddhist retreat centre in Wales: 
>>> https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸
>>>
>>> ☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd 
>>> gen ti ddim esgus - Meinir Gwilym ☸
>>>
>>>
>>> On Wed, 19 Jul 2023 at 14:36, Christophe Demko <chd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>>
>>>> You can use a lua filter:
>>>>
>>>> $ pandoc --lua-filter note.lua -t markdown | sed -e 
>>>> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g'
>>>>
>>>> with this note.lua file
>>>>
>>>> function Note(note)
>>>>   note.content[1].content[1].text = "%%opening%%" .. 
>>>> note.content[1].content[1].text
>>>>   note.content[1].content[#note.content[1].content].text = 
>>>> note.content[1].content[#note.content[1].content].text .. "%%closing%%"
>>>>   return note.content[1].content
>>>> end
>>>> Le dimanche 16 juillet 2023 à 17:35:38 UTC+2, tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a 
>>>> écrit :
>>>>
>>>>> 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
>>>>> ----
>>>>>     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
>>>>>
>>>>> 'ö-Dzin
>>>>>
>>>> -- 
>>>> 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/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com 
>>>> <https://groups.google.com/d/msgid/pandoc-discuss/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/7d7d33f9-dc97-4b3e-b3f0-efcaac2bd324n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 23759 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Converting reference footnotes to inline footnotes (md -> md if poss.)
       [not found]                     ` <7d7d33f9-dc97-4b3e-b3f0-efcaac2bd324n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2023-07-19 21:32                       ` 'o-Dzin Tridral
  0 siblings, 0 replies; 8+ messages in thread
From: 'o-Dzin Tridral @ 2023-07-19 21:32 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 7380 bytes --]

Hi Christoph,

Thank you very much.

I'm working on a book and I cut it down to the smallest file that would
reproduce the error.

I've tried this with you new code and it works...!

So the next thing was to try your new code with the entire book - and I get
a different error message

Error running filter lua_filter_note_complex.lua:
Inline, list of Inlines, or string expected, got List

I can try the process of chopping the file down to see if I can get the
same error with a smaller file. If you're happy to continue looking at this
I'll let you know how it goes.

I'm going to be away until Monday. If you have any advice I'll pick it up
then.

Thank you again,

'ö-Dzin




འོད་འཛིན་དྲི་བྲལ
'ö-Dzin Tridral
[image: https://]about.me/tridral
<https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
☸
*Drala Jong Appeal - creating a Buddhist retreat centre in Wales:
https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸

☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd gen
ti ddim esgus - Meinir Gwilym ☸


On Wed, 19 Jul 2023 at 19:43, Christophe Demko <chdemko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> May be you have some complex content in your footnotes.
> Try this note.lua file:
>
> function Note(note)
>   if #note.content == 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 à 19:59:23 UTC+2, Christophe Demko a écrit :
>
>> Can you post the files which cause an issue ?
>>
>> Le mercredi 19 juillet 2023 à 18:44:09 UTC+2, 'o-Dzin Tridral a écrit :
>>
>>> 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
>>> causing the problem.  If you have any advice re how to get more information
>>> from pandoc or lua I would very much appreciate it.
>>>
>>> I entirely understand if you don't have time to look at this of course.
>>>
>>> best regards,
>>>
>>> 'ö-Dzin
>>>
>>>
>>>
>>>
>>> འོད་འཛིན་དྲི་བྲལ
>>> 'ö-Dzin Tridral
>>> [image: https://]about.me/tridral
>>>
>>> <https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
>>> ☸
>>> *Drala Jong Appeal - creating a Buddhist retreat centre in Wales:
>>> https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸
>>>
>>> ☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd
>>> gen ti ddim esgus - Meinir Gwilym ☸
>>>
>>>
>>> On Wed, 19 Jul 2023 at 17:19, 'o-Dzin Tridral <tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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
>>>> 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
>>>> like me.
>>>>
>>>> I've now done this with your script, inserting the* '-i' *for the
>>>> input file and using output redirection '*>'  *for the output file
>>>>
>>>>    pandoc --lua-filter note.lua -t markdown -i *<input file>* | sed -e
>>>> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g' > *<output file>*
>>>>
>>>> This works on my small example file.
>>>>
>>>> Thank you once again.
>>>>
>>>> 'ö-Dzin
>>>>
>>>>
>>>>
>>>>
>>>> འོད་འཛིན་དྲི་བྲལ
>>>> 'ö-Dzin Tridral
>>>> [image: https://]about.me/tridral
>>>>
>>>> <https://about.me/tridral?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links>
>>>> ☸
>>>> *Drala Jong Appeal - creating a Buddhist retreat centre in Wales:
>>>> https://www.drala-jong.org/ <https://www.drala-jong.org/> *☸
>>>>
>>>> ☸ Achos pan ddaw y Pedwar Marchog i ofyn a roist ti o dy gyfan - fydd
>>>> gen ti ddim esgus - Meinir Gwilym ☸
>>>>
>>>>
>>>> On Wed, 19 Jul 2023 at 14:36, Christophe Demko <chd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>> wrote:
>>>>
>>>>> You can use a lua filter:
>>>>>
>>>>> $ pandoc --lua-filter note.lua -t markdown | sed -e
>>>>> 's/%%opening%%/\^\[/g' | sed -e 's/%%closing%%/\]/g'
>>>>>
>>>>> with this note.lua file
>>>>>
>>>>> function Note(note)
>>>>>   note.content[1].content[1].text = "%%opening%%" ..
>>>>> note.content[1].content[1].text
>>>>>   note.content[1].content[#note.content[1].content].text =
>>>>> note.content[1].content[#note.content[1].content].text .. "%%closing%%"
>>>>>   return note.content[1].content
>>>>> end
>>>>> Le dimanche 16 juillet 2023 à 17:35:38 UTC+2, tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a
>>>>> écrit :
>>>>>
>>>>>> 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
>>>>>> ----
>>>>>>     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
>>>>>>
>>>>>> 'ö-Dzin
>>>>>>
>>>>> --
>>>>> 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/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/pandoc-discuss/dabd9a50-de23-47d9-971e-cfc8d1b92e0dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
> You received this message because you are subscribed to the Google Groups
> "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/7d7d33f9-dc97-4b3e-b3f0-efcaac2bd324n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/7d7d33f9-dc97-4b3e-b3f0-efcaac2bd324n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAD3c%3DRATZXBr4t64RtbUXtCnFLOMfEWENC7zGn-ozL51wNUWSw%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 32721 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-19 21:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-16 15:35 Converting reference footnotes to inline footnotes (md -> md if poss.) tri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found] ` <fa3d8615-1ad8-4034-adb3-5e7daeaa8dden-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-19 13:36   ` Christophe Demko
     [not found]     ` <dabd9a50-de23-47d9-971e-cfc8d1b92e0dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-19 15:57       ` Christophe Demko
2023-07-19 16:19       ` 'o-Dzin Tridral
     [not found]         ` <CAD3c=RBZ3r8sXRSebMD2hpX-mbLPubS7NF8nur=sr-z+tf--aQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-07-19 16:43           ` 'o-Dzin Tridral
     [not found]             ` <CAD3c=RDmb_AG=OeuZomhhokhHD0KWOwgZkjm--imw3akac6RhQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-07-19 17:59               ` Christophe Demko
     [not found]                 ` <fdfa600a-c418-467e-a01b-2f8af160eba9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-19 18:43                   ` Christophe Demko
     [not found]                     ` <7d7d33f9-dc97-4b3e-b3f0-efcaac2bd324n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-19 21:32                       ` 'o-Dzin Tridral

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).