git.iko.soy/typeable/pandoc
on master help sign in
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.

commit09b4f294bf4584f0010abc331b7e44bb26189865 authorJesse Rosenthal <jrosenthal@jhu.edu> dateSun 21 Feb 2016, 14:37 (11 years ago) parentc7c4ee4
1 file changed+9−7
pandoc.hs+9−7
pandoc.hs+9−7
@@ -1319,14 +1319,16 @@ convertWithOpts opts args = do
13191319 either (return . Left) (\s -> fmap (,mempty) <$> r readerOpts s) doc
13201320 ByteStringReader r -> readFiles sources' >>= r readerOpts
13211321
1322− -- We parse first if fileScope is set OR if the reader is a
1323− -- BSReader. So, if it's a StringReader AND not fileScope, we
1324− -- don't.
1322+ -- We parse first if (1) fileScope is set, (2), it's a binary
1323+ -- reader, or (3) we're reading JSON. This is easier to do of an AND
1324+ -- of negatives as opposed to an OR of positives, so we do default
1325+ -- parsing if it's a StringReader AND (fileScope is set AND it's not
1326+ -- a JSON reader).
13251327 (doc, media) <- case reader of
1326− (StringReader _) | not fileScope -> sourceToDoc sources
1327− _ -> do
1328− pairs <- mapM (\s -> sourceToDoc [s]) sources
1329− return (mconcat $ map fst pairs, mconcat $ map snd pairs)
1328+ (StringReader _) | not fileScope && readerName' /= "json" ->
1329+ sourceToDoc sources
1330+ _ -> do pairs <- mapM (\s -> sourceToDoc [s]) sources
1331+ return (mconcat $ map fst pairs, mconcat $ map snd pairs)
13301332
13311333 let writerOptions = def { writerStandalone = standalone',
13321334 writerTemplate = templ,