public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Using YAML variables in docx
Date: Sun, 5 Nov 2017 09:40:28 -0800	[thread overview]
Message-ID: <20171105174028.GC73700@Johns-MacBook-Pro.local> (raw)
In-Reply-To: <5f9a9b31-62b5-47b5-9db7-0a8ab5cae4e3-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

The simplest idea would be 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.  However, 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.  If you edit with Word, you'll
get things like

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

which (for two authors) would resolve to:

<w:p>
  <w:r>
    <w:t>

</w:t>
  </w:r>
</w:p>
<w:p>
  <w:r>
    <w:t>Author 1 (Institute 1)</w:t>
  </w:r>
</w:p>
<w:p>
  <w:r>
    <w:t>
</w:t>
  </w:r>
</w:p>
<w:p>
  <w:r>
    <w:t>Author 2 (Institute 2)</w:t>
  </w:r>
</w:p>
<w:p>
  <w:r>
    <w:t>
</w:t>
  </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 ]:
>   It might be useful to replace the limited "reference-doc" system with a
>   full-fledged template system. Users could then naturally create a
>   template as a .docx file¹ that could include $for$ loops, $variable$
>   substitution, and so on as usual.
>   ___
>   ¹ or .dotx too, I suppose? My knowledge of Word templates is at least
>   15 years old.

-- 
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 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/20171105174028.GC73700%40Johns-MacBook-Pro.local.
For more options, visit https://groups.google.com/d/optout.


  parent reply	other threads:[~2017-11-05 17:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01  1:18 'Adam Mackie' via pandoc-discuss
     [not found] ` <46936ce3-7335-4071-ab66-88bd60ecdf84-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-01  3:51   ` John MacFarlane
     [not found]     ` <20171101035147.GB19638-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2017-11-01 12:57       ` 'Adam Mackie' via pandoc-discuss
     [not found]         ` <edfcc38c-eb20-400f-822a-2c2f1231141c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-01 16:54           ` John MACFARLANE
2017-11-01 17:05             ` 'Adam Mackie' via pandoc-discuss
     [not found]               ` <eb861fe9-af97-4e32-bc6c-75662e0846a4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-01 17:14                 ` John MACFARLANE
2017-11-01 21:40                 ` Agustín Martín
     [not found]                   ` <b6259169-dba5-4aa7-9154-1816c021ce99-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-01 22:05                     ` 'Adam Mackie' via pandoc-discuss
     [not found]                       ` <caa2d23a-8956-4660-abb7-09835f3edc44-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-02  5:17                         ` Ophir Lifshitz
     [not found]                           ` <5f9a9b31-62b5-47b5-9db7-0a8ab5cae4e3-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-11-05 16:28                             ` 'Adam Mackie' via pandoc-discuss
2017-11-05 17:40                             ` John MacFarlane [this message]
     [not found]                               ` <20171105174028.GC73700-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2017-11-07 21:54                                 ` BP Jonsson
2017-11-11 19:30                                 ` Ophir Lifshitz

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=20171105174028.GC73700@Johns-MacBook-Pro.local \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@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).