From 4dac62ef3a0377f2c748b348d3c7fa11a1d689f6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 5 Oct 2020 16:58:55 -0700 Subject: Use yamlToMeta for yaml bibliography This speeds up parsing of external yaml bibliographies considerably (in one test 36s -> 17s). --- src/Text/Pandoc/Citeproc.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs index de7f3273f..feb9be4f1 100644 --- a/src/Text/Pandoc/Citeproc.hs +++ b/src/Text/Pandoc/Citeproc.hs @@ -18,12 +18,13 @@ import Text.Pandoc.Citeproc.Locator (parseLocator) import Text.Pandoc.Citeproc.CslJson (cslJsonToReferences) import Text.Pandoc.Citeproc.BibTeX (readBibtexString, Variant(..)) import Text.Pandoc.Citeproc.MetaValue (metaValueToReference, metaValueToText) +import Text.Pandoc.Readers.Markdown (yamlToMeta) import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as L import Text.Pandoc.Definition as Pandoc import Text.Pandoc.Walk import Text.Pandoc.Builder as B -import Text.Pandoc (PandocMonad(..), PandocError(..), readMarkdown, +import Text.Pandoc (PandocMonad(..), PandocError(..), readDataFile, ReaderOptions(..), pandocExtensions, report, LogMessage(..), fetchItem) import Text.Pandoc.Shared (stringify, ordNub, blocksToInlines) @@ -203,10 +204,8 @@ getRefs locale format idpred raw = (return . filter (idpred . unItemId . referenceId)) . cslJsonToReferences $ raw Format_yaml -> do - Pandoc meta _ <- - readMarkdown - def{ readerExtensions = pandocExtensions } - (UTF8.toText raw) + meta <- yamlToMeta def{ readerExtensions = pandocExtensions } + (L.fromStrict raw) case lookupMeta "references" meta of Just (MetaList rs) -> return $ mapMaybe (metaValueToReference idpred) rs -- cgit v1.2.3