diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 293bc627c..c8868b20d 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -169,9 +169,10 @@ parseHtmlContent :: PandocMonad m
=> String -> MuseParser m (Attr, F Blocks)
parseHtmlContent tag = try $ do
many spaceChar
+ pos <- getPosition
(TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
manyTill spaceChar eol
- content <- parseBlocksTill (try $ manyTill spaceChar endtag)
+ content <- parseBlocksTill (try $ ((count (sourceColumn pos - 1) spaceChar) >> endtag))
manyTill spaceChar eol -- closing tag must be followed by optional whitespace and newline
return (htmlAttrToPandoc attr, content)
where
diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs
index f64927ff1..f961083ef 100644
--- a/test/Tests/Readers/Muse.hs
+++ b/test/Tests/Readers/Muse.hs
@@ -1242,5 +1242,23 @@ tests =
, " "
] =?>
bulletList [ para "" <> lineBlock [ "
" ] ]
+
+ -- Allowing indented closing tags is dangerous,
+ -- as they may terminate lists
+ , "No indented closing tags" =:
+ T.unlines
+ [ ""
+ , ""
+ , " - Foo"
+ , ""
+ , "
"
+ , ""
+ , " bar"
+ , ""
+ , " "
+ , " "
+ , " "
+ ] =?>
+ para "" <> bulletList [ para "Foo" <> para "
" <> para "bar" <> lineBlock [ "" ] ]
]
]