From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/18620 Path: news.gmane.org!.POSTED!not-for-mail From: Ophir Lifshitz Newsgroups: gmane.text.pandoc Subject: Re: Using YAML variables in docx Date: Sat, 11 Nov 2017 11:30:26 -0800 (PST) Message-ID: <25ab9cfc-04e7-4cca-be75-b77bb4f996bc@googlegroups.com> References: <46936ce3-7335-4071-ab66-88bd60ecdf84@googlegroups.com> <20171101035147.GB19638@Johns-MacBook-Pro.local> <20171101165418.GA9384@protagoras> <5f9a9b31-62b5-47b5-9db7-0a8ab5cae4e3@googlegroups.com> <20171105174028.GC73700@Johns-MacBook-Pro.local> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_5218_1537289633.1510428626965" X-Trace: blaine.gmane.org 1510428631 27584 195.159.176.226 (11 Nov 2017 19:30:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 11 Nov 2017 19:30:31 +0000 (UTC) To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDM4PRVZZYLBBU47TXIAKGQENV5SPGI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Nov 11 20:30:23 2017 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-oi0-f63.google.com ([209.85.218.63]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eDbTx-0006hm-7u for gtp-pandoc-discuss@m.gmane.org; Sat, 11 Nov 2017 20:30:21 +0100 Original-Received: by mail-oi0-f63.google.com with SMTP id r190sf6192562oie.14 for ; Sat, 11 Nov 2017 11:30:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=XId8aVI+pSujSam1KzV2kLlFdU1JK8F7kXqwFe5GO1M=; b=abE2gPbSPH7qzS9NoCBsyP4bxtfqD/NxeMYT0+DCJw5OR7B6xJPGMNYBNH6hrWrWNQ acg1wHUyE/WH/qcSBnVPu7126VI3BHMpLlQQPXJyDDPZYly8+3u9iXOtqufVhODDXj76 l7WqcAK7VHl3psl0uBiiVtxJgAci5I92zw0dhLVqGMqxkquKesuhAWGqK7lPd2S299v/ cl0rqgtXIcEgQ9E028+AuB6pUP9UH1r5Zeevobj0sDjZjwqlcXaUmrgAR7O9R8MF/pWp fPgSLxxLqgRNJASdat7pvJU/nttVqafk3LyDnMIYliG1Bh0HJnYCzoUx2DD6A9my3Zce 48qw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=XId8aVI+pSujSam1KzV2kLlFdU1JK8F7kXqwFe5GO1M=; b=LX90uMppp8sQzPphixjV1HQeEqCVQ3IkSmUhi9E8YkrLwUuoenW2lmZPJ4429y48b2 6j2aqsPqkZxBufbyvxlS58oy6VFl1xJEQCd8ahJfwuJ8F3i3X6Cp/h9BUMWmdc3Drdgi ONPYLlhqv7Y1KnLZNIF1H9Wbcm4wM9f7CqISLbolfm82SvEYQTi3k+flHM3G7SCz4Gsu WHHbcq0fzp7vDvtFDl26rtSV+TJvVAl9Yprsw3CBcIeFC0bqcDnxHq8NFT+6/XYA7EN7 /pOVZe29VbeHiOeDYXFtdGc1OblNDIci3nl9w+NZpilXA9W/+GyCR9A7RHIuzDsk26ku o+qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=XId8aVI+pSujSam1KzV2kLlFdU1JK8F7kXqwFe5GO1M=; b=h2RB+ms8GdeCxIxb8bH4mxtm/IwFdrN5cMYbx+151k1qRnnCvuXA1yCV3HfbkiYoRa 4VwZHA7J1nxM02UgBvj1UAzWwmVtCWlFWUQvCpU7kGKFLGyzCgxLI9Jyz23+/qwLIcyM sCkDsJsQJ3cSBZir/O3G652PKt0T1q7sg7QRZAh/WjB1/neUw/8ZWNu36gM7QdnpiYJb iyogGn3jsrAPPTk6EvCQZT0A9KiYmcDJU4OR9NjhSi3LDDkhT601IPmiSM1UqMRXQxKz BI0gcSofk2ESwOgtt2nf6pmtWXfucVfSzEm2j3LwOppXVHA6zF9T2ht8QirMqOjhy6qt ePUQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJaThX7S1AD5fZeq9bKoVnJ9bHeyzFArB/ccczr8I7USh4NEN0Gqv4bW 5jPrFisVOhAuB251UKYvc5E= X-Google-Smtp-Source: AGs4zMZuz6zMwlIE1MCc/nm2R3RSkEJGux5Sje7zuFhCRPV71I0ytdjVTNYZco/i9LW0EfPOatXnJA== X-Received: by 10.157.3.71 with SMTP id 65mr540397otv.13.1510428628566; Sat, 11 Nov 2017 11:30:28 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.202.225.131 with SMTP id y125ls1817046oig.6.gmail; Sat, 11 Nov 2017 11:30:27 -0800 (PST) X-Received: by 10.157.42.99 with SMTP id t90mr212131ota.5.1510428627365; Sat, 11 Nov 2017 11:30:27 -0800 (PST) In-Reply-To: <20171105174028.GC73700-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org> X-Original-Sender: hangfromthefloor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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.org gmane.text.pandoc:18620 Archived-At: ------=_Part_5218_1537289633.1510428626965 Content-Type: multipart/alternative; boundary="----=_Part_5219_1617987264.1510428626966" ------=_Part_5219_1617987264.1510428626966 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I like this idea as a first iteration of the feature. Will it be difficult= =20 to merge the current "reference docx" system into the full-fledged template= =20 system? I expect most people do not want to manually unzip and edit XML and would= =20 rather edit a template document within Word. It should be possible to trim= =20 the opening and closing empty paragraphs (i.e. detect when a paragraph only= =20 contains a control statement like $for$), or actually manipulate the XML=20 tree. On Sunday, November 5, 2017 at 12:40:27 PM UTC-5, John MacFarlane wrote: > > The simplest idea would be to run the template resolver=20 > on word/document.xml from the reference.docx, to produce=20 > the new word/document.xml from the document body and=20 > metadata values.=20 > > This could work, I think. However, except in simple cases=20 > you'd have to edit word/document.xml with a text editor,=20 > rather than using Word, in order to get the template control=20 > commands in the right place. If you edit with Word, you'll=20 > get things like=20 > > =20 > =20 > $for(author)$=20 > =20 > =20 > =20 > =20 > $author.name$ ($author.institute$)=20 > =20 > =20 > =20 > =20 > $endfor$=20 > =20 > =20 > > which (for two authors) would resolve to:=20 > > =20 > =20 > =20 > > =20 > =20 > =20 > =20 > =20 > Author 1 (Institute 1)=20 > =20 > =20 > =20 > =20 > =20 > =20 > =20 > =20 > =20 > =20 > Author 2 (Institute 2)=20 > =20 > =20 > =20 > =20 > =20 > =20 > =20 > =20 > > This is valid (though I don't know if we can guarantee that=20 > in all cases), but contains a number of empty paragraphs.=20 > > > +++ Ophir Lifshitz [Nov 01 17 22:17 ]:=20 > > It might be useful to replace the limited "reference-doc" system with= =20 > a=20 > > full-fledged template system. Users could then naturally create a=20 > > template as a .docx file=C2=B9 that could include $for$ loops, $varia= ble$=20 > > substitution, and so on as usual.=20 > > ___=20 > > =C2=B9 or .dotx too, I suppose? My knowledge of Word templates is at = least=20 > > 15 years old.=20 > --=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 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/25ab9cfc-04e7-4cca-be75-b77bb4f996bc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_5219_1617987264.1510428626966 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I like this idea as a first iteration of the feature. Will= it be difficult to merge the current "reference docx" system int= o the full-fledged template system?

I expect most people= do not want to=C2=A0manually unzip and edit XML and would rather edit a te= mplate document within Word. It should be possible to trim the opening and = closing empty paragraphs (i.e. detect when a paragraph only contains a cont= rol statement like $for$), or actually manipulate the XML tree.
<= div>
On Sunday, November 5, 2017 at 12:40:27 PM UTC-5, John MacFarlane w= rote:
The simplest idea would b= e to run the template resolver
on word/document.xml from the reference.docx, to produce
the new word/document.xml from the document body and
metadata values.

This could work, I think. =C2=A0However, except in simple cases
you'd have to edit word/document.xml with a text editor,
rather than using Word, in order to get the template control
commands in the right place. =C2=A0If you edit with Word, you'll
get things like

<w:p>
=C2=A0 <w:r>
=C2=A0 =C2=A0 <w:t>$for(author)$</w:t>
=C2=A0 </w:r>
</w:p>
<w:p>
=C2=A0 <w:r>
=C2=A0 =C2=A0 <w:t>$author= .name$ ($author.institute$)</w:t>
=C2=A0 </w:r>
</w:p>
<w:p>
=C2=A0 <w:r>
=C2=A0 =C2=A0 <w:t>$endfor$</w:t>
=C2=A0 </w:r>
</w:p>

which (for two authors) would resolve to:

<w:p>
=C2=A0 <w:r>
=C2=A0 =C2=A0 <w:t>

</w:t>
=C2=A0 </w:r>
</w:p>
<w:p>
=C2=A0 <w:r>
=C2=A0 =C2=A0 <w:t>Author 1 (Institute 1)</w:t>
=C2=A0 </w:r>
</w:p>
<w:p>
=C2=A0 <w:r>
=C2=A0 =C2=A0 <w:t>
</w:t>
=C2=A0 </w:r>
</w:p>
<w:p>
=C2=A0 <w:r>
=C2=A0 =C2=A0 <w:t>Author 2 (Institute 2)</w:t>
=C2=A0 </w:r>
</w:p>
<w:p>
=C2=A0 <w:r>
=C2=A0 =C2=A0 <w:t>
</w:t>
=C2=A0 </w:r>
</w:p>

This is valid (though I don't know if we can guarantee that
in all cases), but contains a number of empty paragraphs.


+++ Ophir Lifshitz [Nov 01 17 22:17 ]:
> =C2=A0 It might be useful to replace the limited "reference-d= oc" system with a
> =C2=A0 full-fledged template system. Users could then naturally cr= eate a
> =C2=A0 template as a .docx file=C2=B9 that could include $for$ loo= ps, $variable$
> =C2=A0 substitution, and so on as usual.
> =C2=A0 ___
> =C2=A0 =C2=B9 or .dotx too, I suppose? My knowledge of Word templa= tes is at least
> =C2=A0 15 years old.

--
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/= msgid/pandoc-discuss/25ab9cfc-04e7-4cca-be75-b77bb4f996bc%40googlegroups.co= m.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_5219_1617987264.1510428626966-- ------=_Part_5218_1537289633.1510428626965--