summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2015-05-23 13:22:07 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2015-05-23 13:22:07 +0200
commitb61355cecd39b84109160cb925af95469a9e01dd (patch)
tree790dad79e3d5c5741d341cc1f8b1a4b618c00311 /src/Text/Pandoc/Readers
parent40fb102417c1fafd39f0b636de7e14fd8a85f675 (diff)
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.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Org.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index f3e8fc1f7..fd714736a 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -399,11 +399,11 @@ exportsResults :: [(String, String)] -> Bool
exportsResults attrs = ("rundoc-exports", "results") `elem` attrs
|| ("rundoc-exports", "both") `elem` attrs
-followingResultsBlock :: OrgParser (Maybe String)
+followingResultsBlock :: OrgParser (Maybe (F Blocks))
followingResultsBlock =
optionMaybe (try $ blanklines *> stringAnyCase "#+RESULTS:"
*> blankline
- *> (unlines <$> many1 exampleLine))
+ *> block)
codeBlock :: BlockProperties -> OrgParser (F Blocks)
codeBlock blkProp = do
@@ -418,7 +418,7 @@ codeBlock blkProp = do
labelledBlck <- maybe (pure codeBlck)
(labelDiv codeBlck)
<$> lookupInlinesAttr "caption"
- let resultBlck = pure $ maybe mempty (exampleCode) resultsContent
+ let resultBlck = fromMaybe mempty resultsContent
return $ (if includeCode then labelledBlck else mempty)
<> (if includeResults then resultBlck else mempty)
where