Muse reader: allow empty headers
Previously empty headers caused parser to terminate without parsing the rest of the document.
This commit is contained in:
parent
f202279902
commit
8df59952bf
2 changed files with 8 additions and 7 deletions
|
@ -172,12 +172,6 @@ getIndent :: PandocMonad m
|
|||
=> MuseParser m Int
|
||||
getIndent = subtract 1 . sourceColumn <$ many spaceChar <*> getPosition
|
||||
|
||||
someUntil :: (Stream s m t)
|
||||
=> ParserT s u m a
|
||||
-> ParserT s u m b
|
||||
-> ParserT s u m ([a], b)
|
||||
someUntil p end = first <$> ((:) <$> p) <*> manyUntil p end
|
||||
|
||||
-- ** HTML parsers
|
||||
|
||||
openTag :: PandocMonad m => String -> MuseParser m [(String, String)]
|
||||
|
@ -462,7 +456,7 @@ paraContentsUntil :: PandocMonad m
|
|||
=> MuseParser m a -- ^ Terminator parser
|
||||
-> MuseParser m (F Inlines, a)
|
||||
paraContentsUntil end = first (trimInlinesF . mconcat)
|
||||
<$> someUntil inline (try (manyTill spaceChar eol *> local (\s -> s { museInPara = True}) end))
|
||||
<$> manyUntil inline (try (manyTill spaceChar eol *> local (\s -> s { museInPara = True}) end))
|
||||
|
||||
-- | Parse a paragraph.
|
||||
paraUntil :: PandocMonad m
|
||||
|
|
|
@ -650,6 +650,13 @@ tests =
|
|||
T.unlines [ "* Foo"
|
||||
, "bar"
|
||||
] =?> header 1 "Foo\nbar"
|
||||
, "Empty header" =:
|
||||
T.unlines [ "Foo"
|
||||
, ""
|
||||
, "* "
|
||||
, ""
|
||||
, "bar"
|
||||
] =?> para (text "Foo") <> header 1 "" <> para (text "bar")
|
||||
, test (purely $ readMuse def { readerExtensions = extensionsFromList [Ext_amuse, Ext_auto_identifiers]})
|
||||
"Auto identifiers"
|
||||
(T.unlines [ "* foo"
|
||||
|
|
Loading…
Reference in a new issue