public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Lua filter to set meta data
@ 2021-08-11 16:25 Björn Fisseler
       [not found] ` <998f827a-92f9-49fc-ab87-25707ba5c7e8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Björn Fisseler @ 2021-08-11 16:25 UTC (permalink / raw)
  To: pandoc-discuss


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


Hi, 

I want to use Pandoc for converting DOCX to HTML. The goal is to convert 
DOCX to Moodle-Books. While understanding the very basic of developing Lua 
filters is relatively easy, I find it has a steep learning curve when you 
want to achieve certain things.

For example, I need to convert a heading level 2 to the meta data element 
title while reducing all other levels by one (h3 > h4, h4 > h5). This is 
the code that I came up with:
function Header(el)
if (el.level > 2) then
el.level = el.level + 1
end
if (el.level == 2) then
title = el.content
end
return el
end

Thing is, it doesn't work as intended and I don't know why. While it 
correctly modifies the heading levels, it won't set the title. Could 
anybody point me to some documentation? Browsing the Pandoc manual didn't 
help me to understand why this wouldn't work.

-- 
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/998f827a-92f9-49fc-ab87-25707ba5c7e8n%40googlegroups.com.

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

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

* Re: Lua filter to set meta data
       [not found] ` <998f827a-92f9-49fc-ab87-25707ba5c7e8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-08-11 18:05   ` John MacFarlane
       [not found]     ` <m2k0kr7t7o.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: John MacFarlane @ 2021-08-11 18:05 UTC (permalink / raw)
  To: Björn Fisseler, pandoc-discuss


Have you looked at the pandoc option --shift-heading-level-by?

Björn Fisseler <bjoern.fisseler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi, 
>
> I want to use Pandoc for converting DOCX to HTML. The goal is to convert 
> DOCX to Moodle-Books. While understanding the very basic of developing Lua 
> filters is relatively easy, I find it has a steep learning curve when you 
> want to achieve certain things.
>
> For example, I need to convert a heading level 2 to the meta data element 
> title while reducing all other levels by one (h3 > h4, h4 > h5). This is 
> the code that I came up with:
> function Header(el)
> if (el.level > 2) then
> el.level = el.level + 1
> end
> if (el.level == 2) then
> title = el.content
> end
> return el
> end
>
> Thing is, it doesn't work as intended and I don't know why. While it 
> correctly modifies the heading levels, it won't set the title. Could 
> anybody point me to some documentation? Browsing the Pandoc manual didn't 
> help me to understand why this wouldn't work.
>
> -- 
> 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/998f827a-92f9-49fc-ab87-25707ba5c7e8n%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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2k0kr7t7o.fsf%40MacBook-Pro-2.hsd1.ca.comcast.net.


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

* Re: Lua filter to set meta data
       [not found]     ` <m2k0kr7t7o.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
@ 2021-08-12 11:05       ` Björn Fisseler
  0 siblings, 0 replies; 3+ messages in thread
From: Björn Fisseler @ 2021-08-12 11:05 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks for the tip, but that doesn't solve my problem. 

I want to use headings level 2 as title, thus "--shift-heading-level-by=-2" 
would do this trick. But then all the other headings get shifted in the 
wrong direction, as h3 get to h1, h4 to h2 and so on. Accessibility is one 
requirement, and thus a specific heading structure is required by WCAG 
Criterion 1.3.1 
<https://www.w3.org/TR/2008/REC-WCAG20-20081211/#content-structure-separation-programmatic>
.

But doing some additional research lead to this tip on StackOverflow 
<https://stackoverflow.com/questions/56004886/pandoc-set-document-title-to-first-title>. 
Will give it a try.

John MacFarlane schrieb am Mittwoch, 11. August 2021 um 20:05:30 UTC+2:

>
> Have you looked at the pandoc option --shift-heading-level-by?
>
> Björn Fisseler <bjoern....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
> > Hi, 
> >
> > I want to use Pandoc for converting DOCX to HTML. The goal is to convert 
> > DOCX to Moodle-Books. While understanding the very basic of developing 
> Lua 
> > filters is relatively easy, I find it has a steep learning curve when 
> you 
> > want to achieve certain things.
> >
> > For example, I need to convert a heading level 2 to the meta data 
> element 
> > title while reducing all other levels by one (h3 > h4, h4 > h5). This is 
> > the code that I came up with:
> > function Header(el)
> > if (el.level > 2) then
> > el.level = el.level + 1
> > end
> > if (el.level == 2) then
> > title = el.content
> > end
> > return el
> > end
> >
> > Thing is, it doesn't work as intended and I don't know why. While it 
> > correctly modifies the heading levels, it won't set the title. Could 
> > anybody point me to some documentation? Browsing the Pandoc manual 
> didn't 
> > help me to understand why this wouldn't work.
> >
> > -- 
> > 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/998f827a-92f9-49fc-ab87-25707ba5c7e8n%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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e0ae1e48-ef87-402d-97a0-fd7c5d6874f0n%40googlegroups.com.

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

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

end of thread, other threads:[~2021-08-12 11:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 16:25 Lua filter to set meta data Björn Fisseler
     [not found] ` <998f827a-92f9-49fc-ab87-25707ba5c7e8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-08-11 18:05   ` John MacFarlane
     [not found]     ` <m2k0kr7t7o.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2021-08-12 11:05       ` Björn Fisseler

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