From 6ad486c3c3922e4ac7dd5710f69c3ccf623e92b4 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 30 Mar 2017 16:43:17 +0200 Subject: Automatically include URI-encoded jats.csl for jats output. This way people can do pandoc -s -t jats --filter pandoc-citeproc and it will just work. If they want to specify a stylesheet, they still can. --- src/Text/Pandoc/App.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 0fc883792..e45d10254 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -73,7 +73,7 @@ import Text.Pandoc.Lua ( runLuaFilter ) import Text.Pandoc.MediaBag (MediaBag, extractMediaBag, mediaDirectory) import Text.Pandoc.PDF (makePDF) import Text.Pandoc.Process (pipeProcess) -import Text.Pandoc.SelfContained (makeSelfContained) +import Text.Pandoc.SelfContained (makeSelfContained, makeDataURI) import Text.Pandoc.Shared (err, headerShift, openURL, readDataFile, readDataFileUTF8, safeRead, tabFilter) import qualified Text.Pandoc.UTF8 as UTF8 @@ -386,10 +386,16 @@ convertWithOpts opts = do withMediaBag . r readerOpts) sources return (mconcat (map fst pairs), mconcat (map snd pairs)) + jatsCSL <- readDataFile datadir "jats.csl" + let jatsEncoded = makeDataURI ("application/xml", jatsCSL) + let metadata = if format == "jats" + then ("csl", jatsEncoded) : optMetadata opts + else optMetadata opts + runIO' $ do (doc, media) <- sourceToDoc sources doc' <- (maybe return (extractMedia media) (optExtractMedia opts) >=> - return . flip (foldr addMetadata) (optMetadata opts) >=> + return . flip (foldr addMetadata) metadata >=> applyTransforms transforms >=> applyLuaFilters datadir (optLuaFilters opts) [format] >=> applyFilters datadir filters' [format]) doc -- cgit v1.2.3