git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: require closing tag to have the same indentation as opening
commitc3fbc492c8795c0cd92f29f69d01819e8dccec93 authorAlexander Krotov <ilabdsf@gmail.com> dateMon 12 Mar 2018, 14:24 (9 years ago) parentf0a029a
2 files changed+20−1
src/Text/Pandoc/Readers/Muse.hs+2−1 test/Tests/Readers/Muse.hs+18
src/Text/Pandoc/Readers/Muse.hs+2−1
@@ -169,9 +169,10 @@ parseHtmlContent :: PandocMonad m
169169 => String -> MuseParser m (Attr, F Blocks)
170170parseHtmlContent tag = try $ do
171171 many spaceChar
172+ pos <- getPosition
172173 (TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
173174 manyTill spaceChar eol
174− content <- parseBlocksTill (try $ manyTill spaceChar endtag)
175+ content <- parseBlocksTill (try $ ((count (sourceColumn pos - 1) spaceChar) >> endtag))
175176 manyTill spaceChar eol -- closing tag must be followed by optional whitespace and newline
176177 return (htmlAttrToPandoc attr, content)
177178 where
test/Tests/Readers/Muse.hs+18
@@ -1242,5 +1242,23 @@ tests =
12421242 , " </verse>"
12431243 ] =?>
12441244 bulletList [ para "<quote>" <> lineBlock [ "</quote>" ] ]
1245+
1246+ -- Allowing indented closing tags is dangerous,
1247+ -- as they may terminate lists
1248+ , "No indented closing tags" =:
1249+ T.unlines
1250+ [ "<quote>"
1251+ , ""
1252+ , " - Foo"
1253+ , ""
1254+ , " </quote>"
1255+ , ""
1256+ , " bar"
1257+ , ""
1258+ , " <verse>"
1259+ , " </quote>"
1260+ , " </verse>"
1261+ ] =?>
1262+ para "<quote>" <> bulletList [ para "Foo" <> para "</quote>" <> para "bar" <> lineBlock [ "</quote>" ] ]
12451263 ]
12461264 ]