public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Move TOC when converting html to docx
Date: Mon, 18 Jul 2022 10:07:00 +0200	[thread overview]
Message-ID: <EE47F68F-93F4-41CF-B650-7B1E1613D00E@gmail.com> (raw)
In-Reply-To: <77066946-d07a-489a-9ec2-99796422f682n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

There's a special syntax in the docx file to include the table of contents; you're not going to be able to do it this way.

Maybe your best approach would be to have a script modify the docx after pandoc produces it. A docx is just a zip file containing xml documnets, so you'd need to unzip it, modify document.xml, and zip it back up.  The modification would simply consist of moving the XML elements that produce the TOC to another location in your document.xml.

> On Jul 11, 2022, at 10:48 AM, Ismail Jattioui <ismail.jattioui1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> 
> 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 :
> 
> <!DOCTYPE html>
> <html lang="en">
>     <head>
>         <meta charset="UTF-8" />
>     </head>
>     <h1>Title 1</h1>
>     <p>Some stuff 2</p>
>     <h2>Subtitle 1</h2>
>     <p>Some stuff 2</p>
>     <div>Other things</div>
>     <div id="TOC">Insert TOC below</div>
> </html>
> 
> 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/77066946-d07a-489a-9ec2-99796422f682n%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/EE47F68F-93F4-41CF-B650-7B1E1613D00E%40gmail.com.


  parent reply	other threads:[~2022-07-18  8:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11  8:48 Ismail Jattioui
     [not found] ` <77066946-d07a-489a-9ec2-99796422f682n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-12 14:32   ` Ismail Jattioui
     [not found]     ` <88926968-1ca3-40c4-944f-c78e0554ba84n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-18  6:33       ` Ismail Jattioui
2022-07-18  8:07   ` John MacFarlane [this message]
     [not found]     ` <EE47F68F-93F4-41CF-B650-7B1E1613D00E-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-07-21 13:48       ` Ismail Jattioui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EE47F68F-93F4-41CF-B650-7B1E1613D00E@gmail.com \
    --to=fiddlosopher-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).