escape data-warning attr
This commit is contained in:
parent
046dc59834
commit
258b1c6102
2 changed files with 10 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
|||
module BuilderQQ
|
||||
(b,
|
||||
Builder, toLazyText, fromText, fromString, fromChar,
|
||||
textMap, ifJust, escId)
|
||||
textMap, ifJust, escId, escAttr)
|
||||
where
|
||||
|
||||
import Data.Char (isLower, isSpace, isDigit, isAlphaNum)
|
||||
|
@ -159,6 +159,14 @@ escId = foldMap esc1 . Text.unpack where
|
|||
latin1Special c =
|
||||
c <= 'ÿ' && not (isAlphaNum c) && c /= '-'
|
||||
|
||||
escAttr :: Text -> Builder
|
||||
escAttr = foldMap esc1 . Text.unpack where
|
||||
esc1 '<' = "<"
|
||||
esc1 '>' = ">"
|
||||
esc1 '"' = """
|
||||
esc1 '\'' = "'"
|
||||
esc1 c = fromChar c
|
||||
|
||||
|
||||
class CanBuild a where
|
||||
build :: a -> Builder
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue