aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2016-08-29 14:10:57 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2016-08-29 14:10:57 +0200
commit75df1042157e271398e880e64ce95bd83c5d2193 (patch)
tree5d83b55c7ec6e0a3fc102aa70f70347201dc0668
parent2ca2585b3569bd14923795f3023bd0789fe7911f (diff)
downloadpandoc-75df1042157e271398e880e64ce95bd83c5d2193.tar.gz
Org reader: give precedence to later meta lines
The last meta-line of any given type is the significant line. Previously the value of the first line was kept, even if more lines of the same type were encounterd.
-rw-r--r--src/Text/Pandoc/Readers/Org/Meta.hs2
-rw-r--r--tests/Tests/Readers/Org.hs8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Meta.hs b/src/Text/Pandoc/Readers/Org/Meta.hs
index 372b19fb6..91d16fc63 100644
--- a/src/Text/Pandoc/Readers/Org/Meta.hs
+++ b/src/Text/Pandoc/Readers/Org/Meta.hs
@@ -59,7 +59,7 @@ declarationLine = try $ do
value <- metaValue key
updateState $ \st ->
let meta' = B.setMeta key <$> value <*> pure nullMeta
- in st { orgStateMeta = orgStateMeta st <> meta' }
+ in st { orgStateMeta = meta' <> orgStateMeta st }
metaKey :: OrgParser String
metaKey = map toLower <$> many1 (noneOf ": \n\r")
diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs
index 844266401..5bb291d45 100644
--- a/tests/Tests/Readers/Org.hs
+++ b/tests/Tests/Readers/Org.hs
@@ -496,6 +496,14 @@ tests =
] =?>
(mempty::Blocks)
+ , "later meta definitions take precedence" =:
+ unlines [ "#+AUTHOR: this will not be used"
+ , "#+author: Max"
+ ] =?>
+ let author = MetaInlines [Str "Max"]
+ meta = setMeta "author" (MetaList [author]) $ nullMeta
+ in Pandoc meta mempty
+
, "Logbook drawer" =:
unlines [ " :LogBook:"
, " - State \"DONE\" from \"TODO\" [2014-03-03 Mon 11:00]"