git.iko.soy/typeable/pandoc
on master help sign in
Org reader: generalize code block result parsing

Code blocks can be followed by optional result blocks, representing the output generated by running the code in the code block. It is possible to choose whether one wants to export the code, the result, both or none. This patch allows any kind of `Block` as the result. Previously, only example code blocks were recognized.

commitb61355cecd39b84109160cb925af95469a9e01dd authorAlbert Krewinkel <albert@zeitkraut.de> dateSat 23 May 2015, 13:22 (11 years ago) parent40fb102
1 file changed+3−3
src/Text/Pandoc/Readers/Org.hs+3−3
src/Text/Pandoc/Readers/Org.hs+3−3
@@ -399,11 +399,11 @@ exportsResults :: [(String, String)] -> Bool
399399exportsResults attrs = ("rundoc-exports", "results") `elem` attrs
400400 || ("rundoc-exports", "both") `elem` attrs
401401
402−followingResultsBlock :: OrgParser (Maybe String)
402+followingResultsBlock :: OrgParser (Maybe (F Blocks))
403403followingResultsBlock =
404404 optionMaybe (try $ blanklines *> stringAnyCase "#+RESULTS:"
405405 *> blankline
406− *> (unlines <$> many1 exampleLine))
406+ *> block)
407407
408408codeBlock :: BlockProperties -> OrgParser (F Blocks)
409409codeBlock blkProp = do
@@ -418,7 +418,7 @@ codeBlock blkProp = do
418418 labelledBlck <- maybe (pure codeBlck)
419419 (labelDiv codeBlck)
420420 <$> lookupInlinesAttr "caption"
421− let resultBlck = pure $ maybe mempty (exampleCode) resultsContent
421+ let resultBlck = fromMaybe mempty resultsContent
422422 return $ (if includeCode then labelledBlck else mempty)
423423 <> (if includeResults then resultBlck else mempty)
424424 where