public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Pandoc filter: numbering parts, chapters and sections for HTML
@ 2018-07-29 22:26 Axel Rauschmayer
       [not found] ` <d24dc311-f2fc-44d1-b947-06785d900f1f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Axel Rauschmayer @ 2018-07-29 22:26 UTC (permalink / raw)
  To: pandoc-discuss


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

Pandoc optionally numbers sections. But, alas, that doesn’t work in HTML if 
your level 1 are parts.

I wrote a filter that you can use in that case. Warning: My knowledge of 
Lua and Pandoc filters is limited, so I may have made mistakes. Feedback 
welcome!

Link: https://gist.github.com/rauschma/458303094cd87cab077c00c061cce8da

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d24dc311-f2fc-44d1-b947-06785d900f1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Pandoc filter: numbering parts, chapters and sections for HTML
       [not found] ` <d24dc311-f2fc-44d1-b947-06785d900f1f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2018-07-29 23:21   ` 'Jason Seeley' via pandoc-discuss
       [not found]     ` <c8a50552-3824-4b57-96b2-c1a1476a062f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: 'Jason Seeley' via pandoc-discuss @ 2018-07-29 23:21 UTC (permalink / raw)
  To: pandoc-discuss


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

Looks good.

One thing you should be aware of is that Lua filters aren't processed in 
Depth-first order properly. Rather, all blocks at the top level are 
processed, then all blocks at the second level, and so on. This doesn't 
matter for Headers since they don't actually nest, but if you have a Header 
inside a Div (and not all of the Headers are in Divs of the same level) it 
could come out wrong.

For example, if you have:

## This is a Header ##

::: {.whatever}
## This is a nested Header ##
:::

## This is a third Header ##

then you will end up with:

1. This is a Header

3. This is a nested Header

2. This is a third Header

I don't know of a good way to fix this problem, it's just something you 
need to be aware of when using a filter that depends on the order that each 
node is processed by Pandoc.



On Sunday, July 29, 2018 at 5:26:44 PM UTC-5, Axel Rauschmayer wrote:

> Pandoc optionally numbers sections. But, alas, that doesn’t work in HTML 
> if your level 1 are parts.
>
> I wrote a filter that you can use in that case. Warning: My knowledge of 
> Lua and Pandoc filters is limited, so I may have made mistakes. Feedback 
> welcome!
>
> Link: https://gist.github.com/rauschma/458303094cd87cab077c00c061cce8da
>

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c8a50552-3824-4b57-96b2-c1a1476a062f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Pandoc filter: numbering parts, chapters and sections for HTML
       [not found]     ` <c8a50552-3824-4b57-96b2-c1a1476a062f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2018-07-30  8:07       ` Axel Rauschmayer
  2018-07-30  8:53       ` Axel Rauschmayer
  1 sibling, 0 replies; 4+ messages in thread
From: Axel Rauschmayer @ 2018-07-30  8:07 UTC (permalink / raw)
  To: pandoc-discuss


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

Interesting, thanks! I’d want to never number nested Headers. Is there a 
way to detect if a Header is at the top level or not?

-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/653d925c-2462-42af-bb46-09e85f2b2f08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: Pandoc filter: numbering parts, chapters and sections for HTML
       [not found]     ` <c8a50552-3824-4b57-96b2-c1a1476a062f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2018-07-30  8:07       ` Axel Rauschmayer
@ 2018-07-30  8:53       ` Axel Rauschmayer
  1 sibling, 0 replies; 4+ messages in thread
From: Axel Rauschmayer @ 2018-07-30  8:53 UTC (permalink / raw)
  To: pandoc-discuss


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

Another issue: several headers are visited by the filter, even if they 
never show up in the HTML. I’m skipping them via a table for now:

local headersToIgnore = {
  ["List of Figures"] = true,
  ["List of Listings"] = true,
  ["List of Tables"] = true,
}


-- 
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e503c624-9fe4-4335-b3be-66f007850058%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

end of thread, other threads:[~2018-07-30  8:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-29 22:26 Pandoc filter: numbering parts, chapters and sections for HTML Axel Rauschmayer
     [not found] ` <d24dc311-f2fc-44d1-b947-06785d900f1f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2018-07-29 23:21   ` 'Jason Seeley' via pandoc-discuss
     [not found]     ` <c8a50552-3824-4b57-96b2-c1a1476a062f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2018-07-30  8:07       ` Axel Rauschmayer
2018-07-30  8:53       ` Axel Rauschmayer

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