git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: require closing tag to have the same indentation as opening
c3fbc49Alexander Krotov
src/Text/Pandoc/Readers/Muse.hs+2−1
@@ -169,9 +169,10 @@ parseHtmlContent :: PandocMonad m
169 => String -> MuseParser m (Attr, F Blocks)
169 => String -> MuseParser m (Attr, F Blocks)
170parseHtmlContent tag = try $ do
170parseHtmlContent tag = try $ do
171 many spaceChar
171 many spaceChar
172+ pos <- getPosition
172 (TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
173 (TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
173 manyTill spaceChar eol
174 manyTill spaceChar eol
174− content <- parseBlocksTill (try $ manyTill spaceChar endtag)
175+ content <- parseBlocksTill (try $ ((count (sourceColumn pos - 1) spaceChar) >> endtag))
175 manyTill spaceChar eol -- closing tag must be followed by optional whitespace and newline
176 manyTill spaceChar eol -- closing tag must be followed by optional whitespace and newline
176 return (htmlAttrToPandoc attr, content)
177 return (htmlAttrToPandoc attr, content)
177 where
178 where
test/Tests/Readers/Muse.hs+18
@@ -1242,5 +1242,23 @@ tests =
1242 , " </verse>"
1242 , " </verse>"
1243 ] =?>
1243 ] =?>
1244 bulletList [ para "<quote>" <> lineBlock [ "</quote>" ] ]
1244 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>" ] ]
1245 ]
1263 ]
1246 ]
1264 ]