public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Use -V on command line to select from YAML structure?
@ 2020-02-07 21:37 Martin Post
       [not found] ` <8ae56d51-dbe6-44cb-9bb0-e875f636730b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Post @ 2020-02-07 21:37 UTC (permalink / raw)
  To: pandoc-discuss


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

I’d like to do this:

In “source.md”:

---
myvar:
- foo: 123
- bar: 789
---

On the command line:

pandoc -s --template template.htm source.md -o target.htm -V subvar=bar

Is it possible to have “template.htm” display the content of myvar.[subvar] 
as passed from the command line– i.e. in this example, the content of 
myvar.bar (“789”)?

I tried these, which aren’t working:

$for(myvar)$ $myvar$.$subvar$ $endfor$

$for(myvar)$ $myvar.subvar$ $endfor$

Thank you.

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8ae56d51-dbe6-44cb-9bb0-e875f636730b%40googlegroups.com.

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

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

* Re: Use -V on command line to select from YAML structure?
       [not found] ` <8ae56d51-dbe6-44cb-9bb0-e875f636730b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-02-08  8:54   ` BPJ
       [not found]     ` <CADAJKhBnhvNr_tKoFMnyCO2ZpgsAJqSVkq=EG8hEjxYRfjCbXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: BPJ @ 2020-02-08  8:54 UTC (permalink / raw)
  To: pandoc-discuss

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

Use `-M foo` (*M*etadata) rather than `-V` (*V*ariable).

Den fre 7 feb. 2020 22:38Martin Post <martinpostberlin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> I’d like to do this:
>
> In “source.md”:
>
> ---
> myvar:
> - foo: 123
> - bar: 789
> ---
>
> On the command line:
>
> pandoc -s --template template.htm source.md -o target.htm -V subvar=bar
>
> Is it possible to have “template.htm” display the content of
> myvar.[subvar] as passed from the command line– i.e. in this example, the
> content of myvar.bar (“789”)?
>
> I tried these, which aren’t working:
>
> $for(myvar)$ $myvar$.$subvar$ $endfor$
>
> $for(myvar)$ $myvar.subvar$ $endfor$
>
> Thank you.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/8ae56d51-dbe6-44cb-9bb0-e875f636730b%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/8ae56d51-dbe6-44cb-9bb0-e875f636730b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBnhvNr_tKoFMnyCO2ZpgsAJqSVkq%3DEG8hEjxYRfjCbXA%40mail.gmail.com.

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

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

* Re: Use -V on command line to select from YAML structure?
       [not found]     ` <CADAJKhBnhvNr_tKoFMnyCO2ZpgsAJqSVkq=EG8hEjxYRfjCbXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-02-08  9:57       ` Martin Post
       [not found]         ` <fc91b010-a16e-4326-9a24-7749301b6607-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Post @ 2020-02-08  9:57 UTC (permalink / raw)
  To: pandoc-discuss


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


Thank you, BPJ, but I don’t understand (yet) how to apply this.

When I run pandoc […] -M subvar=foo , I’d like the target document to show 
“123” (myvar.foo).
When I run pandoc […] -M subvar=bar , it should show “789” (myvar.bar).
 
How would I set up my template to achieve this?

Thanks again.


On Saturday, February 8, 2020 at 9:55:03 AM UTC+1, BPJ wrote:
>
> Use `-M foo` (*M*etadata) rather than `-V` (*V*ariable).
>
> Den fre 7 feb. 2020 22:38Martin Post <martinpo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 
> skrev:
>
>> I’d like to do this:
>>
>> In “source.md”:
>>
>> ---
>> myvar:
>> - foo: 123
>> - bar: 789
>> ---
>>
>> On the command line:
>>
>> pandoc -s --template template.htm source.md -o target.htm -V subvar=bar
>>
>> Is it possible to have “template.htm” display the content of 
>> myvar.[subvar] as passed from the command line– i.e. in this example, the 
>> content of myvar.bar (“789”)?
>>
>> I tried these, which aren’t working:
>>
>> $for(myvar)$ $myvar$.$subvar$ $endfor$
>>
>> $for(myvar)$ $myvar.subvar$ $endfor$
>>
>> Thank you.
>>
>> -- 
>> 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/8ae56d51-dbe6-44cb-9bb0-e875f636730b%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/8ae56d51-dbe6-44cb-9bb0-e875f636730b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/fc91b010-a16e-4326-9a24-7749301b6607%40googlegroups.com.

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

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

* Re: Use -V on command line to select from YAML structure?
       [not found]         ` <fc91b010-a16e-4326-9a24-7749301b6607-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-02-08 21:11           ` BPJ
  2020-02-09  6:48           ` Dmitriy Krasilnikov
  1 sibling, 0 replies; 5+ messages in thread
From: BPJ @ 2020-02-08 21:11 UTC (permalink / raw)
  To: pandoc-discuss

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

You mean like `${!foo}` in bash?
That's not possible as far as I know.  The only difference between `-V` and
`-M` is that the latter are available in the document metadata (lso that
e.g. filters can get at the value or metadata values set in the document
are overridden. From the perspective of a template `-V foo=bar` and `-M
foo=bar` are the same: a `$foo$` in the template gets replaced with "bar".
That's really all there is to it.  The only perks are

1. If you repeat the same key the value becomes an array, so that a
template can loop over it with `$for(foo)$`.

2. `foo=true` and `foo=false` become real booleans.

3. `-V foo`/`-M foo` are equivalent to `-V foo=true` and `-M foo=true`.



Den lör 8 feb. 2020 10:58Martin Post <martinpostberlin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

>
> Thank you, BPJ, but I don’t understand (yet) how to apply this.
>
> When I run pandoc […] -M subvar=foo , I’d like the target document to show
> “123” (myvar.foo).
> When I run pandoc […] -M subvar=bar , it should show “789” (myvar.bar).
>
> How would I set up my template to achieve this?
>
> Thanks again.
>
>
> On Saturday, February 8, 2020 at 9:55:03 AM UTC+1, BPJ wrote:
>>
>> Use `-M foo` (*M*etadata) rather than `-V` (*V*ariable).
>>
>> Den fre 7 feb. 2020 22:38Martin Post <martinpo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>
>>> I’d like to do this:
>>>
>>> In “source.md”:
>>>
>>> ---
>>> myvar:
>>> - foo: 123
>>> - bar: 789
>>> ---
>>>
>>> On the command line:
>>>
>>> pandoc -s --template template.htm source.md -o target.htm -V subvar=bar
>>>
>>> Is it possible to have “template.htm” display the content of
>>> myvar.[subvar] as passed from the command line– i.e. in this example, the
>>> content of myvar.bar (“789”)?
>>>
>>> I tried these, which aren’t working:
>>>
>>> $for(myvar)$ $myvar$.$subvar$ $endfor$
>>>
>>> $for(myvar)$ $myvar.subvar$ $endfor$
>>>
>>> Thank you.
>>>
>>> --
>>> 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-...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pandoc-discuss/8ae56d51-dbe6-44cb-9bb0-e875f636730b%40googlegroups.com
>>> <https://groups.google.com/d/msgid/pandoc-discuss/8ae56d51-dbe6-44cb-9bb0-e875f636730b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/fc91b010-a16e-4326-9a24-7749301b6607%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/fc91b010-a16e-4326-9a24-7749301b6607%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhCYcP3naTO%3DDD-zEL7MrUcj5PDvKt0o7%3D1yP3DzHTV0CQ%40mail.gmail.com.

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

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

* Re: Use -V on command line to select from YAML structure?
       [not found]         ` <fc91b010-a16e-4326-9a24-7749301b6607-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-02-08 21:11           ` BPJ
@ 2020-02-09  6:48           ` Dmitriy Krasilnikov
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitriy Krasilnikov @ 2020-02-09  6:48 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Use PP (pandoc preprocessor).

сб, 8 февр. 2020 г. в 12:57, Martin Post <martinpostberlin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:

>
> Thank you, BPJ, but I don’t understand (yet) how to apply this.
>
> When I run pandoc […] -M subvar=foo , I’d like the target document to show
> “123” (myvar.foo).
> When I run pandoc […] -M subvar=bar , it should show “789” (myvar.bar).
>
> How would I set up my template to achieve this?
>
> Thanks again.
>
>
> On Saturday, February 8, 2020 at 9:55:03 AM UTC+1, BPJ wrote:
>>
>> Use `-M foo` (*M*etadata) rather than `-V` (*V*ariable).
>>
>> Den fre 7 feb. 2020 22:38Martin Post <martinpo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>
>>> I’d like to do this:
>>>
>>> In “source.md”:
>>>
>>> ---
>>> myvar:
>>> - foo: 123
>>> - bar: 789
>>> ---
>>>
>>> On the command line:
>>>
>>> pandoc -s --template template.htm source.md -o target.htm -V subvar=bar
>>>
>>> Is it possible to have “template.htm” display the content of
>>> myvar.[subvar] as passed from the command line– i.e. in this example, the
>>> content of myvar.bar (“789”)?
>>>
>>> I tried these, which aren’t working:
>>>
>>> $for(myvar)$ $myvar$.$subvar$ $endfor$
>>>
>>> $for(myvar)$ $myvar.subvar$ $endfor$
>>>
>>> Thank you.
>>>
>>> --
>>> 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-...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pandoc-discuss/8ae56d51-dbe6-44cb-9bb0-e875f636730b%40googlegroups.com
>>> <https://groups.google.com/d/msgid/pandoc-discuss/8ae56d51-dbe6-44cb-9bb0-e875f636730b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/fc91b010-a16e-4326-9a24-7749301b6607%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/fc91b010-a16e-4326-9a24-7749301b6607%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CALZUCcACoWHx4B8NargwhxzwpgiOX5bms1D2jhv1Orh2cQP3-g%40mail.gmail.com.

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

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

end of thread, other threads:[~2020-02-09  6:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 21:37 Use -V on command line to select from YAML structure? Martin Post
     [not found] ` <8ae56d51-dbe6-44cb-9bb0-e875f636730b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-02-08  8:54   ` BPJ
     [not found]     ` <CADAJKhBnhvNr_tKoFMnyCO2ZpgsAJqSVkq=EG8hEjxYRfjCbXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-02-08  9:57       ` Martin Post
     [not found]         ` <fc91b010-a16e-4326-9a24-7749301b6607-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-02-08 21:11           ` BPJ
2020-02-09  6:48           ` Dmitriy Krasilnikov

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