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

--
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-/JYPxA39Uh5TLH3MbocFFw@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.