From 09b4f294bf4584f0010abc331b7e44bb26189865 Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Sun, 21 Feb 2016 14:37:31 -0500 Subject: pandoc.hs: Also use filescope for json files. JSON files have metadata and list structure, so they can't be simply catted, but they're useful as intermediate build files in large projects. --- pandoc.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pandoc.hs b/pandoc.hs index 59277690a..39335785c 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -1319,14 +1319,16 @@ convertWithOpts opts args = do either (return . Left) (\s -> fmap (,mempty) <$> r readerOpts s) doc ByteStringReader r -> readFiles sources' >>= r readerOpts - -- We parse first if fileScope is set OR if the reader is a - -- BSReader. So, if it's a StringReader AND not fileScope, we - -- don't. + -- We parse first if (1) fileScope is set, (2), it's a binary + -- reader, or (3) we're reading JSON. This is easier to do of an AND + -- of negatives as opposed to an OR of positives, so we do default + -- parsing if it's a StringReader AND (fileScope is set AND it's not + -- a JSON reader). (doc, media) <- case reader of - (StringReader _) | not fileScope -> sourceToDoc sources - _ -> do - pairs <- mapM (\s -> sourceToDoc [s]) sources - return (mconcat $ map fst pairs, mconcat $ map snd pairs) + (StringReader _) | not fileScope && readerName' /= "json" -> + sourceToDoc sources + _ -> do pairs <- mapM (\s -> sourceToDoc [s]) sources + return (mconcat $ map fst pairs, mconcat $ map snd pairs) let writerOptions = def { writerStandalone = standalone', writerTemplate = templ, -- cgit v1.2.3