aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Org/Blocks.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2020-06-29 21:19:34 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2020-06-29 21:19:34 +0200
commit5ef315cc6db868a11bd0c3e887b8c55eb2216662 (patch)
tree2affeab7c36d22cfdcb304248a6102f302b27c62 /src/Text/Pandoc/Readers/Org/Blocks.hs
parent90ac70c79c776a0f41367a6f509d66591aa925ae (diff)
downloadpandoc-5ef315cc6db868a11bd0c3e887b8c55eb2216662.tar.gz
Org reader: keep unknown keyword lines as raw org
The lines of unknown keywords, like `#+SOMEWORD: value` are no longer read as metadata, but kept as raw `org` blocks. This ensures that more information is retained when round-tripping org-mode files; additionally, this change makes it possible to support non-standard org extensions via filters.
Diffstat (limited to 'src/Text/Pandoc/Readers/Org/Blocks.hs')
-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 2fbb26d31..0e2f49a83 100644
--- a/src/Text/Pandoc/Readers/Org/Blocks.hs
+++ b/src/Text/Pandoc/Readers/Org/Blocks.hs
@@ -76,6 +76,7 @@ block = choice [ mempty <$ blanklines
, list
, latexFragment
, noteBlock
+ , rawOrgLine
, paraOrPlain
] <?> "block"
@@ -559,6 +560,8 @@ include = try $ do
| otherwise -> Para content
_ -> blk
+-- | Parses a meta line which defines a raw block. Currently recognized:
+-- @#+LATEX:@, @#+HTML:@, @#+TEXINFO:@, and @#+BEAMER@.
rawExportLine :: PandocMonad m => OrgParser m Blocks
rawExportLine = try $ do
metaLineStart
@@ -567,6 +570,14 @@ rawExportLine = try $ do
then B.rawBlock key <$> anyLine
else mzero
+-- | Parses any meta line, i.e., a line starting with @#+@, into a raw
+-- org block. This should be the last resort when trying to parse
+-- keywords. Leading spaces are discarded.
+rawOrgLine :: PandocMonad m => OrgParser m (F Blocks)
+rawOrgLine = do
+ line <- metaLineStart *> anyLine
+ returnF $ B.rawBlock "org" $ ("#+" <> line)
+
commentLine :: Monad m => OrgParser m Blocks
commentLine = commentLineStart *> anyLine *> pure mempty