Skip to content

Commit

Permalink
Fixed multiline attribute value parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
RussBaz committed Mar 21, 2024
1 parent 528350a commit 4849e61
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Resources/Pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ <h1>
hx-target="body"
data-loading-delay
data-loading-disable
onfocus="console.log('?');
console.log('This is drastic?');
console.log('too many');"
>
What's up?
</button>
Expand Down
2 changes: 2 additions & 0 deletions Sources/Core/SimpleHtmlParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public final class SimpleHtmlParser {
} else {
state = .lookingForAttributeValue(tag: tag, attributes: attributes, key: key, value: value + String(char), wrapper: wrapper)
}
} else if char == "\n", wrapper != .none {
state = .lookingForAttributeValue(tag: tag, attributes: attributes, key: key, value: value + String(" "), wrapper: wrapper)
} else if char == "\"" {
switch wrapper {
case .single:
Expand Down
2 changes: 1 addition & 1 deletion Sources/Example/pages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ enum Pages {
}
lines.append("""
</p>
<button class="button" hx-post="/auth/logout?next=/" hx-target="body" data-loading-delay data-loading-disable>
<button class="button" hx-post="/auth/logout?next=/" hx-target="body" onfocus="console.log('?'); console.log('This is drastic?'); console.log('too many');" data-loading-delay data-loading-disable>
What's up?
</button>
</main>
Expand Down

0 comments on commit 4849e61

Please sign in to comment.