public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Using YAML variables in docx
@ 2017-11-01  1:18 'Adam Mackie' via pandoc-discuss
       [not found] ` <46936ce3-7335-4071-ab66-88bd60ecdf84-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: 'Adam Mackie' via pandoc-discuss @ 2017-11-01  1:18 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]

Hey folks,

Is there a straightforward way to use YAML-defined variables in my docx files? 

I generate docx files from markdown with headers and footers taken from a reference.docx. These headers always contain some document properties like "Title", "Revision" etc. Is there ANY way to get these to flow through from my YAML metadata?

I have looked through the readme and understand that reference.docx files are not like templates, so they're only intended to carry over document styles. I am also aware you can define "filters" for pandoc, but am unsure what they do for you or if they could be leveraged to solve this problem.

Just looking for ideas tbh, it's possible I've missed something somewhere, although I've poured over the readme/pandoc-discuss and gotten nowhere haha.

Cheers,
Adam

-- 
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/46936ce3-7335-4071-ab66-88bd60ecdf84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [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>
  0 siblings, 1 reply; 13+ messages in thread
From: John MacFarlane @ 2017-11-01  3:51 UTC (permalink / raw)
  To: 'Adam Mackie' via pandoc-discuss

Title and author and keywords defined in YAML blocks should
go into your document properties.  (Make sure you're using
the latest pandoc.)

Filters can't add things to the docx properties.
But they can add things to the body of the document.
You'd have to use specially labeled spans or something
in the document as placeholders. Then the filter could
replace these with values taken from the metadata.

+++ 'Adam Mackie' via pandoc-discuss [Oct 31 17 18:18 ]:
>Hey folks,
>
>Is there a straightforward way to use YAML-defined variables in my docx files?
>
>I generate docx files from markdown with headers and footers taken from a reference.docx. These headers always contain some document properties like "Title", "Revision" etc. Is there ANY way to get these to flow through from my YAML metadata?
>
>I have looked through the readme and understand that reference.docx files are not like templates, so they're only intended to carry over document styles. I am also aware you can define "filters" for pandoc, but am unsure what they do for you or if they could be leveraged to solve this problem.
>
>Just looking for ideas tbh, it's possible I've missed something somewhere, although I've poured over the readme/pandoc-discuss and gotten nowhere haha.
>
>Cheers,
>Adam
>
>-- 
>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/46936ce3-7335-4071-ab66-88bd60ecdf84%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [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>
  0 siblings, 1 reply; 13+ messages in thread
From: 'Adam Mackie' via pandoc-discuss @ 2017-11-01 12:57 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 241 bytes --]

Thanks for the reply.

Will I be able to use this method to alter the headers and footers provided by the reference.docx? I'm playing around with filters just now and it looks like they get applied BEFORE the reference.docx...

Cheers,
Adam

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [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
  0 siblings, 1 reply; 13+ messages in thread
From: John MACFARLANE @ 2017-11-01 16:54 UTC (permalink / raw)
  To: 'Adam Mackie' via pandoc-discuss

Yes, correct.  Filters can't modify the header or footer,
that's taken from the reference.docx.

+++ 'Adam Mackie' via pandoc-discuss [Nov 01 17 05:57 ]:
>Thanks for the reply.
>
>Will I be able to use this method to alter the headers and footers provided by the reference.docx? I'm playing around with filters just now and it looks like they get applied BEFORE the reference.docx...
>
>Cheers,
>Adam
>
>-- 
>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/edfcc38c-eb20-400f-822a-2c2f1231141c%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
  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>
  0 siblings, 1 reply; 13+ messages in thread
From: 'Adam Mackie' via pandoc-discuss @ 2017-11-01 17:05 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]

So is there any way to accomplish what I want? I.e. have a file in markdown, convert it to docx, apply reference headers and then finally MODIFY the headers to have custom values as defined in a YAML block? So far it seems like I can do everything up to the last step.

I take it I couldn't do say, two passes, where I first apply the reference docx and THEN use a filter to alter the headers? Or am I right in saying the headers will get stripped off even if going from docx to docx...

-- 
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/eb861fe9-af97-4e32-bc6c-75662e0846a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [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
  1 sibling, 0 replies; 13+ messages in thread
From: John MACFARLANE @ 2017-11-01 17:14 UTC (permalink / raw)
  To: 'Adam Mackie' via pandoc-discuss

No easy way to do this.  You could extract information from
your markdown file programatically (using pandoc's API or
a filter) and then postprocess the docx file itself.  Not
pretty.

+++ 'Adam Mackie' via pandoc-discuss [Nov 01 17 10:05 ]:
>So is there any way to accomplish what I want? I.e. have a file in markdown, convert it to docx, apply reference headers and then finally MODIFY the headers to have custom values as defined in a YAML block? So far it seems like I can do everything up to the last step.
>
>I take it I couldn't do say, two passes, where I first apply the reference docx and THEN use a filter to alter the headers? Or am I right in saying the headers will get stripped off even if going from docx to docx...
>
>-- 
>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/eb861fe9-af97-4e32-bc6c-75662e0846a4%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

-- 
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/20171101171417.GA12087%40protagoras.
For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [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>
  1 sibling, 1 reply; 13+ messages in thread
From: Agustín Martín @ 2017-11-01 21:40 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1329 bytes --]

For certain standard properties (title, author...) it is already working.
Not in a general way for custom properties though.

Check https://github.com/jgm/pandoc/issues/3034

On Wednesday, November 1, 2017 at 6:05:20 PM UTC+1, Adam Mackie wrote:
>
> So is there any way to accomplish what I want? I.e. have a file in 
> markdown, convert it to docx, apply reference headers and then finally 
> MODIFY the headers to have custom values as defined in a YAML block? So far 
> it seems like I can do everything up to the last step.
>
> I take it I couldn't do say, two passes, where I first apply the reference 
> docx and THEN use a filter to alter the headers? Or am I right in saying 
> the headers will get stripped off even if going from docx to docx...
>

-- 
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/b6259169-dba5-4aa7-9154-1816c021ce99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1895 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [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>
  0 siblings, 1 reply; 13+ messages in thread
From: 'Adam Mackie' via pandoc-discuss @ 2017-11-01 22:05 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 300 bytes --]

To be honest, I sort of suspected this was not possible (well, easy). Maybe I can figure out a way to get the custom variables into the custom.xml file? I'll play around with that and see if I get anywhere.

I hope the custom properties make their way into pandoc at some point. Cheers for you help!

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [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>
  0 siblings, 1 reply; 13+ messages in thread
From: Ophir Lifshitz @ 2017-11-02  5:17 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 923 bytes --]

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/5f9a9b31-62b5-47b5-9db7-0a8ab5cae4e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1365 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [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
  1 sibling, 0 replies; 13+ messages in thread
From: 'Adam Mackie' via pandoc-discuss @ 2017-11-05 16:28 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

At a minimum it would be useful to have YAML variables added as Custom Document Properties. I could do pretty much anything I want to if that feature existed. Docx seems to be a bit of a nightmare however, so that might be easier said than done. 

I'm curious how high a priority this is? I can see that new document properties (keywords) were added in 2.0 for docx.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [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
       [not found]                               ` <20171105174028.GC73700-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
  1 sibling, 1 reply; 13+ messages in thread
From: John MacFarlane @ 2017-11-05 17:40 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [not found]                               ` <20171105174028.GC73700-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
@ 2017-11-07 21:54                                 ` BP Jonsson
  2017-11-11 19:30                                 ` Ophir Lifshitz
  1 sibling, 0 replies; 13+ messages in thread
From: BP Jonsson @ 2017-11-07 21:54 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 3458 bytes --]

I haven't used Word in over a decade, so I don't know what builtin
scripting capabilities it has nowadays, but my thought is that you might
have a filter insert certain metadata values as custom styled paragraphs at
the end of the document body and then use python-docx to pull out the
(contents of) those paragraphs and insert them into the header/footer (of
each section seemingly to judge by <
http://python-docx.readthedocs.io/en/latest/dev/analysis/features/header.html
>).

Just my two worthless coins.

Den 5 nov 2017 18:40 skrev "John MacFarlane" <jgm-TVLZxgkOlNX2fBVCVOL8/A@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/ms
> gid/pandoc-discuss/20171105174028.GC73700%40Johns-MacBook-Pro.local.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAFC_yuTZRE6grnVvWkCbbjDGAQ3NPWY0Ee52SrQ2-P7aUNpNrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 5395 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using YAML variables in docx
       [not found]                               ` <20171105174028.GC73700-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
  2017-11-07 21:54                                 ` BP Jonsson
@ 2017-11-11 19:30                                 ` Ophir Lifshitz
  1 sibling, 0 replies; 13+ messages in thread
From: Ophir Lifshitz @ 2017-11-11 19:30 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 2884 bytes --]

I like this idea as a first iteration of the feature. Will it be difficult 
to merge the current "reference docx" system into the full-fledged template 
system?

I expect most people do not want to manually unzip and edit XML and would 
rather edit a template document within Word. It should be possible to trim 
the opening and closing empty paragraphs (i.e. detect when a paragraph only 
contains a control statement like $for$), or actually manipulate the XML 
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 
> 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/25ab9cfc-04e7-4cca-be75-b77bb4f996bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 4313 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-11-11 19:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-01  1:18 Using YAML variables in docx '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
     [not found]                               ` <20171105174028.GC73700-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2017-11-07 21:54                                 ` BP Jonsson
2017-11-11 19:30                                 ` Ophir Lifshitz

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).