Skip to content

Commit

Permalink
Allow hsx to parse spaces in closing tags
Browse files Browse the repository at this point in the history
Some people structure their HTML code in a way that introduces spaces in
the closing tags. This is valid HTML, but the hsx parser will
complain when copying the HTML into hsx.

The following should be valid hsx after this change:

<!-- Example 1 -->
<span>
    <i class="fab fa-html5"></i
                        >
</span>

<!-- Example 2 -->
<span>
    <i class="fab fa-html5"></i >
</span>
  • Loading branch information
zarak committed Jan 19, 2021
1 parent 0b4e60a commit 3a16b8f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions IHP/HtmlSupport/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,14 @@ hsxSplicedValue = do
Left error -> fail (show error)
pure (ExpressionValue haskellExpression)

hsxClosingElement name = do
_ <- string ("</" <> name <> ">")
pure ()
hsxClosingElement name = (hsxClosingElement' name) <?> friendlyErrorMessage
where
friendlyErrorMessage = show (Text.unpack ("</" <> name <> ">"))
hsxClosingElement' name = do
_ <- string ("</" <> name)
space
char ('>')
pure ()

hsxChild = hsxElement <|> hsxSplicedNode <|> hsxText

Expand Down

0 comments on commit 3a16b8f

Please sign in to comment.