Discussion:
pandoc custom template condition: looking for variable with certain value (yaml metadata)
Jan Kröger
2015-03-09 09:44:47 UTC
Permalink
Hi,

as long as I understood, it is possible to set a pandoc template condition
which asks if a variable's value is not zero.
But want I need is to create a condition which asks for a variable with a
certain value.
Is that possible?

An example: I want pandoc to write some yaml metadata (contributors names)
to the epub's titlepage to give the different contributors their
credentials (put a label in front of the name).

I have set them in yaml metadata block like:
contributor:
- role: edt
text: Person1
- role: pfr
text: Person2
- role: pht
text: Person3
- role: trl
text:

What works is a simple list of different contributors, set in my custom
template:
$for(contributor)$
$contributor.text$$sep$,
$endfor$

so with:
pandoc metadata.yaml book-content.md -t epub3 -o book.epub

I got a list of all contributors written to the title page:
Person1, Person2, Person3

But what I want instead is this:
Editor: Person1
Proofreader: Person2
Photographer: Person3

So what I am missing is the possibility to set e.g.:
$for(contributor)$
$if(contributor.role)==edt$
<p>Editor: $contributor.text$</p>
$endif$
$if(contributor.role)==pfr$
<p>Proofreader: $contributor.text$</p>
$endif$
$if(contributor.role)==pht$
<p>Photographer: $contributor.text$</p>
$endif$
$endfor$
(Which can't work because it seems this syntax is not implemented.)

How can that be done as long as I use standard conform yaml metadata? I use
latest pandoc 1.13.2.
--
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+***@googlegroups.com.
To post to this group, send email to pandoc-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/3cd16275-1460-4335-be0c-36d9c3b0ca07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
John MacFarlane
2015-03-09 16:05:36 UTC
Permalink
Post by Jan Kröger
Hi,
as long as I understood, it is possible to set a pandoc template condition
which asks if a variable's value is not zero.
But want I need is to create a condition which asks for a variable with a
certain value.
Is that possible?
No.
Post by Jan Kröger
An example: I want pandoc to write some yaml metadata (contributors names)
to the epub's titlepage to give the different contributors their
credentials (put a label in front of the name).
- role: edt
text: Person1
- role: pfr
text: Person2
- role: pht
text: Person3
- role: trl
What works is a simple list of different contributors, set in my custom
$for(contributor)$
$contributor.text$$sep$,
$endfor$
pandoc metadata.yaml book-content.md -t epub3 -o book.epub
Person1, Person2, Person3
Editor: Person1
Proofreader: Person2
Photographer: Person3
$for(contributor)$
$if(contributor.role)==edt$
<p>Editor: $contributor.text$</p>
$endif$
$if(contributor.role)==pfr$
<p>Proofreader: $contributor.text$</p>
$endif$
$if(contributor.role)==pht$
<p>Photographer: $contributor.text$</p>
$endif$
$endfor$
(Which can't work because it seems this syntax is not implemented.)
How can that be done as long as I use standard conform yaml metadata? I use
latest pandoc 1.13.2.
Two possibilities. 1) Just use the word "Editor" instead of "edt" in
your metadata. 2) Create a filter that modifies these metadata fields,
changing "edt" to "Editor" etc.
--
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+***@googlegroups.com.
To post to this group, send email to pandoc-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20150309160536.GD88189%40localhost.hsd1.ca.comcast.net.
For more options, visit https://groups.google.com/d/optout.
Jan Kröger
2015-03-10 08:49:10 UTC
Permalink
Will try. Thnx, John!
--
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+***@googlegroups.com.
To post to this group, send email to pandoc-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/cac085ca-aede-4f76-9f0b-fd32f1e28505%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...