public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* lua access to metadata variables
@ 2018-02-02 10:32 tolot27
       [not found] ` <ac250ed2-67fb-4fef-aed1-45681b15f48c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: tolot27 @ 2018-02-02 10:32 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi.

I try to access a metadata variable inside a lua filter with pandoc 2.1 but 
find no easy solution to cover the four cases (known to me):


   1. at the command line with: -M key:value
   2. inside a YAML block as a single line: key: value
   3. inside a YAML block printed at a second line with: key: |
   value
   4. inside a YAML block printed at a second line with: key:
     - value


Inside the lua filter I access the variable using meta['key'] but the type 
and content depends on the case.

1. returns a string
2-4. returns a table with:
  2. { [1] = { ["c"] = value,} ,}
  3. { [1] = { [1] = { ["c"] = value,} ,} ,}
  4. { [1] = { ["c"] = { [1] = { ["c"] = value,} ,} ,} ,}

Hence, an increasing nesting. How to easily "unlist" these tables or access 
the key directly? And why is there a table key "c"?

--
Regards,
Mathias

-- 
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/ac250ed2-67fb-4fef-aed1-45681b15f48c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: lua access to metadata variables
       [not found] ` <ac250ed2-67fb-4fef-aed1-45681b15f48c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2018-02-02 10:35   ` tolot27
       [not found]     ` <30a56c18-cfed-46e3-9c62-5bbe38167f0a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: tolot27 @ 2018-02-02 10:35 UTC (permalink / raw)
  To: pandoc-discuss


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

The only thing I want is just to get the value of the key, which should be 
a single value, always.

-- 
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/30a56c18-cfed-46e3-9c62-5bbe38167f0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: lua access to metadata variables
       [not found]     ` <30a56c18-cfed-46e3-9c62-5bbe38167f0a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2018-02-02 20:48       ` Albert Krewinkel
  0 siblings, 0 replies; 3+ messages in thread
From: Albert Krewinkel @ 2018-02-02 20:48 UTC (permalink / raw)
  To: pandoc-discuss

tolot27 <mathias-taBouHiV1h1goHlPtYpdqQ@public.gmane.org> writes:

> The only thing I want is just to get the value of the key, which should be a single value, always.

Your can use `pandoc.utils.stringify` on the meta value.

<https://pandoc.org/lua-filters.html#utils-stringify>

-- 
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


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

end of thread, other threads:[~2018-02-02 20:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-02 10:32 lua access to metadata variables tolot27
     [not found] ` <ac250ed2-67fb-4fef-aed1-45681b15f48c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2018-02-02 10:35   ` tolot27
     [not found]     ` <30a56c18-cfed-46e3-9c62-5bbe38167f0a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2018-02-02 20:48       ` Albert Krewinkel

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