* Reading yaml metadata @ 2023-12-11 5:03 ss2 [not found] ` <dac9ab6e-b3ad-4645-912e-a7f72f5c7429n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: ss2 @ 2023-12-11 5:03 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 1719 bytes --] Hello Everyone, 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 = fromList []}) [Para [Str "\8212",SoftBreak,Str "title:",Space,Str "The",Space,Str "document",Space,Str "title",SoftBreak,Str "author:"],BulletList [[Plain [Str "name:",Space,Str "Author",Space,Str "One",SoftBreak,Str "affiliation:",Space,Str "University",Space,Str "of",Space,Str "Somewhere"]],[Plain [Str "name:",Space,Str "Author",Space,Str "Two",SoftBreak,Str "affiliation:",Space,Str "University",Space,Str "of",Space,Str "Nowhere"]]],Para [Str "\8230"],Header 1 ("",[],[]) [Str "Root"],Header 1 ("",[],[]) [Str "Nav"],BulletList [[Plain [Link ("",[],[]) [Str "posts"] ("posts/hello-world.org","")]],[Plain [Link ("",[],[]) [Str "stream"] ("stream.org","")]]],Para [Str "About",Space,Str "me."]]) As you can see the metadata is empty even though there is a yaml metadata block in the source file. My build depends on pandoc >= 3.1 && < 3.2 and pandoc-types >= 1.23. Any help would be greatly appreciated!! Best, P -- 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/dac9ab6e-b3ad-4645-912e-a7f72f5c7429n%40googlegroups.com. [-- Attachment #1.2: Type: text/html, Size: 2190 bytes --] [-- Attachment #2: root.org --] [-- Type: application/octet-stream, Size: 252 bytes --] --- title: The document title author: - name: Author One affiliation: University of Somewhere - name: Author Two affiliation: University of Nowhere ... * Root * Nav - [[file:posts/hello-world.org][posts]] - [[file:stream.org][stream]] About me. [-- Attachment #3: Example.hs --] [-- Type: text/x-haskell, Size: 392 bytes --] import qualified Data.Text as T import Text.Pandoc -- Read an org document with a yaml metadata block and print it printDocWithMetaData :: IO () printDocWithMetaData = do input <- readFile "root.org" let readerOpts = def { readerStandalone = True, readerExtensions = extensionsFromList [Ext_yaml_metadata_block] } doc <- runIO $ readOrg readerOpts (T.pack input) print doc ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <dac9ab6e-b3ad-4645-912e-a7f72f5c7429n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Reading yaml metadata [not found] ` <dac9ab6e-b3ad-4645-912e-a7f72f5c7429n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2023-12-12 1:27 ` ss2 [not found] ` <c1b6d4fe-8cd5-482c-b351-be20a658b8d3n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: ss2 @ 2023-12-12 1:27 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 3014 bytes --] 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 _) = meta -- Read an org document with a yaml metadata block and print it printDocWithMetaData :: IO () printDocWithMetaData = do input <- readFile "root.org" let readerOpts = def { readerStandalone = True, readerExtensions = enableExtension Ext_yaml_metadata_block (getDefaultExtensions $ T.pack "org") } eitherDoc <- runIO $ readOrg readerOpts (T.pack input) doc <- handleError eitherDoc let metaData = 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 = fromList []}``` The input file contains a yaml metadata block yet the pandoc reader isn't extracting it. On Sunday, December 10, 2023 at 11:03:41 PM UTC-6 ss2 wrote: > Hello Everyone, > > 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 = fromList []}) [Para [Str > "\8212",SoftBreak,Str "title:",Space,Str "The",Space,Str > "document",Space,Str "title",SoftBreak,Str "author:"],BulletList [[Plain > [Str "name:",Space,Str "Author",Space,Str "One",SoftBreak,Str > "affiliation:",Space,Str "University",Space,Str "of",Space,Str > "Somewhere"]],[Plain [Str "name:",Space,Str "Author",Space,Str > "Two",SoftBreak,Str "affiliation:",Space,Str "University",Space,Str > "of",Space,Str "Nowhere"]]],Para [Str "\8230"],Header 1 ("",[],[]) [Str > "Root"],Header 1 ("",[],[]) [Str "Nav"],BulletList [[Plain [Link ("",[],[]) > [Str "posts"] ("posts/hello-world.org","")]],[Plain [Link ("",[],[]) [Str > "stream"] ("stream.org","")]]],Para [Str "About",Space,Str "me."]]) > > As you can see the metadata is empty even though there is a yaml metadata > block in the source file. > > My build depends on pandoc >= 3.1 && < 3.2 and pandoc-types >= 1.23. > > Any help would be greatly appreciated!! > > Best, > P > -- 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/c1b6d4fe-8cd5-482c-b351-be20a658b8d3n%40googlegroups.com. [-- Attachment #1.2: Type: text/html, Size: 4861 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <c1b6d4fe-8cd5-482c-b351-be20a658b8d3n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Reading yaml metadata [not found] ` <c1b6d4fe-8cd5-482c-b351-be20a658b8d3n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2023-12-12 10:22 ` 'William Lupton' via pandoc-discuss 0 siblings, 0 replies; 3+ messages in thread From: 'William Lupton' via pandoc-discuss @ 2023-12-12 10:22 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw [-- Attachment #1: Type: text/plain, Size: 4106 bytes --] I don't use org myself, but I'm wondering whether the org reader supports YAML metadata blocks. *% *pandoc --list-extensions=org -ascii_identifiers +auto_identifiers +citations -east_asian_line_breaks -fancy_lists -gfm_auto_identifiers -smart +task_lists On Tue, 12 Dec 2023 at 01:27, ss2 <okubo.peyton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > 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 _) = meta > > -- Read an org document with a yaml metadata block and print it > printDocWithMetaData :: IO () > printDocWithMetaData = do > input <- readFile "root.org" > let readerOpts = def { > readerStandalone = True, > readerExtensions = enableExtension Ext_yaml_metadata_block > (getDefaultExtensions $ T.pack "org") > } > eitherDoc <- runIO $ readOrg readerOpts (T.pack input) > doc <- handleError eitherDoc > let metaData = 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 = fromList []}``` > > The input file contains a yaml metadata block yet the pandoc reader isn't > extracting it. > > > On Sunday, December 10, 2023 at 11:03:41 PM UTC-6 ss2 wrote: > >> Hello Everyone, >> >> 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 = fromList []}) [Para [Str >> "\8212",SoftBreak,Str "title:",Space,Str "The",Space,Str >> "document",Space,Str "title",SoftBreak,Str "author:"],BulletList [[Plain >> [Str "name:",Space,Str "Author",Space,Str "One",SoftBreak,Str >> "affiliation:",Space,Str "University",Space,Str "of",Space,Str >> "Somewhere"]],[Plain [Str "name:",Space,Str "Author",Space,Str >> "Two",SoftBreak,Str "affiliation:",Space,Str "University",Space,Str >> "of",Space,Str "Nowhere"]]],Para [Str "\8230"],Header 1 ("",[],[]) [Str >> "Root"],Header 1 ("",[],[]) [Str "Nav"],BulletList [[Plain [Link ("",[],[]) >> [Str "posts"] ("posts/hello-world.org","")]],[Plain [Link ("",[],[]) >> [Str "stream"] ("stream.org","")]]],Para [Str "About",Space,Str "me."]]) >> >> As you can see the metadata is empty even though there is a yaml metadata >> block in the source file. >> >> My build depends on pandoc >= 3.1 && < 3.2 and pandoc-types >= 1.23. >> >> Any help would be greatly appreciated!! >> >> Best, >> P >> > -- > 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/c1b6d4fe-8cd5-482c-b351-be20a658b8d3n%40googlegroups.com > <https://groups.google.com/d/msgid/pandoc-discuss/c1b6d4fe-8cd5-482c-b351-be20a658b8d3n%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_xxhm5nqFVMMAq%3DzUTA%3DSLo4bAf3gQ0DDaKVLSx9a5A7HPw%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 9556 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-12 10:22 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-12-11 5:03 Reading yaml metadata ss2 [not found] ` <dac9ab6e-b3ad-4645-912e-a7f72f5c7429n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2023-12-12 1:27 ` ss2 [not found] ` <c1b6d4fe-8cd5-482c-b351-be20a658b8d3n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2023-12-12 10:22 ` 'William Lupton' via pandoc-discuss
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).