From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29736 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "'Nick Bart' via pandoc-discuss" Newsgroups: gmane.text.pandoc Subject: Re: Table of Contents Insertion Date: Thu, 09 Dec 2021 16:47:24 +0000 Message-ID: References: <09cc470d-3c03-4d79-bc47-7158080a9413n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="b1_I9QfBiNThsYIUJY0pKiVOUnpekElf6ir1c84tZg" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38823"; mail-complaints-to="usenet@ciao.gmane.io" To: "pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org" Original-X-From: pandoc-discuss+bncBDR4BGVI44MRBKHGZCGQMGQEIEJYKWY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Dec 09 17:47:39 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lj1-f184.google.com ([209.85.208.184]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mvMa2-0009rO-W5 for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 09 Dec 2021 17:47:39 +0100 Original-Received: by mail-lj1-f184.google.com with SMTP id y11-20020a2e978b000000b00218df7f76fesf2088304lji.11 for ; Thu, 09 Dec 2021 08:47:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1639068458; cv=pass; d=google.com; s=arc-20160816; b=0yL2o24xe3wzUo3Vz0pta8dJB8uVIZgzHzYbldLHeieAoOn5Tfpqk9vtlcHx4YRBYB eATIOUVoGn5/a7ZI4t4zlMLNDDORcGwlOl1ZXmOCGbNOvccly2HTq92IKyT2uVNLVc8e tXRjizWfpzL/iHf2c4qFgo+80TfMpmPRUaKO1zJqzWJ121ea0YgcYDhHMVWb3OMJRmXI gZwhEQCyN+Gx6qlutXRHmmVh9C5aH/VprMMjdGjzuEAoQgKQeQD22xMkcMKo2VuTRMj6 aGOSyD5oxQxxsWD7xft8sYOYojAwBPP07JvIyndAskSEtuOZrbmJynrCh9bsABwPrSLM UCBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:subject:reply-to:from:to:date:dkim-signature; bh=icTGLaFcKbD9zM/rbzMkbWM/2cCljgOwuPbwzIm8hs4=; b=owhuho2ClsSdVo7MgqvkdB7HQqa/i3MiuUDpOJ9rEbgqWBhG50V//DLSWVGCDtosZj 3XGFhETpaUo+HYmmR9vsMtvQ6+IlvAOOA3xv0fiPzA9ReGZEC3te/8LogFrK0IXuMtk0 w5+m5rHaiZoLuAk2ECJEzQs2TUJRDE/ZpTdry6cr8VilXYPhu0BAscY7hmDd7wR8YVmA ZChRwYN2lz+GlvoxzszaFQ7MqELGFepPAEPEHbJVftwF6Bs4Z3lBzQCDFdZ6FQam1cK1 iHD0NZkBK8RqDE57/ea1cOPgHA1PG/MBtth2ngZjLJsZo44itS4VNwl7YfHppidcz4so 91UA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail2 header.b=j0kb2S3D; spf=pass (google.com: domain of njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org designates 185.70.40.140 as permitted sender) smtp.mailfrom=njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=date:to:from:reply-to:subject:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=icTGLaFcKbD9zM/rbzMkbWM/2cCljgOwuPbwzIm8hs4=; b=XZqNkpmp+BM2egKE5b/MfkVWU06ZqS2IdtOz5HJ0k91q0as9fpPKW2clSk0yXwxfbY vPhbYMhzoRJHxbGF4NhFUa1LLmCdYOE9cnPYuvUHJ9viOxVqc2DIeVOXcOfPRM8t7wsC qCHG+KhsXf6BwJ9cIS3eTbHj8C4e5/1hZZFQ+xyxoBJ9iAkTEtuuMy6mpclo+JdYeRt4 c28Fr8YazqHZ6GI3E6MH8FZdihKsEoDh2mLD6tuNvgXiBjvlDMQyVmTpPD9Se8VxnARf kxHS3t0GhSA+mTBgwATwZ25RAxKKkzrB/HsnaPUv31slGsJXxRsdt9zOeFwhWney+KIb E5Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:to:from:reply-to:subject:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=icTGLaFcKbD9zM/rbzMkbWM/2cCljgOwuPbwzIm8hs4=; b=JRQqqVcmHOEd/U1kPdzmh1I4ujTSxHZusCOaXOpBeXxfPVBnGOyEOPN/6nGmAniJLj nY2uaGDxkCg2dgR4IfqKDqGtga4J88Sb0gy1IDsAgN4ZphaBtkW22W12VL1iYY21uwJV Pdt6lzKSjnT1mx53OQtNm6BTDpPvMep/A4r+ZrvQCu/WEaMIqrswGNNcu8uV2WD4bSlL xqFFRChahZZrMQNbsuw2zMOEBmr/VGqndE3ISKUjk7HS3IYz68ZsxHRU4u5s0xgcckKi 2D4r8bRohctRbTMPR2lLw1f4CIXkoycmOx8deX9owHtSA/YGvMIF15lnw7r/UYltID5h Zu6g== X-Gm-Message-State: AOAM530XMnU8Pklc6C1qMZCmFWLV8C6QqYNcI1HQCdYELDAPY5zGKi2P 63n9730wdMVDlKTERCpiSDU= X-Google-Smtp-Source: ABdhPJzmZDA5Un05oKIoO7QwFVgLiG36rjV9sTNWbP1rnW4XQcrvApjtqntNakt91R3Q/Sr95J6tYg== X-Received: by 2002:a05:6512:33cd:: with SMTP id d13mr7005876lfg.360.1639068458437; Thu, 09 Dec 2021 08:47:38 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a2e:a378:: with SMTP id i24ls1033032ljn.3.gmail; Thu, 09 Dec 2021 08:47:35 -0800 (PST) X-Received: by 2002:a2e:b177:: with SMTP id a23mr7277151ljm.2.1639068455787; Thu, 09 Dec 2021 08:47:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639068455; cv=none; d=google.com; s=arc-20160816; b=DHhqHfCzzJHFPU0QlrlOTWjruRxQjHvGFux978sGLFQaGmqaElJMNj4pDIFew9CX7r mknGK+Y7dqTEUWQrTjAPoc61rNLmVp9eWtG1rCZLLCYG0YnXhYESTVi3WjgzRbfV5uZx aDAj9gPOG6zEnSoMPzuEWcGrLRNEKDcltAbx48Puj+3Z+YGpqHecgFneL0PYg1vjDVwh jkNXf7sEgonSYBSdqMb3C1h+6TGxHtaNrbOwJC0FkaG9lF7lVN8C3yJuuxz8RmHjQY8X jH+q7q0ibJzyixqzXAA2Qe3vZn3kV8z3qggR87MoJhXlRSMP1yq7X/KdmcJ+FR4HfwzT cdMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:subject:reply-to :from:to:dkim-signature:date; bh=0oAxdV8fvB1hjRvsfpwaojbDXDPQdG2RrQihqnLL1Ok=; b=SpHaaDyZm1ngWLQ/wGhwikPTH0fBDruApKyXWRivnfX5vBbxECprt4p+ba2dCVB9C0 KyjtElK4YgTr0G2yz0tBfFty2fEVUsndPMZxnItvFy3X2rsiu69R4WsaNEg2Gn1BKe+a VTnVmirbCjKNpw0o8NcUnwclrMkGTyJpfTbyGKUPVI8ry+r6i7PYBBbwPiZBYkhhDLSE D29I58R1CQuHzykPuMcgTdWKzK+lOTpLQ/x6AWlf2KG4ZvY/RP7R/jGjMDMPmsyD8JvC aXaio0Bdd8IcxiroHgy5RWIUv6s8lIH4I+2A0YRzWGUz3jzAn7DomRbFnATC+2lpP4sB yJsA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail2 header.b=j0kb2S3D; spf=pass (google.com: domain of njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org designates 185.70.40.140 as permitted sender) smtp.mailfrom=njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Original-Received: from mail-40140.protonmail.ch (mail-40140.protonmail.ch. [185.70.40.140]) by gmr-mx.google.com with ESMTPS id w21si25035ljd.2.2021.12.09.08.47.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 08:47:35 -0800 (PST) Received-SPF: pass (google.com: domain of njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org designates 185.70.40.140 as permitted sender) client-ip=185.70.40.140; In-Reply-To: <09cc470d-3c03-4d79-bc47-7158080a9413n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail2 header.b=j0kb2S3D; spf=pass (google.com: domain of njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org designates 185.70.40.140 as permitted sender) smtp.mailfrom=njbart-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com X-Original-From: Nick Bart Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:29736 Archived-At: This is a multi-part message in MIME format. --b1_I9QfBiNThsYIUJY0pKiVOUnpekElf6ir1c84tZg Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable AFAIK, pandoc can only insert a placeholder for a ToC into a docx document,= but not create a full ToC itself. The latter requires opening the document in MS Word, LibreOffice or a simil= ar program and updating the ToC manually. (In LibreOffice, the menu command= is Tools > Update > Update All; MS Word instructions are at https://suppor= t.microsoft.com/en-us/office/update-a-table-of-contents-6c727329-d8fd-44fe-= 83b7-fa7fe3d8ac7a.) Updating from the command line is possible, too (at least when using LibreO= ffice [LO]). This involves a macro like the following (which borrows ideas from https://= ask.libreoffice.org/t/how-to-automatically-update-indices-in-headless-mode/= 11878), saved in LO under, e.g., "Standard.Module2.UpdateAllIndexes": ``` sub UpdateAllIndexes(sDocUrl as string) dim oDocument as object dim dispatcher as object dim propExp(0) as new com.sun.star.beans.PropertyValue dim sNewUrl as string Dim FileProperties(1) As New com.sun.star.beans.PropertyValue FileProperties(0).Name =3D "Hidden" FileProperties(0).Value =3D True if fileExists(sDocUrl) then oDocument =3D starDesktop.loadComponentFromUrl(convertToUrl(sDocUrl), "_bla= nk", 0, FileProperties()) dispatcher =3D createUnoService("com.sun.star.frame.DispatchHelper") dispatcher.executeDispatch(oDocument.CurrentController.Frame, ".uno:UpdateA= llIndexes", "", 0, Array()) GlobalScope.BasicLibraries.LoadLibrary("Tools") propExp(0).Name =3D "FilterName" propExp(0).Value =3D "MS Word 2007 XML" sNewUrl =3D GetFileNameWithoutExtension(sDocUrl) & "_updated.docx" oDocument.storeToURL(convertToUrl(sNewUrl), propExp()) end if end sub ``` This macro can then be run from the command line (the following works on ma= cOS): ``` /Applications/LibreOffice.app/Contents/MacOS/soffice --invisible --nofirsts= tartwizard --headless --norestore "macro:///Standard.Module2.UpdateAllIndex= es(/full/path/to/file.docx)" ``` =E2=80=A6 creating a new file `/full/path/to/file_updated.docx`. --=20 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 e= mail 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/I80KhRRTIZtqDS6YtSd0sn82PQLGziJEjj2sjDDddOo_KTaCx9bTm1rY-DJs= xjJSc2ymofEp2QHoQ6hyzN1y46N0No6jor8j_oMBYWEdDjM%3D%40protonmail.com. --b1_I9QfBiNThsYIUJY0pKiVOUnpekElf6ir1c84tZg Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
AFAIK, pandoc can only insert a placeholder for a ToC into a docx docu= ment, but not create a full ToC itself.

The la= tter requires opening the document in MS Word, LibreOffice or a similar pr= ogram and updating the ToC manually. (In LibreOffice, the menu command is T= ools > Update > Update All; MS Word instructions are at https://support.microsoft.com/en-us/office/= update-a-table-of-contents-6c727329-d8fd-44fe-83b7-fa7fe3d8ac7a.)

Updating from the command line is possible, too (at= least when using LibreOffice [LO]).

This invo= lves a macro like the following (which borrows ideas from https://ask.libreoffice.org/t/how-to-automatically-update-indices-= in-headless-mode/11878), saved in LO under, e.g., "Standard.Module2.Upd= ateAllIndexes":

```
sub UpdateAl= lIndexes(sDocUrl as string)

dim oDocument as o= bject
dim dispatcher as object

d= im propExp(0) as new com.sun.star.beans.PropertyValue

dim sNewUrl as string

  Dim FileP= roperties(1) As New com.sun.star.beans.PropertyValue
  F= ileProperties(0).Name =3D "Hidden"
  FileProperties(0).V= alue =3D True
 
if fileExists(sDocUrl) the= n
  oDocument =3D starDesktop.loadComponentFromUrl(conve= rtToUrl(sDocUrl), "_blank", 0, FileProperties())
  dispa= tcher =3D createUnoService("com.sun.star.frame.DispatchHelper")
  dispatcher.executeDispatch(oDocument.CurrentController.Frame, ".u= no:UpdateAllIndexes", "", 0, Array())
  GlobalScope.Basi= cLibraries.LoadLibrary("Tools")
  propExp(0).Name =3D "F= ilterName"
  propExp(0).Value =3D "MS Word 2007 XML"
=
  sNewUrl =3D GetFileNameWithoutExtension(sDocUrl) & "_= updated.docx"
  oDocument.storeToURL(convertToUrl(sNewUr= l), propExp())
end if

end sub
```

This macro can then be run fro= m the command line (the following works on macOS):

```
/Applications/LibreOffice.app/Contents/MacOS/soffice --invisible= --nofirststartwizard --headless --norestore "macro:///Standard.Module2.Upd= ateAllIndexes(/full/path/to/file.docx)"
```
=E2=80=A6 creating a new file `/full/path/to/file_updated.docx`= .


--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msg= id/pandoc-discuss/I80KhRRTIZtqDS6YtSd0sn82PQLGziJEjj2sjDDddOo_KTaCx9bTm1rY-= DJsxjJSc2ymofEp2QHoQ6hyzN1y46N0No6jor8j_oMBYWEdDjM%3D%40protonmail.com.=
--b1_I9QfBiNThsYIUJY0pKiVOUnpekElf6ir1c84tZg--