diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-10-07 13:02:36 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-10-07 13:12:32 -0700 |
commit | 428f8b4d204bf90118f01b0a03b6763b626a6532 (patch) | |
tree | 91f552dc7c9a09d7d498a21a73cbab2ae64dcb68 /src/Text/Pandoc/Citeproc.hs | |
parent | 69b030c7dfa0e7dc454cc589747f8fc7f5987510 (diff) | |
download | pandoc-428f8b4d204bf90118f01b0a03b6763b626a6532.tar.gz |
Raise informative errors when YAML metadata parsing fails.
Closes #6730.
Previously the command would succeed, returning empty metadata,
with no errors or warnings.
API changes:
- Remove now unused CouldNotParseYamlMetadata constructor for
LogMessage (T.P.Logging).
- Add 'Maybe FilePath' parameter to yamlToMeta in T.P.Readers.Markdown.
Diffstat (limited to 'src/Text/Pandoc/Citeproc.hs')
-rw-r--r-- | src/Text/Pandoc/Citeproc.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs index 2a71f619a..202fc5506 100644 --- a/src/Text/Pandoc/Citeproc.hs +++ b/src/Text/Pandoc/Citeproc.hs @@ -191,7 +191,7 @@ getRefsFromBib locale idpred t = do let fp = T.unpack t raw <- readFileStrict fp case formatFromExtension fp of - Just f -> getRefs locale f idpred raw + Just f -> getRefs locale f idpred (Just fp) raw Nothing -> throwError $ PandocAppError $ "Could not deterine bibliography format for " <> t @@ -199,9 +199,10 @@ getRefs :: PandocMonad m => Locale -> BibFormat -> (Text -> Bool) + -> Maybe FilePath -> ByteString -> m [Reference Inlines] -getRefs locale format idpred raw = +getRefs locale format idpred mbfp raw = case format of Format_bibtex -> either (throwError . PandocAppError . T.pack . show) return . @@ -216,6 +217,7 @@ getRefs locale format idpred raw = Format_yaml -> do rs <- yamlToRefs idpred def{ readerExtensions = pandocExtensions } + mbfp (L.fromStrict raw) return $ mapMaybe metaValueToReference rs |