Skip to content

Commit 2deb5d8

Browse files
committed
Fix attributeParser, add a test case for attr1 attr2='val'
1 parent 7d37fd6 commit 2deb5d8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Html/Parser.purs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import Data.List (List)
1717
import Data.List as List
1818
import Data.String.CodeUnits (fromCharArray)
1919
import Text.Parsing.StringParser (Parser, ParseError, runParser, try)
20-
import Text.Parsing.StringParser.Combinators (many, manyTill, option, optional, sepEndBy)
2120
import Text.Parsing.StringParser.CodeUnits (anyChar, regex, skipSpaces, string, whiteSpace)
21+
import Text.Parsing.StringParser.Combinators (many, manyTill, option, optional, sepEndBy)
2222

2323
data HtmlNode
2424
= HtmlElement Element
@@ -53,7 +53,8 @@ charListToString = fromCharArray <<< Array.fromFoldable
5353

5454
attributeParser :: Parser HtmlAttribute
5555
attributeParser = do
56-
k <- regex "[^=>/]+"
56+
k <- regex "[^=>/ ]+"
57+
void whiteSpace
5758
v <- option "" (equals *> quotedString)
5859
pure $ HtmlAttribute k v
5960

test/Main.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ rightHtml :: Array String
8080
rightHtml =
8181
[ "<iframe></iframe>"
8282
, "<iframe width ></iframe>"
83+
, "<iframe width src='//'></iframe>"
8384
, """<iframe width ="560" ></iframe>"""
8485
, "<iframe width='560' ></iframe>"
8586
, """<iframe width = "560" ></iframe>"""

0 commit comments

Comments
 (0)