Muse reader: require closing tag to have the same indentation as opening

This commit is contained in:
Alexander Krotov
2018-03-12 14:24:50 +03:00
parent f0a029ac51
commit c3fbc492c8
2 changed files with 20 additions and 1 deletions
+2 -1
View File
@@ -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
+18
View File
@@ -1242,5 +1242,23 @@ tests =
, " </verse>"
] =?>
bulletList [ para "<quote>" <> lineBlock [ "</quote>" ] ]
-- Allowing indented closing tags is dangerous,
-- as they may terminate lists
, "No indented closing tags" =:
T.unlines
[ "<quote>"
, ""
, " - Foo"
, ""
, " </quote>"
, ""
, " bar"
, ""
, " <verse>"
, " </quote>"
, " </verse>"
] =?>
para "<quote>" <> bulletList [ para "Foo" <> para "</quote>" <> para "bar" <> lineBlock [ "</quote>" ] ]
]
]