Skip to content

Commit b15d57b

Browse files
remove makeXmlElementNoEnd
1 parent bf6720f commit b15d57b

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ svg content =
1616

1717
contents :: Element
1818
contents =
19-
rect_ [ Width <<- "100%", Height <<- "100%", "red" ->> Fill] nil
20-
<> circle_ [ Cx <<- "150", Cy <<- "100", R <<- "80", Fill <<- "green"] nil
19+
rect_ [ Width <<- "100%", Height <<- "100%", "red" ->> Fill]
20+
<> circle_ [ Cx <<- "150", Cy <<- "100", R <<- "80", Fill <<- "green"]
2121
<> text_ [ X <<- "150", Y <<- "125", Font_size <<- "60"
2222
, Text_anchor <<- "middle", Fill <<- "white"] "SVG"
2323

examples/path.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Data.Text.Lazy as T
66

77
svg :: Element -> Element
88
svg content =
9-
doctype_
9+
doctype
1010
<> with (svg11_ content) [Width <<- "325", Height <<- "325"]
1111

1212
contents :: Element
@@ -15,7 +15,7 @@ contents =
1515
[ D <<- (mA 10 80 <> qA 52.5 10 95 80 <> tA 180 80 <> z)
1616
, Stroke <<- "blue"
1717
, Fill <<- "orange"
18-
] nil
18+
]
1919

2020
main :: IO ()
2121
main = do

examples/simple.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Lucid.Svg
44

55
svg :: Element -> Element
66
svg content =
7-
doctype_
7+
doctype
88
<> with (svg11_ content) [Version <<- "1.1", Width <<- "300", Height <<- "200"]
99

1010
contents :: Element

src/Lucid/Svg.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ prettyText svg = B.toLazyText $ LT.foldr go mempty text Nothing (-1)
7979
-- <text>Hello</text><text>SVG</text>
8080
--
8181
-- Attributes are set by providing an argument list. Each argument is set
82-
-- using the 'bindAttr' function or operators, ' <<-' and '-->'.
82+
-- using the 'bindAttr' function or operators, ' <<-' and '->>'.
8383
--
8484
-- >>> rect_ [Width <<- "100%", Height <<- "100%", "red" ->> Fill] nil
8585
-- <rect height="100%" width="100%" fill="red"></rect>
@@ -102,13 +102,13 @@ prettyText svg = B.toLazyText $ LT.foldr go mempty text Nothing (-1)
102102
-- >
103103
-- > svg :: Element -> Element
104104
-- > svg content =
105-
-- > doctype_
106-
-- > <> with (svg11_ content) [version_ "1.1", width_ "300" , height_ "200"]
105+
-- > doctype
106+
-- > <> with (svg11_ content) [Version <<- "1.1", Width <<- "300" , Height <<- "200"]
107107
-- >
108108
-- > contents :: Element
109109
-- > contents =
110-
-- > rect_ [Width <<- "100%", Height <<- "100%", Fill <<- "red"] nil
111-
-- > <> circle_ [Cx <<- "150", Cy <<- "100", R <<- "80", Fill <<- "green"] nil
110+
-- > rect_ [Width <<- "100%", Height <<- "100%", Fill <<- "red"]
111+
-- > <> circle_ [Cx <<- "150", Cy <<- "100", R <<- "80", Fill <<- "green"]
112112
-- > <> text_ [ X <<- "150", Y <<- "125", FontSize <<- "60"
113113
-- > , TextAnchor <<- "middle", Fill <<- "white" ] "SVG"
114114
-- >

src/Lucid/Svg/Core.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module Lucid.Svg.Core
2121
-- * Combinators
2222
, makeAttribute
2323
, makeElement
24+
, makeElementDoctype
2425
, makeElementNoEnd
25-
, makeXmlElementNoEnd
2626
, with
2727
-- * Rendering
2828
, renderBS
@@ -78,14 +78,14 @@ instance ToElement LT.Text where
7878

7979
-- | Used to make specific SVG element builders.
8080
class Term result where
81-
-- | Used for constructing elements e.g. @term "p"@ yields 'Lucid.Html5.p_'.
81+
-- | Used for constructing elements e.g. @term "circle"@ yields 'circle_'.
8282
term :: Text -> [Attribute] -> result
8383

8484
instance (e ~ Element) => Term (e -> Element) where
8585
term name attrs e = with (makeElement name e) attrs
8686

8787
instance Term Element where
88-
term name attrs = with (makeXmlElementNoEnd name) attrs
88+
term name attrs = with (makeElementNoEnd name) attrs
8989

9090
--------------------------------------------------------------------------------
9191
-- Combinators
@@ -117,17 +117,17 @@ makeElement name (Element c) = Element $ \a -> go c a
117117
<> children mempty
118118
<> s2b "</" <> BB.fromText name <> s2b ">"
119119

120-
-- | Make an SVG element builder with no end tag.
121-
makeElementNoEnd :: Text -> Element
122-
makeElementNoEnd name = Element $ \a -> go a
120+
-- | Make an SVG element builder with no end tag,.
121+
makeElementDoctype :: Text -> Element
122+
makeElementDoctype name = Element $ \a -> go a
123123
where
124124
go attrs =
125125
s2b "<" <> BB.fromText name
126126
<> foldlMapWithKey buildAttr attrs <> s2b ">"
127127

128128
-- | Make an XML element with no end tag.
129-
makeXmlElementNoEnd :: Text -> Element
130-
makeXmlElementNoEnd name = Element $ \a -> go a
129+
makeElementNoEnd :: Text -> Element
130+
makeElementNoEnd name = Element $ \a -> go a
131131
where
132132
go attrs =
133133
s2b "<" <> BB.fromText name

src/Lucid/Svg/Elements.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ module Lucid.Svg.Elements where
1717
import Lucid.Svg.Core
1818

1919
-- | @DOCTYPE@ element
20-
doctype_ :: Element
21-
doctype_ = makeElementNoEnd "?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\""
20+
doctype :: Element
21+
doctype = makeElementDoctype "?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\""
2222

2323
-- | @svg@ element + svg 1.1 Attribute
2424
svg11_:: Element -> Element
@@ -200,11 +200,11 @@ fontFace_ = term "font-face"
200200

201201
-- | @fontFaceFormat@ element
202202
fontFaceFormat_ :: [Attribute] -> Element
203-
fontFaceFormat_ = with $ makeXmlElementNoEnd "font-face-format"
203+
fontFaceFormat_ = with $ makeElementNoEnd "font-face-format"
204204

205205
-- | @fontFaceName@ element
206206
fontFaceName_ :: [Attribute] -> Element
207-
fontFaceName_ = with $ makeXmlElementNoEnd "font-face-name"
207+
fontFaceName_ = with $ makeElementNoEnd "font-face-name"
208208

209209
-- | @fontFaceSrc@ element
210210
fontFaceSrc_ :: Term result => [Attribute] -> result
@@ -228,11 +228,11 @@ glyph_ = term "glyph"
228228

229229
-- | @glyphref@ element
230230
glyphRef_ :: [Attribute] -> Element
231-
glyphRef_ = with $ makeXmlElementNoEnd "glyphRef"
231+
glyphRef_ = with $ makeElementNoEnd "glyphRef"
232232

233233
-- | @hkern@ element
234234
hkern_ :: [Attribute] -> Element
235-
hkern_ = with $ makeXmlElementNoEnd "hkern"
235+
hkern_ = with $ makeElementNoEnd "hkern"
236236

237237
-- | @image@ element
238238
image_ :: Term result => [Attribute] -> result
@@ -348,4 +348,4 @@ view_ = term "view"
348348

349349
-- | @vkern@ element
350350
vkern_ :: [Attribute] -> Element
351-
vkern_ = with $ makeXmlElementNoEnd "vkern"
351+
vkern_ = with $ makeElementNoEnd "vkern"

0 commit comments

Comments
 (0)