up please Le mardi 12 juillet 2022 à 16:32:43 UTC+2, Ismail Jattioui a écrit : > I tried this code which looked like what I want to do, but it still > doesn’t work unfortunately. > > There are apparently no RawBlock in the html I posted and I don't see how > we can add one > > I tried using Para and Block with no success :/ I got the following error > : > PandocLuaError "Trying to set unavailable property text." at the line > indicated by ----> > > The command I am using: > > pandoc --metadata toc-title=custom-toc --lua-filter=filter.lua > input-test.html -o res.docx > > The luaFilter I am trying: > > ------------------------------------------------------ > local RAW_TOC = [[ > > > > > > TOC \o "1-3" \h \z \u > > > > > > > ]] > local meta_key = "toc-title" > local vars = {} > > > local function getVars (meta) > for k, v in pairs(meta) do > if v.t == 'MetaInlines' then > print('isMetaInlines') > vars["$" .. k .. "$"] = { table.unpack(v) } > end > end > end > > local function pageBreak(el) > if el.text == "pandoc-page-break" then > print('pageBreak') > return pandoc.Str "" > else > return el > end > end > > > local function toc(el) > print(el) > if pandoc.utils.stringify(el) == "pandoc-toc" then > ----> el.text = RAW_TOC > el.format = "openxml" > local para = pandoc.Para(vars) > local div = pandoc.Div({ para, el }) > div["attr"]["attributes"]["custom-style"] = "TOC Heading" > return div > end > end > > return { > { Meta = getVars }, > { Str = pageBreak }, > { RawBlock = toc } > } > ------------------------------------------------------ > Le lundi 11 juillet 2022 à 10:48:41 UTC+2, Ismail Jattioui a écrit : > >> Hi, >> >> I am trying to convert a html file to docx using pandoc. My problem is >> that I can’t manage to move the table of contents to a specific position in >> the document. I tried splitting my document into two, then merging it again >> but it isn’t optimal since we are using it in production and it costs us 2 >> calls to pandoc and it isn't very maintanable >> >> I was wondering if there is a way to do that using Lua filters >> >> In a nutshell, let’s say I have the following html document that I wish >> to convert to DOCX : >> >> >> >> >> >> >>

Title 1

>>

Some stuff 2

>>

Subtitle 1

>>

Some stuff 2

>>
Other things
>>
Insert TOC below
>> >> >> How do I manage to generate a Table of content below the div with the TOC >> id, without splitting the document ? >> >> Thanks in advance >> > -- 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/a9967f45-314e-484c-a642-ecb03c315e10n%40googlegroups.com.