aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2015-05-23 13:17:10 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2015-05-23 13:17:10 +0200
commit40fb102417c1fafd39f0b636de7e14fd8a85f675 (patch)
tree8c089bbae06976e9b6e318b76e534004325323f8 /src
parentd5f367d04b9b7830ead3e3298aafe3987e55c697 (diff)
downloadpandoc-40fb102417c1fafd39f0b636de7e14fd8a85f675.tar.gz
Reorder block arguments parsing code
Group code used to parse block arguments together in one place. This seems better than having part of the code mixed between unrelated parsing state changing functions.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Org.hs31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 83fb48764..f3e8fc1f7 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -172,19 +172,6 @@ recordAnchorId :: String -> OrgParser ()
recordAnchorId i = updateState $ \s ->
s{ orgStateAnchorIds = i : (orgStateAnchorIds s) }
-addBlockAttribute :: String -> String -> OrgParser ()
-addBlockAttribute key val = updateState $ \s ->
- let attrs = orgStateBlockAttributes s
- in s{ orgStateBlockAttributes = M.insert key val attrs }
-
-lookupBlockAttribute :: String -> OrgParser (Maybe String)
-lookupBlockAttribute key =
- M.lookup key . orgStateBlockAttributes <$> getState
-
-resetBlockAttributes :: OrgParser ()
-resetBlockAttributes = updateState $ \s ->
- s{ orgStateBlockAttributes = orgStateBlockAttributes def }
-
updateLastForbiddenCharPos :: OrgParser ()
updateLastForbiddenCharPos = getPosition >>= \p ->
updateState $ \s -> s{ orgStateLastForbiddenCharPos = Just p}
@@ -312,9 +299,18 @@ block = choice [ mempty <$ blanklines
, paraOrPlain
] <?> "block"
+--
+-- Block Attributes
+--
+
+-- | Parse optional block attributes (like #+TITLE or #+NAME)
optionalAttributes :: OrgParser (F Blocks) -> OrgParser (F Blocks)
optionalAttributes parser = try $
resetBlockAttributes *> parseBlockAttributes *> parser
+ where
+ resetBlockAttributes :: OrgParser ()
+ resetBlockAttributes = updateState $ \s ->
+ s{ orgStateBlockAttributes = orgStateBlockAttributes def }
parseBlockAttributes :: OrgParser ()
parseBlockAttributes = do
@@ -339,6 +335,15 @@ lookupInlinesAttr attr = try $ do
(fmap Just . parseFromString parseInlines)
val
+addBlockAttribute :: String -> String -> OrgParser ()
+addBlockAttribute key val = updateState $ \s ->
+ let attrs = orgStateBlockAttributes s
+ in s{ orgStateBlockAttributes = M.insert key val attrs }
+
+lookupBlockAttribute :: String -> OrgParser (Maybe String)
+lookupBlockAttribute key =
+ M.lookup key . orgStateBlockAttributes <$> getState
+
--
-- Org Blocks (#+BEGIN_... / #+END_...)