public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Interpolate a value defined in metadata without a template
@ 2022-02-09  1:55 ` Shiwei Weng
       [not found]   ` <986f8e0f-9bf8-44ba-aae9-678315f1da94n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Shiwei Weng @ 2022-02-09  1:55 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi all,

I am new to pandoc. I am trying to render from a markdown file to a html 
file.

I wonder if it's possible to interpolate a field in the metadata e.g. 
if the meta has `foo=MY_FOO` , in the markdown I write `$(foo)` and I hope 
the result html has `MY_FOO` without using a template.

best,
Shiwei

-- 
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/986f8e0f-9bf8-44ba-aae9-678315f1da94n%40googlegroups.com.

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

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

* Re: Interpolate a value defined in metadata without a template
       [not found]   ` <986f8e0f-9bf8-44ba-aae9-678315f1da94n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-02-09  9:13     ` William Lupton
       [not found]       ` <CAEe_xxjkA5yFoxtq7aFfxfxw_88HO1aL46URc1qyr3fdzddudg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: William Lupton @ 2022-02-09  9:13 UTC (permalink / raw)
  To: pandoc-discuss

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

I think this requires a filter. There's a very simple example at
https://pandoc.org/lua-filters.html#macro-substitution (that illustrates
how to expand '{{foo}}') and I have written my own that uses '%foo%'
syntax. I could share an outline of my filter if you like. W.

On Wed, 9 Feb 2022 at 01:55, Shiwei Weng <arbipher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Hi all,
>
> I am new to pandoc. I am trying to render from a markdown file to a html
> file.
>
> I wonder if it's possible to interpolate a field in the metadata e.g.
> if the meta has `foo=MY_FOO` , in the markdown I write `$(foo)` and I hope
> the result html has `MY_FOO` without using a template.
>
> best,
> Shiwei
>
> --
> 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/986f8e0f-9bf8-44ba-aae9-678315f1da94n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/986f8e0f-9bf8-44ba-aae9-678315f1da94n%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/CAEe_xxjkA5yFoxtq7aFfxfxw_88HO1aL46URc1qyr3fdzddudg%40mail.gmail.com.

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

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

* Re: Interpolate a value defined in metadata without a template
       [not found]       ` <CAEe_xxjkA5yFoxtq7aFfxfxw_88HO1aL46URc1qyr3fdzddudg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-02-09  9:19         ` Joost
       [not found]           ` <525b4bf5-4db1-4040-baaf-b4fea3be6a01-jFIJ+Wc5/Vo7lZ9V/NTDHw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Joost @ 2022-02-09  9:19 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On Wed, 9 Feb 2022, at 10:13, William Lupton wrote:
> I think this requires a filter. There's a very simple example at 
> https://pandoc.org/lua-filters.html#macro-substitution (that 
> illustrates how to expand '{{foo}}') and I have written my own that 
> uses '%foo%' syntax. I could share an outline of my filter if you like. 
> W.

FWIW this example filter may be even better:

https://pandoc.org/lua-filters.html#replacing-placeholders-with-their-metadata-value

Since it seems to discuss the OP's exact use case: fill in place holders with information from the metadata.

-- 
Joost Kremers
Life has its moments


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

* Re: Interpolate a value defined in metadata without a template
       [not found]           ` <525b4bf5-4db1-4040-baaf-b4fea3be6a01-jFIJ+Wc5/Vo7lZ9V/NTDHw@public.gmane.org>
@ 2022-02-09  9:35             ` William Lupton
       [not found]               ` <CAEe_xxgk1UD44XHm6CRzHbWuPEcgWdEd+q65XqsLf3AxMJY0Pw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: William Lupton @ 2022-02-09  9:35 UTC (permalink / raw)
  To: pandoc-discuss

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

Oops yes, definitely! I forgot about that one (which is probably what
caused me to use '%' for my filter!). Sorry for the spam...

On Wed, 9 Feb 2022 at 09:20, Joost <joostkremers-97jfqw80gc6171pxa8y+qA@public.gmane.org> wrote:

> On Wed, 9 Feb 2022, at 10:13, William Lupton wrote:
> > I think this requires a filter. There's a very simple example at
> > https://pandoc.org/lua-filters.html#macro-substitution (that
> > illustrates how to expand '{{foo}}') and I have written my own that
> > uses '%foo%' syntax. I could share an outline of my filter if you like.
> > W.
>
> FWIW this example filter may be even better:
>
>
> https://pandoc.org/lua-filters.html#replacing-placeholders-with-their-metadata-value
>
> Since it seems to discuss the OP's exact use case: fill in place holders
> with information from the metadata.
>
> --
> Joost Kremers
> Life has its moments
>
> --
> 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/525b4bf5-4db1-4040-baaf-b4fea3be6a01%40www.fastmail.com
> .
>

-- 
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/CAEe_xxgk1UD44XHm6CRzHbWuPEcgWdEd%2Bq65XqsLf3AxMJY0Pw%40mail.gmail.com.

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

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

* Re: Interpolate a value defined in metadata without a template
       [not found]               ` <CAEe_xxgk1UD44XHm6CRzHbWuPEcgWdEd+q65XqsLf3AxMJY0Pw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-02-09 14:46                 ` Shiwei Weng
       [not found]                   ` <c8c01eae-a15d-45fd-bf60-ccfe266994f2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Shiwei Weng @ 2022-02-09 14:46 UTC (permalink / raw)
  To: pandoc-discuss


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

Thank you all. I will try it later.

I thought the pandoc was similar to Jekyll that I could do templating 
things in the input markdown (and having both HTML and pdf results).
Now I see it.

It seems I may also need lua-filter's helps if I would do loop for lists in 
meta block e.g. ${foo (list-in-meta)} 
<https://pandoc.org/MANUAL.html#for-loops> .



On Wednesday, February 9, 2022 at 4:36:02 AM UTC-5 William Lupton wrote:

> Oops yes, definitely! I forgot about that one (which is probably what 
> caused me to use '%' for my filter!). Sorry for the spam...
>
> On Wed, 9 Feb 2022 at 09:20, Joost <joostk...-97jfqw80gc6171pxa8y+qA@public.gmane.org> wrote:
>
>> On Wed, 9 Feb 2022, at 10:13, William Lupton wrote:
>> > I think this requires a filter. There's a very simple example at 
>> > https://pandoc.org/lua-filters.html#macro-substitution (that 
>> > illustrates how to expand '{{foo}}') and I have written my own that 
>> > uses '%foo%' syntax. I could share an outline of my filter if you like. 
>> > W.
>>
>> FWIW this example filter may be even better:
>>
>>
>> https://pandoc.org/lua-filters.html#replacing-placeholders-with-their-metadata-value
>>
>> Since it seems to discuss the OP's exact use case: fill in place holders 
>> with information from the metadata.
>>
>> -- 
>> Joost Kremers
>> Life has its moments
>>
>> -- 
>> 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/525b4bf5-4db1-4040-baaf-b4fea3be6a01%40www.fastmail.com
>> .
>>
>

-- 
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/c8c01eae-a15d-45fd-bf60-ccfe266994f2n%40googlegroups.com.

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

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

* AW: Interpolate a value defined in metadata without a template
       [not found]                   ` <c8c01eae-a15d-45fd-bf60-ccfe266994f2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-02-09 14:49                     ` denis.maier-NSENcxR/0n0
       [not found]                       ` <6616f42d3fcc49ba8b0f50b037603bd3-NSENcxR/0n0@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2022-02-09 14:49 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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


Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Shiwei Weng
Gesendet: Mittwoch, 9. Februar 2022 15:47
An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Re: Interpolate a value defined in metadata without a template

Thank you all. I will try it later.

I thought the pandoc was similar to Jekyll that I could do templating things in the input markdown (and having both HTML and pdf results).
Now I see it.



There are also preprocessors that do such things.

Denis

-- 
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/6616f42d3fcc49ba8b0f50b037603bd3%40unibe.ch.

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

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

* Re: Interpolate a value defined in metadata without a template
       [not found]                       ` <6616f42d3fcc49ba8b0f50b037603bd3-NSENcxR/0n0@public.gmane.org>
@ 2022-02-09 15:06                         ` Shiwei Weng
  0 siblings, 0 replies; 7+ messages in thread
From: Shiwei Weng @ 2022-02-09 15:06 UTC (permalink / raw)
  To: pandoc-discuss


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

I found this discussed in one github 
[issue](https://github.com/jgm/pandoc/issues/1950#issuecomment-74613325) 
with the example provided by jgm

```shell
% pandoc my.md --template my.md | pandoc -t html
<p>Hello world.</p>
```

On Wednesday, February 9, 2022 at 9:49:32 AM UTC-5 denis...-NSENcxR/0n0@public.gmane.org wrote:

>  
>
> *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> *Im 
> Auftrag von *Shiwei Weng
> *Gesendet:* Mittwoch, 9. Februar 2022 15:47
> *An:* pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> *Betreff:* Re: Interpolate a value defined in metadata without a template
>
>  
>
> Thank you all. I will try it later.
>
> I thought the pandoc was similar to Jekyll that I could do templating 
> things in the input markdown (and having both HTML and pdf results).
>
> Now I see it.
>
>  
>
>  
>
>  
>
> There are also preprocessors that do such things. 
>
>  
>
> Denis
>

-- 
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/8fb7b5dc-5ef8-4ac4-b3d3-d9c216a4095dn%40googlegroups.com.

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

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

end of thread, other threads:[~2022-02-09 15:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <AQHYHVgud3W2GHIs10iUFNi6wRG666yK3yAAgAABzACAAAR1gIAAVtcAgAARTiA=>
2022-02-09  1:55 ` Interpolate a value defined in metadata without a template Shiwei Weng
     [not found]   ` <986f8e0f-9bf8-44ba-aae9-678315f1da94n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-02-09  9:13     ` William Lupton
     [not found]       ` <CAEe_xxjkA5yFoxtq7aFfxfxw_88HO1aL46URc1qyr3fdzddudg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-02-09  9:19         ` Joost
     [not found]           ` <525b4bf5-4db1-4040-baaf-b4fea3be6a01-jFIJ+Wc5/Vo7lZ9V/NTDHw@public.gmane.org>
2022-02-09  9:35             ` William Lupton
     [not found]               ` <CAEe_xxgk1UD44XHm6CRzHbWuPEcgWdEd+q65XqsLf3AxMJY0Pw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-02-09 14:46                 ` Shiwei Weng
     [not found]                   ` <c8c01eae-a15d-45fd-bf60-ccfe266994f2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-02-09 14:49                     ` AW: " denis.maier-NSENcxR/0n0
     [not found]                       ` <6616f42d3fcc49ba8b0f50b037603bd3-NSENcxR/0n0@public.gmane.org>
2022-02-09 15:06                         ` Shiwei Weng

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