aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2020-06-28 17:36:31 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2020-06-28 18:01:30 +0200
commite3a6d651e17b88df107bf2293dfc5e3e6dbf35d2 (patch)
treee34b46c35ecf63dea7c3b5fb38317e22efe21319 /src/Text/Pandoc
parent54f6faa10f79a7e9172c67a9d860689269aa6cc3 (diff)
downloadpandoc-e3a6d651e17b88df107bf2293dfc5e3e6dbf35d2.tar.gz
Org reader: update behavior of author, keywords export settings
The behavior of the `#+AUTHOR` and `#+KEYWORD` export settings has changed: Org now allows multiple such lines and adds a space between the contents of each line. Pandoc now always parses these settings as meta inlines; setting values are no longer treated as comma-separated lists. Note that a Lua filter can be used to restore the previous behavior.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Org/Meta.hs28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Meta.hs b/src/Text/Pandoc/Readers/Org/Meta.hs
index 7ee64c2e5..fdb7abe7c 100644
--- a/src/Text/Pandoc/Readers/Org/Meta.hs
+++ b/src/Text/Pandoc/Readers/Org/Meta.hs
@@ -74,11 +74,11 @@ metaKey = T.toLower <$> many1Char (noneOf ": \n\r")
exportSettingHandlers :: PandocMonad m => Map Text (OrgParser m ())
exportSettingHandlers = Map.fromList
[ ("result" , fmap pure anyLine `parseThen` discard) -- RESULT is never an export setting
- , ("author" , commaSepInlines `parseThen` setField "author")
- , ("keywords" , commaSepInlines `parseThen` setField "keywords")
+ , ("author" , lineOfInlines `parseThen` collectLines "author")
+ , ("keywords" , lineOfInlines `parseThen` collectLines "keywords")
, ("date" , lineOfInlines `parseThen` setField "date")
- , ("description", lineOfInlines `parseThen` collectSepBy B.SoftBreak "description")
- , ("title" , lineOfInlines `parseThen` collectSepBy B.Space "title")
+ , ("description", lineOfInlines `parseThen` collectLines "description")
+ , ("title" , lineOfInlines `parseThen` collectLines "title")
, ("nocite" , lineOfInlines `parseThen` collectAsList "nocite")
, ("latex_class", fmap pure anyLine `parseThen` setField "documentclass")
, ("latex_class_options", (pure . T.filter (`notElem` ("[]" :: String)) <$> anyLine)
@@ -101,8 +101,8 @@ parseThen p modMeta = do
discard :: a -> Meta -> Meta
discard = const id
-collectSepBy :: Inline -> Text -> Inlines -> Meta -> Meta
-collectSepBy sep key value meta =
+collectLines :: Text -> Inlines -> Meta -> Meta
+collectLines key value meta =
let value' = appendValue meta (B.toList value)
in B.setMeta key value' meta
where
@@ -117,7 +117,7 @@ collectSepBy sep key value meta =
collectInlines :: MetaValue -> [Inline]
collectInlines = \case
MetaInlines inlns -> inlns
- MetaList ml -> intercalate [sep] $ map collectInlines ml
+ MetaList ml -> intercalate [B.SoftBreak] $ map collectInlines ml
MetaString s -> [B.Str s]
MetaBlocks blks -> blocksToInlines blks
MetaMap _map -> []
@@ -138,16 +138,6 @@ collectAsList key value meta =
setField :: ToMetaValue a => Text -> a -> Meta -> Meta
setField field value meta = B.setMeta field (B.toMetaValue value) meta
-lineOfInlines :: PandocMonad m => OrgParser m (F Inlines)
-lineOfInlines = inlinesTillNewline
-
-commaSepInlines :: PandocMonad m => OrgParser m (F [Inlines])
-commaSepInlines = do
- itemStrs <- many1Char (noneOf ",\n") `sepBy1` char ','
- newline
- items <- mapM (parseFromString inlinesTillNewline . (<> "\n")) itemStrs
- return $ sequence items
-
-- | Read an format specific meta definition
metaExportSnippet :: Monad m => Text -> OrgParser m (F Inlines)
metaExportSnippet format = pure . B.rawInline format <$> anyLine
@@ -233,8 +223,8 @@ emphChars = do
skipSpaces
safeRead <$> anyLine
-inlinesTillNewline :: PandocMonad m => OrgParser m (F Inlines)
-inlinesTillNewline = do
+lineOfInlines :: PandocMonad m => OrgParser m (F Inlines)
+lineOfInlines = do
updateLastPreCharPos
trimInlinesF . mconcat <$> manyTill inline newline