Skip to content

Commit 9a40a15

Browse files
committed
Remove Html.Parser.Util.toVirtualDomSvg
1 parent fd1db04 commit 9a40a15

File tree

4 files changed

+14
-55
lines changed

4 files changed

+14
-55
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [2.0.0] - 2018-12-06
10+
### Removed
11+
- `Html.Parser.Util.toVirtualDomSvg` as parsing of SVG nodes is not implemented yet.
12+
913
## [1.1.0] - 2018-12-06
1014
### Added
1115
- `Html.Parser.Util` to transform parser nodes into virtual dom nodes.
@@ -22,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2226

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

25-
[Unreleased]: https://github.com/hecrj/html-parser/compare/1.1.0...HEAD
29+
[Unreleased]: https://github.com/hecrj/html-parser/compare/2.0.0...HEAD
30+
[2.0.0]: https://github.com/hecrj/html-parser/compare/1.1.0...2.0.0
2631
[1.1.0]: https://github.com/hecrj/html-parser/compare/1.0.1...1.1.0
2732
[1.0.1]: https://github.com/hecrj/html-parser/compare/1.0.0...1.0.1

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ Html.Parser.run "<div><p>Hello, world!</p></div>"
1010
```
1111

1212
## Limitations
13-
* `<script>` tags are not fully supported yet! Feel free to contribute!
13+
* `<script>` tags are not fully supported.
14+
* SVG is not supported.
15+
16+
Feel free to contribute!
1417

1518

1619
## Contributing / Feedback

elm.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "hecrj/html-parser",
44
"summary": "Parse HTML 5 in Elm",
55
"license": "BSD-3-Clause",
6-
"version": "1.1.0",
6+
"version": "2.0.0",
77
"exposed-modules": [
88
"Html.Parser",
99
"Html.Parser.Util"
@@ -13,7 +13,6 @@
1313
"elm/core": "1.0.0 <= v < 2.0.0",
1414
"elm/html": "1.0.0 <= v < 2.0.0",
1515
"elm/parser": "1.0.0 <= v < 2.0.0",
16-
"elm/svg": "1.0.1 <= v < 2.0.0",
1716
"elm/virtual-dom": "1.0.2 <= v < 2.0.0",
1817
"rtfeldman/elm-hex": "1.0.0 <= v < 2.0.0"
1918
},

src/Html/Parser/Util.elm

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
module Html.Parser.Util exposing (toVirtualDom, toVirtualDomSvg)
1+
module Html.Parser.Util exposing (toVirtualDom)
22

33
{-| Utility functions that may help you digging into the contents.
44
55
66
# Virtual DOM
77
8-
@docs toVirtualDom, toVirtualDomSvg
8+
@docs toVirtualDom
99
1010
-}
1111

1212
import Html exposing (..)
1313
import Html.Attributes exposing (..)
1414
import Html.Parser exposing (Node(..))
15-
import Svg exposing (Svg)
16-
import Svg.Attributes
1715
import VirtualDom
1816

1917

@@ -28,11 +26,7 @@ toVirtualDomEach : Node -> Html msg
2826
toVirtualDomEach node =
2927
case node of
3028
Element name attrs children ->
31-
if name == "svg" then
32-
toVirtualDomSvgEach node
33-
34-
else
35-
Html.node name (List.map toAttribute attrs) (toVirtualDom children)
29+
Html.node name (List.map toAttribute attrs) (toVirtualDom children)
3630

3731
Text s ->
3832
text s
@@ -44,45 +38,3 @@ toVirtualDomEach node =
4438
toAttribute : ( String, String ) -> Attribute msg
4539
toAttribute ( name, value ) =
4640
attribute name value
47-
48-
49-
{-| Converts nodes to virtual dom SVG nodes.
50-
51-
Note: If node list contains `<svg>` tag, you can use `toVirtualDom` instead.
52-
Otherwise, use this function.
53-
54-
svg : Svg msg
55-
svg =
56-
parse """<circle cx="40" cy="40" r="24" style="stroke:#006600; fill:#00cc00"/>"""
57-
|> toVirtualDomSvg
58-
|> Svg.svg []
59-
60-
-}
61-
toVirtualDomSvg : List Node -> List (Svg msg)
62-
toVirtualDomSvg nodes =
63-
List.map toVirtualDomSvgEach nodes
64-
65-
66-
toVirtualDomSvgEach : Node -> Svg msg
67-
toVirtualDomSvgEach node =
68-
case node of
69-
Element name attrs children ->
70-
Svg.node name (List.map toSvgAttribute attrs) (toVirtualDomSvg children)
71-
72-
Text s ->
73-
text s
74-
75-
Comment _ ->
76-
text ""
77-
78-
79-
toSvgAttribute : ( String, String ) -> Attribute msg
80-
toSvgAttribute ( name, value ) =
81-
if String.startsWith "xlink:" name then
82-
VirtualDom.attributeNS "http://www.w3.org/1999/xlink" name value
83-
84-
else if String.startsWith "xml:" name then
85-
VirtualDom.attributeNS "http://www.w3.org/XML/1998/namespace" name value
86-
87-
else
88-
VirtualDom.attribute name value

0 commit comments

Comments
 (0)