aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs20
-rw-r--r--src/Text/Pandoc/Readers/RST.hs15
2 files changed, 7 insertions, 28 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index abf8061e0..f4b97527f 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -195,10 +195,7 @@ noteBlock = try $ do
raw <- sepBy rawLines (try (blankline >> indentSpaces))
optional blanklines
-- parse the extracted text, which may contain various block elements:
- rest <- getInput
- setInput $ (joinWithSep "\n" raw) ++ "\n\n"
- contents <- parseBlocks
- setInput rest
+ contents <- parseFromString parseBlocks $ (joinWithSep "\n" raw) ++ "\n\n"
return $ NoteBlock ref contents
--
@@ -307,10 +304,7 @@ emailBlockQuote = try $ do
blockQuote = do
raw <- emailBlockQuote <|> emacsBoxQuote
-- parse the extracted block, which may contain various block elements:
- rest <- getInput
- setInput $ (joinWithSep "\n" raw) ++ "\n\n"
- contents <- parseBlocks
- setInput rest
+ contents <- parseFromString parseBlocks $ (joinWithSep "\n" raw) ++ "\n\n"
return $ BlockQuote contents
--
@@ -393,11 +387,8 @@ listItem start = try $ do
let oldContext = stateParserContext state
setState $ state {stateParserContext = ListItemState}
-- parse the extracted block, which may contain various block elements:
- rest <- getInput
let raw = concat (first:continuations)
- setInput raw
- contents <- parseBlocks
- setInput rest
+ contents <- parseFromString parseBlocks raw
updateState (\st -> st {stateParserContext = oldContext})
return contents
@@ -419,10 +410,7 @@ definitionListItem = try $ do
state <- getState
let oldContext = stateParserContext state
-- parse the extracted block, which may contain various block elements:
- rest <- getInput
- setInput (concat raw)
- contents <- parseBlocks
- setInput rest
+ contents <- parseFromString parseBlocks $ concat raw
updateState (\st -> st {stateParserContext = oldContext})
return ((normalizeSpaces term), contents)
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 878c1355c..abbf502a1 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -328,10 +328,7 @@ rawLaTeXBlock = try $ do
blockQuote = try $ do
raw <- indentedBlock True
-- parse the extracted block, which may contain various block elements:
- rest <- getInput
- setInput $ raw ++ "\n\n"
- contents <- parseBlocks
- setInput rest
+ contents <- parseFromString parseBlocks $ raw ++ "\n\n"
return $ BlockQuote contents
--
@@ -344,10 +341,7 @@ definitionListItem = try $ do
term <- many1Till inline endline
raw <- indentedBlock True
-- parse the extracted block, which may contain various block elements:
- rest <- getInput
- setInput $ raw ++ "\n\n"
- contents <- parseBlocks
- setInput rest
+ contents <- parseFromString parseBlocks $ raw ++ "\n\n"
return (normalizeSpaces term, contents)
definitionList = try $ do
@@ -408,12 +402,9 @@ listItem start = try $ do
-- see definition of "endline"
state <- getState
let oldContext = stateParserContext state
- remaining <- getInput
setState $ state {stateParserContext = ListItemState}
-- parse the extracted block, which may itself contain block elements
- setInput $ concat (first:rest) ++ blanks
- parsed <- parseBlocks
- setInput remaining
+ parsed <- parseFromString parseBlocks $ concat (first:rest) ++ blanks
updateState (\st -> st {stateParserContext = oldContext})
return parsed