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
|
=> MuseParser m Int
|
||||||
getIndent = subtract 1 . sourceColumn <$ many spaceChar <*> getPosition
|
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
|
-- ** HTML parsers
|
||||||
|
|
||||||
openTag :: PandocMonad m => String -> MuseParser m [(String, String)]
|
openTag :: PandocMonad m => String -> MuseParser m [(String, String)]
|
||||||
|
@ -462,7 +456,7 @@ paraContentsUntil :: PandocMonad m
|
||||||
=> MuseParser m a -- ^ Terminator parser
|
=> MuseParser m a -- ^ Terminator parser
|
||||||
-> MuseParser m (F Inlines, a)
|
-> MuseParser m (F Inlines, a)
|
||||||
paraContentsUntil end = first (trimInlinesF . mconcat)
|
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.
|
-- | Parse a paragraph.
|
||||||
paraUntil :: PandocMonad m
|
paraUntil :: PandocMonad m
|
||||||
|
|
|
@ -650,6 +650,13 @@ tests =
|
||||||
T.unlines [ "* Foo"
|
T.unlines [ "* Foo"
|
||||||
, "bar"
|
, "bar"
|
||||||
] =?> header 1 "Foo\nbar"
|
] =?> 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]})
|
, test (purely $ readMuse def { readerExtensions = extensionsFromList [Ext_amuse, Ext_auto_identifiers]})
|
||||||
"Auto identifiers"
|
"Auto identifiers"
|
||||||
(T.unlines [ "* foo"
|
(T.unlines [ "* foo"
|
||||||
|
|
Loading…
Reference in a new issue