public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Lua filter to change the order of a markdown file.
@ 2022-02-15 11:42 John
       [not found] ` <4316bc46-9d6b-46b5-8eb7-39b5cb77975en-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: John @ 2022-02-15 11:42 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi all,

First of all, I am quite new to both Pandoc and Lua. So if there are any 
tips you have for getting to know them, they are very welcome.

I am running into a problem while trying to write a Lua filter that would 
change the order of an existing markdown file. This file contains various 
sections (different translations of the same text), divided by headings 
which are followed by paragraphs.

*Example*:
# Heading 1
## Heading 2, source text
Lorem ipsum...

## Heading 2, translation 1
Lorem ipsum...

## Heading 2, translation 2
Lorem ipsum...

I want to be able to change the order of the paragraphs *with* their 
headings. So displaying first the translations and then the source text for 
example. But when I look at the AST, the headers and para(graph)s are 
seperate blocks, so reordering the headers does not copy the corresponding 
paragraphs. 

Can anyone help me out?

Kind regards,
John

-- 
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/4316bc46-9d6b-46b5-8eb7-39b5cb77975en%40googlegroups.com.

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

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

* Re: Lua filter to change the order of a markdown file.
       [not found] ` <4316bc46-9d6b-46b5-8eb7-39b5cb77975en-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-02-15 23:25   ` John MacFarlane
  0 siblings, 0 replies; 2+ messages in thread
From: John MacFarlane @ 2022-02-15 23:25 UTC (permalink / raw)
  To: John, pandoc-discuss


One approach is to iterate over the list of blocks that makes up the
document body using a for loop, and construct a new list with
a different order.

John <johanneswit-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi all,
>
> First of all, I am quite new to both Pandoc and Lua. So if there are any 
> tips you have for getting to know them, they are very welcome.
>
> I am running into a problem while trying to write a Lua filter that would 
> change the order of an existing markdown file. This file contains various 
> sections (different translations of the same text), divided by headings 
> which are followed by paragraphs.
>
> *Example*:
> # Heading 1
> ## Heading 2, source text
> Lorem ipsum...
>
> ## Heading 2, translation 1
> Lorem ipsum...
>
> ## Heading 2, translation 2
> Lorem ipsum...
>
> I want to be able to change the order of the paragraphs *with* their 
> headings. So displaying first the translations and then the source text for 
> example. But when I look at the AST, the headers and para(graph)s are 
> seperate blocks, so reordering the headers does not copy the corresponding 
> paragraphs. 
>
> Can anyone help me out?
>
> Kind regards,
> John
>
> -- 
> 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/4316bc46-9d6b-46b5-8eb7-39b5cb77975en%40googlegroups.com.


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

end of thread, other threads:[~2022-02-15 23:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 11:42 Lua filter to change the order of a markdown file John
     [not found] ` <4316bc46-9d6b-46b5-8eb7-39b5cb77975en-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-02-15 23:25   ` John MacFarlane

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