Skip to content

Commit

Permalink
Space attributes properly in nodeToString
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Mar 10, 2019
1 parent 43c641a commit 6cd8621
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [2.3.1] - 2019-03-10
### Changed
- `Html.Parser.nodeToString` spaces attributes properly.

## [2.3.0] - 2019-03-10
### Added
- `Html.Parser.nodeToString` to turn parser nodes back into its HTML representation.
Expand Down Expand Up @@ -42,7 +46,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

[named-character-references]: https://www.w3.org/TR/html5/syntax.html#named-character-references

[Unreleased]: https://github.com/hecrj/html-parser/compare/2.3.0...HEAD
[Unreleased]: https://github.com/hecrj/html-parser/compare/2.3.1...HEAD
[2.3.1]: https://github.com/hecrj/html-parser/compare/2.3.0...2.3.1
[2.3.0]: https://github.com/hecrj/html-parser/compare/2.2.0...2.3.0
[2.2.0]: https://github.com/hecrj/html-parser/compare/2.1.0...2.2.0
[2.1.0]: https://github.com/hecrj/html-parser/compare/2.0.1...2.1.0
Expand Down
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "hecrj/html-parser",
"summary": "Parse HTML 5 in Elm",
"license": "BSD-3-Clause",
"version": "2.3.0",
"version": "2.3.1",
"exposed-modules": [
"Html.Parser",
"Html.Parser.Util"
Expand Down
2 changes: 1 addition & 1 deletion src/Html/Parser.elm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ nodeToString node_ =
""

_ ->
" " ++ String.join "" (List.map attributeToString attributes)
" " ++ String.join " " (List.map attributeToString attributes)
in
if isVoidElement name then
String.concat
Expand Down
9 changes: 9 additions & 0 deletions tests/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ nodeToStringTests =
]
|> Html.Parser.nodeToString
|> Expect.equal "<div><p>Hello,</p><p>World!</p></div>"
, test "multiple attributes" <|
\_ ->
Element "a"
[ ( "href", "https://elm-lang.org" )
, ( "alt", "Elm website" )
]
[ Text "Elm" ]
|> Html.Parser.nodeToString
|> Expect.equal "<a href=\"https://elm-lang.org\" alt=\"Elm website\">Elm</a>"
, test "void element" <|
\_ ->
Element "br" [] [ Element "a" [] [ Text "should be ignored" ] ]
Expand Down

0 comments on commit 6cd8621

Please sign in to comment.