diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2018-10-21 06:42:00 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2018-10-21 06:42:00 +0300 |
commit | 8df59952bf54321a0e24a1e9104324c7ae9c153f (patch) | |
tree | a8f1c457d145d01404fe6c877e3e93c4a2d9c446 | |
parent | f202279902da34dfa4f22e4e53cb0bf93d519d1e (diff) | |
download | pandoc-8df59952bf54321a0e24a1e9104324c7ae9c153f.tar.gz |
Muse reader: allow empty headers
Previously empty headers caused parser to terminate without parsing the rest of the document.
-rw-r--r-- | src/Text/Pandoc/Readers/Muse.hs | 8 | ||||
-rw-r--r-- | test/Tests/Readers/Muse.hs | 7 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 3b64fe5ef..b973486b1 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -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 diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index 75dd4e7da..ab0579519 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -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" |