aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-11-07 10:48:38 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-11-07 10:48:38 -0800
commit9c7f75afb5d4e50ac915213eba0470c2d0ad304d (patch)
treee6c9e0e66d8cd9458ccaf2104abfb22946652bf5 /src
parente299212bf766cdbeec43be90f634038ab4a727c1 (diff)
downloadpandoc-9c7f75afb5d4e50ac915213eba0470c2d0ad304d.tar.gz
Change merge behavior for metadata.
Previously, if a document contained two YAML metadata blocks that set the same field, the conflict would be resolved in favor of the first. Now it is resolved in favor of the second (due to a change in pandoc-types). This makes the behavior more uniform with other things in pandoc (such as reference links and `--metadata-file`).
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/App.hs12
-rw-r--r--src/Text/Pandoc/App/CommandLineOptions.hs2
-rw-r--r--src/Text/Pandoc/Readers/Vimwiki.hs4
3 files changed, 8 insertions, 10 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index 79346855f..0d34eca11 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -230,12 +230,8 @@ convertWithOpts opts = do
metadataFromFile <-
case optMetadataFiles opts of
[] -> return mempty
- paths -> mapM readFileLazy paths >>= mapM (yamlToMeta readerOpts)
- >>= return . (foldr1 (<>))
- -- Note: this list is in reverse order from the order on the
- -- command line. So this code ensures that metadata files
- -- specified later in the command line take precedence over
- -- those specified earlier.
+ paths -> mapM readFileLazy paths >>=
+ fmap mconcat . mapM (yamlToMeta readerOpts)
let transforms = (case optShiftHeadingLevelBy opts of
0 -> id
@@ -286,8 +282,8 @@ convertWithOpts opts = do
( (if isJust (optExtractMedia opts)
then fillMediaBag
else return)
- >=> return . adjustMetadata (<> metadataFromFile)
- >=> return . adjustMetadata (metadata <>)
+ >=> return . adjustMetadata (metadataFromFile <>)
+ >=> return . adjustMetadata (<> metadata)
>=> applyTransforms transforms
>=> applyFilters readerOpts filters' [format]
>=> maybe return extractMedia (optExtractMedia opts)
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
index 7692cfac9..9f1905741 100644
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -155,7 +155,7 @@ options =
, Option "" ["metadata-file"]
(ReqArg
(\arg opt -> return opt{ optMetadataFiles =
- normalizePath arg : optMetadataFiles opt })
+ optMetadataFiles opt ++ [normalizePath arg] })
"FILE")
""
diff --git a/src/Text/Pandoc/Readers/Vimwiki.hs b/src/Text/Pandoc/Readers/Vimwiki.hs
index 57fa6fa1a..27b7d7245 100644
--- a/src/Text/Pandoc/Readers/Vimwiki.hs
+++ b/src/Text/Pandoc/Readers/Vimwiki.hs
@@ -427,7 +427,9 @@ ph s = try $ do
contents <- trimInlines . mconcat <$> manyTill inline (lookAhead newline)
--use lookAhead because of placeholder in the whitespace parser
let meta' = B.setMeta s contents nullMeta
- updateState $ \st -> st { stateMeta = stateMeta st <> meta' }
+ -- this order ensures that later values will be ignored in favor
+ -- of earlier ones:
+ updateState $ \st -> st { stateMeta = meta' <> stateMeta st }
noHtmlPh :: PandocMonad m => VwParser m ()
noHtmlPh = try $