Fixed small bug in RST list parsing.
See #3432. Previously the parser didn't handle properly this case: * - a - b * - c - d
This commit is contained in:
parent
92a5445aa1
commit
1a23bc65b8
2 changed files with 21 additions and 3 deletions
|
@ -548,8 +548,7 @@ listItem :: PandocMonad m
|
||||||
listItem start = try $ do
|
listItem start = try $ do
|
||||||
(markerLength, first) <- rawListItem start
|
(markerLength, first) <- rawListItem start
|
||||||
rest <- many (listContinuation markerLength)
|
rest <- many (listContinuation markerLength)
|
||||||
blanks <- choice [ try (many blankline <* lookAhead start),
|
skipMany1 blankline <|> () <$ lookAhead start
|
||||||
many1 blankline ] -- whole list must end with blank.
|
|
||||||
-- parsing with ListItemState forces markers at beginning of lines to
|
-- parsing with ListItemState forces markers at beginning of lines to
|
||||||
-- count as list item markers, even if not separated by blank space.
|
-- count as list item markers, even if not separated by blank space.
|
||||||
-- see definition of "endline"
|
-- see definition of "endline"
|
||||||
|
@ -557,7 +556,7 @@ listItem start = try $ do
|
||||||
let oldContext = stateParserContext state
|
let oldContext = stateParserContext state
|
||||||
setState $ state {stateParserContext = ListItemState}
|
setState $ state {stateParserContext = ListItemState}
|
||||||
-- parse the extracted block, which may itself contain block elements
|
-- 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})
|
updateState (\st -> st {stateParserContext = oldContext})
|
||||||
return $ case B.toList parsed of
|
return $ case B.toList parsed of
|
||||||
[Para xs] -> B.singleton $ Plain xs
|
[Para xs] -> B.singleton $ Plain xs
|
||||||
|
|
19
test/command/3432a.md
Normal file
19
test/command/3432a.md
Normal file
|
@ -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>
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue