aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-08-19 00:18:46 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-08-19 00:18:46 +0000
commit81eba062f2e447fb1c266bc3f08b3b1ce2aeabc4 (patch)
tree87406afbd0e9e27fe0e16aad1e83edd223005ede /src/Text/Pandoc
parent4e149f898a3fff677e042f670f04a7d42c78edd3 (diff)
downloadpandoc-81eba062f2e447fb1c266bc3f08b3b1ce2aeabc4.tar.gz
Refactor RST and Markdown readers using parseFromString.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@864 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc')
-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