aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-08-17 16:29:55 +0200
committerAlbert Krewinkel <[email protected]>2022-08-17 16:49:37 +0200
commitf294acff381f3a5c6027e5b0c4082e8255ec64e6 (patch)
tree72760187b20552da8e167f4d88acff3fbcee809e /src
parent90d8205e174c8b734423e81ada5a5f0b59755f6d (diff)
Org reader: treat "abstract" block as metadata
A block of type "abstract" is assumed to define the document's abstract. It is transferred from the main text to the metadata. Closes: #8204
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Org/Blocks.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs
index 1a97a07b4..dd79cc289 100644
--- a/src/Text/Pandoc/Readers/Org/Blocks.hs
+++ b/src/Text/Pandoc/Readers/Org/Blocks.hs
@@ -191,6 +191,7 @@ orgBlock = try $ do
"quote" -> parseBlockLines (fmap B.blockQuote)
"verse" -> verseBlock
"src" -> codeBlock blockAttrs
+ "abstract"-> metadataBlock
_ -> parseBlockLines $
let (ident, classes, kv) = attrFromBlockAttributes blockAttrs
in fmap $ B.divWith (ident, classes ++ [blkType], kv)
@@ -290,6 +291,16 @@ verseBlock blockType = try $ do
line <- parseFromString inlines (indentedLine <> "\n")
return (trimInlinesF $ pure nbspIndent <> line)
+-- | Parses an environment of the given name and adds the result to the document
+-- metadata under a key of the same name.
+metadataBlock :: PandocMonad m => Text -> OrgParser m (F Blocks)
+metadataBlock blockType = try $ do
+ content <- parseBlockLines id blockType
+ meta' <- orgStateMeta <$> getState
+ updateState $ \st ->
+ st { orgStateMeta = B.setMeta blockType <$> content <*> meta' }
+ return mempty
+
-- | Read a code block and the associated results block if present. Which of
-- the blocks is included in the output is determined using the "exports"
-- argument in the block header.