move escId to BuilderQQ
This commit is contained in:
parent
981319483a
commit
d2b2fdf2a5
2 changed files with 10 additions and 8 deletions
|
@ -2,7 +2,7 @@
|
|||
module BuilderQQ
|
||||
(b,
|
||||
Builder, toLazyText, fromText, fromString, fromChar,
|
||||
textMap, ifJust)
|
||||
textMap, ifJust, escId)
|
||||
where
|
||||
|
||||
import Data.Char (isLower, isSpace, isDigit, isAlphaNum)
|
||||
|
@ -189,3 +189,12 @@ textMap f = Text.foldl' (\buf c -> buf <> f c) mempty
|
|||
|
||||
ifJust :: Monoid b => Maybe a -> (a -> b) -> b
|
||||
ifJust x f = maybe mempty f x
|
||||
|
||||
|
||||
escId :: Text -> Builder
|
||||
escId = foldMap esc1 . Text.unpack where
|
||||
esc1 c | isSpace c = ""
|
||||
| latin1Special c = "_"
|
||||
| otherwise = fromChar c
|
||||
latin1Special c =
|
||||
c <= 'ÿ' && not (isAlphaNum c) && c /= '-'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue