From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33509 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: ss2 Newsgroups: gmane.text.pandoc Subject: Re: Reading yaml metadata Date: Mon, 11 Dec 2023 17:27:56 -0800 (PST) Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_744_453094633.1702344476650" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3643"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCTYVA5G7YERBHXO32VQMGQEH722RRI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Dec 12 02:28:02 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f60.google.com ([209.85.161.60]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1rCrZ4-0000iA-1o for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 12 Dec 2023 02:28:02 +0100 Original-Received: by mail-oo1-f60.google.com with SMTP id 006d021491bc7-591202b7fa3sf951874eaf.0 for ; Mon, 11 Dec 2023 17:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1702344481; x=1702949281; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=wuJFeiymnPUU5ioJ2f9c3rPak/DuVsiMFI9biqviBMk=; b=EMmasOmb1LxHZdgFvjgJvswi+M6NTM1wBPsPuBAcF3lCzLEJl9LFbCpXT8qoBEgDW3 xX4NqH3FCQlEl78c6SBgNg2rYB4UFNc90i9qAtDAflFQDYYbCWVcEIuHWifXSx//Xcr3 +PUILzKgDcysObyuVMbFMEXj1c8lcjafuwSIWN4GFv2aoqKcnwwSL+S8DG6/csv5Tvpw iDUnlL7TC4e7HxmBHjLr+Z1RmhOvJoEyt8/b16FUJvvvzrwMvE2lsDSrHfXbLgENHTRz icH5hWW5J0ZaRHT3vzDeJGDqegIcmFWweCGg24miJ2a9lLFGZskzIjs/vzfLIgtdibvp +QIA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702344481; x=1702949281; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=wuJFeiymnPUU5ioJ2f9c3rPak/DuVsiMFI9biqviBMk=; b=fMOccOHnUHD754wrnCWS6iA/4yvL2IL9OfWHMoUsyjc1CgxT8qf2liEFk/SGyf2ybB Z3X30dQ7fZktv1ZrQ3MtmGWRdCgvT+GywMLn07wMHciJ3xoFFUgX23O6MX22Psk/BeYT HbvvxNdcfQv2VRcJv1fSZdDiEFdqbvfLPKH0J0O0lzOAFqMkAq7aYDY9xJehd2t6GptL w2wEm264HNb8Ca+GE6Y+8yEBCydotKwtztX4q89MFWKgFReeIQfCdt1ESLRO7PGvjo/F HSwFkVzTpxxXkO13ztYSTCh2nWCFrxAomo3IKT/B/gANz1kJha1yxHoYEkIRGog2JeLd +Hpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702344481; x=1702949281; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=wuJFeiymnPUU5ioJ2f9c3rPak/DuVsiMFI9biqviBMk=; b=E2EZ9ho1K22j2m/qQF73QBJr4/PNWSRrNNPebWkXHIkahQDHhA1Cr/r2wTzOW9z0Wh EvK11Nb8J4AYm80tk/qQb6Bpr+S9COTB9GcgnYoXebb+nEutsjjuKOh0gDgr9yA69tXo Dul8XFADPF2UYhDDeXlh+sMvdRxbGz7wgI/WEje9payUNjiiMpceiNLNtb/ri+PBnlp2 WYFi8KMk3wQvDBZZpE6F64kTnhox39Xs1o4NPr/vT/UxqpYsQ8K5pPAhHz5dRW/4avfM zrjP2by7j5rCSW6OMdkAY8lkVkYWOaolZF+nsbiDLbxagXeFJ1 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOJu0YxuMFofHCbyyiY7fRxvMhPiGVWw6byaawsixiPLsbspT7HDA9P7 DvJPUb4oPhqQQHogh1nkfyo= X-Google-Smtp-Source: AGHT+IGdP01q5aPrqE0LsQ9/tMrEBtrGoRsYT4LYEnUCPSvd1cgEUVVOyYkylOR6HwuWmRPnzTH1XA== X-Received: by 2002:a05:6820:1ac9:b0:590:87c5:2b0c with SMTP id bu9-20020a0568201ac900b0059087c52b0cmr3452031oob.7.1702344480703; Mon, 11 Dec 2023 17:28:00 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6820:602:b0:58d:b18f:9006 with SMTP id e2-20020a056820060200b0058db18f9006ls4630706oow.0.-pod-prod-00-us; Mon, 11 Dec 2023 17:27:57 -0800 (PST) X-Received: by 2002:a05:6808:208d:b0:3ad:da36:1dd6 with SMTP id s13-20020a056808208d00b003adda361dd6mr4273116oiw.1.1702344477222; Mon, 11 Dec 2023 17:27:57 -0800 (PST) In-Reply-To: X-Original-Sender: Okubo.peyton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:33509 Archived-At: ------=_Part_744_453094633.1702344476650 Content-Type: multipart/alternative; boundary="----=_Part_745_1733831516.1702344476650" ------=_Part_745_1733831516.1702344476650 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Maybe attaching the files was inconvenient. Haskell code ``` import qualified Data.Text as T import Text.Pandoc import Text.Pandoc.Walk (query) -- Extract YAML metadata from document getMetaData :: Pandoc -> Meta getMetaData (Pandoc meta _) =3D meta -- Read an org document with a yaml metadata block and print it printDocWithMetaData :: IO () printDocWithMetaData =3D do input <- readFile "root.org" let readerOpts =3D def { readerStandalone =3D True, readerExtensions =3D enableExtension Ext_yaml_metadata_block=20 (getDefaultExtensions $ T.pack "org") } eitherDoc <- runIO $ readOrg readerOpts (T.pack input) doc <- handleError eitherDoc let metaData =3D getMetaData doc print metaData ``` Input file (root.org): ``` --- title: Hello, World! author: - name: Your Name affiliation: Your Affiliation --- * Introduction Hello, World! This is a simple org-mode document with a YAML header. * Conclusion Thank you for reading! ``` Std out: ```Meta {unMeta =3D fromList []}``` The input file contains a yaml metadata block yet the pandoc reader isn't= =20 extracting it. On Sunday, December 10, 2023 at 11:03:41=E2=80=AFPM UTC-6 ss2 wrote: > Hello Everyone, > > I'm simply trying to read a markup file (org in this case). I'm able to= =20 > read its contents but not the metadata. I've tried reading the=20 > documentation and looking at a few examples and I'm not sure what I'm doi= ng=20 > wrong. The code snippet and file I'm reading are attached below. Here is= =20 > the output when calling the function: > > Right (Pandoc (Meta {unMeta =3D fromList []}) [Para [Str=20 > "\8212",SoftBreak,Str "title:",Space,Str "The",Space,Str=20 > "document",Space,Str "title",SoftBreak,Str "author:"],BulletList [[Plain= =20 > [Str "name:",Space,Str "Author",Space,Str "One",SoftBreak,Str=20 > "affiliation:",Space,Str "University",Space,Str "of",Space,Str=20 > "Somewhere"]],[Plain [Str "name:",Space,Str "Author",Space,Str=20 > "Two",SoftBreak,Str "affiliation:",Space,Str "University",Space,Str=20 > "of",Space,Str "Nowhere"]]],Para [Str "\8230"],Header 1 ("",[],[]) [Str= =20 > "Root"],Header 1 ("",[],[]) [Str "Nav"],BulletList [[Plain [Link ("",[],[= ])=20 > [Str "posts"] ("posts/hello-world.org","")]],[Plain [Link ("",[],[]) [Str= =20 > "stream"] ("stream.org","")]]],Para [Str "About",Space,Str "me."]]) > > As you can see the metadata is empty even though there is a yaml metadata= =20 > block in the source file. > > My build depends on pandoc >=3D 3.1 && < 3.2 and pandoc-types >=3D 1.23. > > Any help would be greatly appreciated!! > > Best, > P > --=20 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 e= mail 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/c1b6d4fe-8cd5-482c-b351-be20a658b8d3n%40googlegroups.com. ------=_Part_745_1733831516.1702344476650 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Maybe attaching the files was inconvenient.

Haskell code
```
import qualified Data.Tex= t as T
import Text.Pandoc
import Text.Pandoc.Walk (query)
-- Extract YAML metadata from document
getMetaData :: Pandoc ->= Meta
getMetaData (Pandoc meta _) =3D meta

-- Read an org d= ocument with a yaml metadata block and print it
printDocWithMetaData := : IO ()
printDocWithMetaData =3D do
=C2=A0 input <- readFile "= root.org"
=C2=A0 let= readerOpts =3D def {
=C2=A0 =C2=A0 readerStandalone =3D True,
= =C2=A0 =C2=A0 readerExtensions =3D enableExtension Ext_yaml_metadata_block = (getDefaultExtensions $ T.pack "org")
=C2=A0 }
=C2=A0 eitherDoc &= lt;- runIO $ readOrg readerOpts (T.pack input)
=C2=A0 doc <- handle= Error eitherDoc
=C2=A0 let metaData =3D getMetaData doc
=C2=A0 pr= int metaData
```

Input file (root.org):
```
---
title: Hello, World!
author:
=C2=A0 - name:= Your Name
=C2=A0 =C2=A0 affiliation: Your Affiliation
---
<= br />* Introduction

Hello, World! This is a simple org-mode docu= ment with a YAML header.

* Conclusion

Thank you for r= eading!
```

Std out:
```Meta= {unMeta =3D fromList []}```

The input file cont= ains a yaml metadata block yet the pandoc reader isn't extracting it.
=

On Sunday, December 10, 2023 at 11:03:41=E2=80=AFPM UTC-6 ss2 wrote:
Hello Every= one,

I'm simply trying to read a markup file (= org in this case). I'm able to read its contents but not the metadata. = I've tried reading the documentation and looking at a few examples and = I'm not sure what I'm doing wrong. The code snippet and file I'= m reading are attached below. Here is the output when calling the function:=

Right (Pandoc (Meta {unMeta =3D fromList []}) [Pa= ra [Str "\8212",SoftBreak,Str "title:",Space,Str "= The",Space,Str "document",Space,Str "title",SoftBr= eak,Str "author:"],BulletList [[Plain [Str "name:",Spac= e,Str "Author",Space,Str "One",SoftBreak,Str "affi= liation:",Space,Str "University",Space,Str "of",Sp= ace,Str "Somewhere"]],[Plain [Str "name:",Space,Str &qu= ot;Author",Space,Str "Two",SoftBreak,Str "affiliation:&= quot;,Space,Str "University",Space,Str "of",Space,Str &= quot;Nowhere"]]],Para [Str "\8230"],Header 1 ("",[= ],[]) [Str "Root"],Header 1 ("",[],[]) [Str "Nav&q= uot;],BulletList [[Plain [Link ("",[],[]) [Str "posts"]= ("posts/hello-world.org",""= )]],[Plain [Link ("",[],[]) [Str "stream"] ("stream.org","")]]],Para [Str "About",Spa= ce,Str "me."]])

As you can see the metad= ata is empty even though there is a yaml metadata block in the source file.=

My build depends on pandoc >=3D 3.1 =C2=A0&= ;& < 3.2 and pandoc-types >=3D 1.23.

Any= help would be greatly appreciated!!

Best,
P

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/c1b6d4fe-8cd5-482c-b351-be20a658b8d3n%40googlegroups.= com.
------=_Part_745_1733831516.1702344476650-- ------=_Part_744_453094633.1702344476650--