Skip to content

Commit 042e5cc

Browse files
authored
Merge pull request bodil#46 from hgiasac/master
only allow rendering self closing tags for SVG and void elements
2 parents aebdf34 + 757f223 commit 042e5cc

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/.tern-port
55
*.tix
66
/.psc-package
7+
/.pulp-cache
8+
.psc-ide-port

src/Text/Smolder/Markup.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ data Attr = Attr String String
3737

3838
data EventHandler e = EventHandler String e
3939

40+
derive instance eqNS :: Eq NS
41+
4042
instance functorEventHandlerFunctor EventHandler where
4143
map f (EventHandler s e) = EventHandler s (f e)
4244

src/Text/Smolder/Renderer/String.purs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Control.Comonad (extend)
88
import Control.Comonad.Cofree (Cofree, head, mkCofree, tail, (:<))
99
import Control.Monad.Free (foldFree)
1010
import Control.Monad.State (State, evalState, execState, get, put, state)
11-
import Data.Array ((..))
11+
import Data.Array (notElem, (..))
1212
import Data.CatList (CatList)
1313
import Data.Char (toCharCode)
1414
import Data.Foldable (elem, fold, foldr)
@@ -18,6 +18,7 @@ import Data.Set (Set)
1818
import Data.Set as Set
1919
import Data.String.CodeUnits (fromCharArray, toCharArray)
2020
import Data.String (length)
21+
import Data.String.CodeUnits (fromCharArray, toCharArray)
2122
import Data.Tuple (Tuple(..))
2223
import Data.Tuple.Nested ((/\))
2324
import Global.Unsafe (unsafeEncodeURI)
@@ -153,6 +154,9 @@ showAttrs tag = map showAttr >>> fold
153154
<> escapeAttrValue tag key value
154155
<> "\""
155156

157+
voidTags :: Array String
158+
voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]
159+
156160
renderItem :: e. MarkupM e ~> State String
157161
renderItem (Element ns name children attrs _ rest) =
158162
let c = render children

0 commit comments

Comments
 (0)