public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* pandoc custom template condition: looking for variable with certain value (yaml metadata)
@ 2015-03-09  9:44 Jan Kröger
       [not found] ` <3cd16275-1460-4335-be0c-36d9c3b0ca07-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kröger @ 2015-03-09  9:44 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

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+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/3cd16275-1460-4335-be0c-36d9c3b0ca07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: pandoc custom template condition: looking for variable with certain value (yaml metadata)
       [not found] ` <3cd16275-1460-4335-be0c-36d9c3b0ca07-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-03-09 16:05   ` John MacFarlane
       [not found]     ` <20150309160536.GD88189-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: John MacFarlane @ 2015-03-09 16:05 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

+++ Jan Kröger [Mar 09 15 02:44 ]:
>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.

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

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+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/20150309160536.GD88189%40localhost.hsd1.ca.comcast.net.
For more options, visit https://groups.google.com/d/optout.


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

* Re: pandoc custom template condition: looking for variable with certain value (yaml metadata)
       [not found]     ` <20150309160536.GD88189-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
@ 2015-03-10  8:49       ` Jan Kröger
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kröger @ 2015-03-10  8:49 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

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+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/cac085ca-aede-4f76-9f0b-fd32f1e28505%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

end of thread, other threads:[~2015-03-10  8:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09  9:44 pandoc custom template condition: looking for variable with certain value (yaml metadata) Jan Kröger
     [not found] ` <3cd16275-1460-4335-be0c-36d9c3b0ca07-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-09 16:05   ` John MacFarlane
     [not found]     ` <20150309160536.GD88189-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-10  8:49       ` Jan Kröger

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