diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-02-21 14:37:31 -0500 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-03-15 13:08:34 -0400 |
commit | 09b4f294bf4584f0010abc331b7e44bb26189865 (patch) | |
tree | bd27a9718b55f68bcc4ac7e2cccdfafde32ee642 | |
parent | c7c4ee46f8c0c72a66d260a3aca00a74f47dc729 (diff) | |
download | pandoc-09b4f294bf4584f0010abc331b7e44bb26189865.tar.gz |
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.
-rw-r--r-- | pandoc.hs | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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, |