@@ -263,17 +263,15 @@ note = try (do
263263 raw <- sepBy rawLines (try (do {blankline; indentSpaces}))
264264 option "" blanklines
265265 -- parse the extracted text, which may contain various block elements:
266+ rest <- getInput
267+ setInput $ (joinWithSep "\n" raw) ++ "\n\n"
268+ contents <- parseBlocks
269+ setInput rest
266270 state <- getState
267− let parsed = case runParser parseBlocks
268− (state {stateParserContext = BlockQuoteState}) "block"
269− ((joinWithSep "\n" raw) ++ "\n\n") of
270− Left err -> error $ "Raw block:\n" ++ show raw ++
271− "\nError:\n" ++ show err
272− Right result -> result
273271 let identifiers = stateNoteIdentifiers state
274272 case (findIndex (== ref) identifiers) of
275273 Just n -> updateState (\s -> s {stateNoteBlocks =
276− (Note (show (n+1)) parsed):(stateNoteBlocks s)})
274+ (Note (show (n+1)) contents):(stateNoteBlocks s)})
277275 Nothing -> updateState id
278276 return Null)
279277
@@ -315,15 +313,12 @@ emailBlockQuote = try (do
315313blockQuote = do
316314 raw <- choice [ emailBlockQuote, emacsBoxQuote ]
317315 -- parse the extracted block, which may contain various block elements:
318− state <- getState
319− let parsed = case runParser parseBlocks
320− (state {stateParserContext = BlockQuoteState}) "block"
321− ((joinWithSep "\n" raw) ++ "\n\n") of
322− Left err -> error $ "Raw block:\n" ++ show raw ++
323− "\nError:\n" ++ show err
324− Right result -> result
325− return (BlockQuote parsed)
326−
316+ rest <- getInput
317+ setInput $ (joinWithSep "\n" raw) ++ "\n\n"
318+ contents <- parseBlocks
319+ setInput rest
320+ return (BlockQuote contents)
321+
327322--
328323-- list blocks
329324--
@@ -382,19 +377,21 @@ listContinuationLine start = try (do
382377
383378listItem start = try (do
384379 first <- rawListItem start
385− rest <- many (listContinuation start)
380+ continuations <- many (listContinuation start)
386381 -- parsing with ListItemState forces markers at beginning of lines to
387382 -- count as list item markers, even if not separated by blank space.
388383 -- see definition of "endline"
389384 state <- getState
390− let parsed = case runParser parseBlocks
391− (state {stateParserContext = ListItemState})
392− "block" raw of
393− Left err -> error $ "Raw block:\n" ++ raw ++
394− "\nError:\n" ++ show err
395− Right result -> result
396− where raw = concat (first:rest)
397− return parsed)
385+ let oldContext = stateParserContext state
386+ setState $ state {stateParserContext = ListItemState}
387+ -- parse the extracted block, which may contain various block elements:
388+ rest <- getInput
389+ let raw = concat (first:continuations)
390+ setInput $ raw
391+ contents <- parseBlocks
392+ setInput rest
393+ updateState (\st -> st {stateParserContext = oldContext})
394+ return contents)
398395
399396orderedList = try (do
400397 items <- many1 (listItem orderedListStart)