Muse reader: try to parse lists before trying to parse table

This ensures that tables inside lists are parsed correctly.
This commit is contained in:
Alexander Krotov 2018-10-28 03:52:25 +03:00
parent d8135b2e67
commit e34a0703f5
2 changed files with 15 additions and 3 deletions

View file

@ -256,8 +256,8 @@ parseBlocks :: PandocMonad m
parseBlocks =
try (parseEnd <|>
nextSection <|>
blockStart <|>
listStart <|>
blockStart <|>
paraStart)
where
nextSection = mempty <$ lookAhead headingStart
@ -287,7 +287,7 @@ parseBlocksTill end = continuation
blockStart = (B.<>) <$> blockElements <*> allowPara continuation
listStart = uncurry (B.<>) <$> allowPara (anyListUntil (parseEnd <|> continuation))
paraStart = uncurry (B.<>) <$> paraUntil (parseEnd <|> continuation)
continuation = try $ parseEnd <|> blockStart <|> listStart <|> paraStart
continuation = try $ parseEnd <|> listStart <|> blockStart <|> paraStart
listItemContentsUntil :: PandocMonad m
=> Int
@ -296,7 +296,7 @@ listItemContentsUntil :: PandocMonad m
-> MuseParser m (F Blocks, a)
listItemContentsUntil col pre end = p
where
p = try blockStart <|> try listStart <|> try paraStart
p = try listStart <|> try blockStart <|> try paraStart
parsePre = (mempty,) <$> pre
parseEnd = (mempty,) <$> end
paraStart = do

View file

@ -1328,6 +1328,18 @@ tests =
]
])
]
, "Definition list with table" =:
" foo :: bar | baz" =?>
definitionList [ ("foo", [ table mempty [(AlignDefault, 0.0), (AlignDefault, 0.0)]
[]
[[plain "bar", plain "baz"]]
])]
, "Definition list with table inside bullet list" =:
" - foo :: bar | baz" =?>
bulletList [definitionList [ ("foo", [ table mempty [(AlignDefault, 0.0), (AlignDefault, 0.0)]
[]
[[plain "bar", plain "baz"]]
])]]
, test emacsMuse "Multi-line definition lists from Emacs Muse manual"
(T.unlines
[ "Term1 ::"