public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* extract yaml to json with pandoc
@ 2020-12-07 18:03 enz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found] ` <321e4555-d464-4db8-a18e-0282ac1b5567n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: enz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-12-07 18:03 UTC (permalink / raw)
  To: pandoc-discuss


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

I have a set of markdown files. At the top of each file I have some 
metadata in yaml. I want to extract the yaml information and the file name 
to a combined json file for all the markdown files. I found a solution (I 
think) with this plugin:

https://github.com/jrainlau/extract-yaml-from-markdown-plugin

But I was wondering if Pandoc itself can't do the job? I'm not a true 
developer, so scripting is not my cup of tea. But it does seam so straight 
forward. Just have all the information at one place and then generate a set 
of html pages  and a combined json file.  Any suggestions?

-- 
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/321e4555-d464-4db8-a18e-0282ac1b5567n%40googlegroups.com.

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

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

* Re: extract yaml to json with pandoc
       [not found] ` <321e4555-d464-4db8-a18e-0282ac1b5567n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-12-07 18:36   ` John MacFarlane
       [not found]     ` <m2mtypjwed.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: John MacFarlane @ 2020-12-07 18:36 UTC (permalink / raw)
  To: enz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, pandoc-discuss


Easiest way is to create a custom template with the meta-json
variable.

If your output format is HTML, create meta.html containing just

$meta-json$

Then:  pandoc --template meta your-input.md


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

* Re: extract yaml to json with pandoc
       [not found]     ` <m2mtypjwed.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2020-12-09 11:04       ` enz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found]         ` <7df8deff-9f5e-49dc-83e8-8296f01967a6n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: enz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-12-09 11:04 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks for your quick reply. For the json part, it works fine. But is there 
a way to also get the filename as part of the json? Or at least on top of 
each json file, so I can easily merge the json with the corresponding 
filename. Right now  I have: 

"file": "$sourcefile$"
$meta-json$

But when I pass all files in the directory, it gives me a list of files and 
after that all the json. I like to get: filename + json, filename + json + 
etc.
In the ideal world: the filename would already be part of the json, but I 
read somewhere that yaml itself doesn't support the filename option.

Hope it makes sense what I want to achieve.
On Monday, December 7, 2020 at 7:36:59 PM UTC+1 John MacFarlane wrote:

>
> Easiest way is to create a custom template with the meta-json
> variable.
>
> If your output format is HTML, create meta.html containing just
>
> $meta-json$
>
> Then: pandoc --template meta your-input.md
>
>

-- 
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/7df8deff-9f5e-49dc-83e8-8296f01967a6n%40googlegroups.com.

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

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

* Re: extract yaml to json with pandoc
       [not found]         ` <7df8deff-9f5e-49dc-83e8-8296f01967a6n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-12-09 18:23           ` John MacFarlane
  0 siblings, 0 replies; 4+ messages in thread
From: John MacFarlane @ 2020-12-09 18:23 UTC (permalink / raw)
  To: enz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, pandoc-discuss


Yes, just add

"files": { $for(sourcefile)$"$sourcefile$"$sep$, $endfor$ }

"enz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <enzonen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Thanks for your quick reply. For the json part, it works fine. But is there 
> a way to also get the filename as part of the json? Or at least on top of 
> each json file, so I can easily merge the json with the corresponding 
> filename. Right now  I have: 
>
> "file": "$sourcefile$"
> $meta-json$
>
> But when I pass all files in the directory, it gives me a list of files and 
> after that all the json. I like to get: filename + json, filename + json + 
> etc.
> In the ideal world: the filename would already be part of the json, but I 
> read somewhere that yaml itself doesn't support the filename option.
>
> Hope it makes sense what I want to achieve.
> On Monday, December 7, 2020 at 7:36:59 PM UTC+1 John MacFarlane wrote:
>
>>
>> Easiest way is to create a custom template with the meta-json
>> variable.
>>
>> If your output format is HTML, create meta.html containing just
>>
>> $meta-json$
>>
>> Then: pandoc --template meta your-input.md
>>
>>
>
> -- 
> 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/7df8deff-9f5e-49dc-83e8-8296f01967a6n%40googlegroups.com.


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

end of thread, other threads:[~2020-12-09 18:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 18:03 extract yaml to json with pandoc enz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found] ` <321e4555-d464-4db8-a18e-0282ac1b5567n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-07 18:36   ` John MacFarlane
     [not found]     ` <m2mtypjwed.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-12-09 11:04       ` enz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found]         ` <7df8deff-9f5e-49dc-83e8-8296f01967a6n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-09 18:23           ` John MacFarlane

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