@@ -180,19 +180,6 @@ recordAnchorId :: String -> OrgParser ()
180180recordAnchorId i = updateState $ \s ->
181181 s{ orgStateAnchorIds = i : (orgStateAnchorIds s) }
182182
183−addBlockAttribute :: String -> String -> OrgParser ()
184−addBlockAttribute key val = updateState $ \s ->
185− let attrs = orgStateBlockAttributes s
186− in s{ orgStateBlockAttributes = M.insert key val attrs }
187−
188−lookupBlockAttribute :: String -> OrgParser (Maybe String)
189−lookupBlockAttribute key =
190− M.lookup key . orgStateBlockAttributes <$> getState
191−
192−resetBlockAttributes :: OrgParser ()
193−resetBlockAttributes = updateState $ \s ->
194− s{ orgStateBlockAttributes = orgStateBlockAttributes def }
195−
196183updateLastForbiddenCharPos :: OrgParser ()
197184updateLastForbiddenCharPos = getPosition >>= \p ->
198185 updateState $ \s -> s{ orgStateLastForbiddenCharPos = Just p}
@@ -320,9 +307,18 @@ block = choice [ mempty <$ blanklines
320307 , paraOrPlain
321308 ] <?> "block"
322309
310+--
311+-- Block Attributes
312+--
313+
314+-- | Parse optional block attributes (like #+TITLE or #+NAME)
323315optionalAttributes :: OrgParser (F Blocks) -> OrgParser (F Blocks)
324316optionalAttributes parser = try $
325317 resetBlockAttributes *> parseBlockAttributes *> parser
318+ where
319+ resetBlockAttributes :: OrgParser ()
320+ resetBlockAttributes = updateState $ \s ->
321+ s{ orgStateBlockAttributes = orgStateBlockAttributes def }
326322
327323parseBlockAttributes :: OrgParser ()
328324parseBlockAttributes = do
@@ -347,6 +343,15 @@ lookupInlinesAttr attr = try $ do
347343 (fmap Just . parseFromString parseInlines)
348344 val
349345
346+addBlockAttribute :: String -> String -> OrgParser ()
347+addBlockAttribute key val = updateState $ \s ->
348+ let attrs = orgStateBlockAttributes s
349+ in s{ orgStateBlockAttributes = M.insert key val attrs }
350+
351+lookupBlockAttribute :: String -> OrgParser (Maybe String)
352+lookupBlockAttribute key =
353+ M.lookup key . orgStateBlockAttributes <$> getState
354+
350355
351356--
352357-- Org Blocks (#+BEGIN_... / #+END_...)
@@ -402,11 +407,11 @@ exportsResults :: [(String, String)] -> Bool
402407exportsResults attrs = ("rundoc-exports", "results") `elem` attrs
403408 || ("rundoc-exports", "both") `elem` attrs
404409
405−followingResultsBlock :: OrgParser (Maybe String)
410+followingResultsBlock :: OrgParser (Maybe (F Blocks))
406411followingResultsBlock =
407412 optionMaybe (try $ blanklines *> stringAnyCase "#+RESULTS:"
408413 *> blankline
409− *> (unlines <$> many1 exampleLine))
414+ *> block)
410415
411416codeBlock :: BlockProperties -> OrgParser (F Blocks)
412417codeBlock blkProp = do
@@ -421,7 +426,7 @@ codeBlock blkProp = do
421426 labelledBlck <- maybe (pure codeBlck)
422427 (labelDiv codeBlck)
423428 <$> lookupInlinesAttr "caption"
424− let resultBlck = pure $ maybe mempty (exampleCode) resultsContent
429+ let resultBlck = fromMaybe mempty resultsContent
425430 return $ (if includeCode then labelledBlck else mempty)
426431 <> (if includeResults then resultBlck else mempty)
427432 where