summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-02-11 20:55:13 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-02-11 20:55:13 +0100
commit1a23bc65b8e8a07d2578ddb0f3b842353ba81dcf (patch)
tree327ca46cde7be31cfb9913c6507240a15cb88639
parent92a5445aa1a0f9d6ff76c2dd97fd742033ff84ce (diff)
Fixed small bug in RST list parsing.
See #3432. Previously the parser didn't handle properly this case: * - a - b * - c - d
-rw-r--r--src/Text/Pandoc/Readers/RST.hs5
-rw-r--r--test/command/3432a.md19
2 files changed, 21 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index c5ddbbad8..ebb1d09e9 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -548,8 +548,7 @@ listItem :: PandocMonad m
listItem start = try $ do
(markerLength, first) <- rawListItem start
rest <- many (listContinuation markerLength)
- blanks <- choice [ try (many blankline <* lookAhead start),
- many1 blankline ] -- whole list must end with blank.
+ skipMany1 blankline <|> () <$ lookAhead start
-- parsing with ListItemState forces markers at beginning of lines to
-- count as list item markers, even if not separated by blank space.
-- see definition of "endline"
@@ -557,7 +556,7 @@ listItem start = try $ do
let oldContext = stateParserContext state
setState $ state {stateParserContext = ListItemState}
-- parse the extracted block, which may itself contain block elements
- parsed <- parseFromString parseBlocks $ concat (first:rest) ++ blanks
+ parsed <- parseFromString parseBlocks $ concat (first:rest) ++ "\n"
updateState (\st -> st {stateParserContext = oldContext})
return $ case B.toList parsed of
[Para xs] -> B.singleton $ Plain xs
diff --git a/test/command/3432a.md b/test/command/3432a.md
new file mode 100644
index 000000000..5f25bce60
--- /dev/null
+++ b/test/command/3432a.md
@@ -0,0 +1,19 @@
+```
+% pandoc -f rst
+* - a
+ - b
+* - c
+ - d
+^D
+<ul>
+<li><ul>
+<li>a</li>
+<li>b</li>
+</ul></li>
+<li><ul>
+<li>c</li>
+<li>d</li>
+</ul></li>
+</ul>
+```
+