move escId to BuilderQQ

This commit is contained in:
Rhiannon Morris 2020-08-03 19:37:44 +02:00
parent 981319483a
commit d2b2fdf2a5
2 changed files with 10 additions and 8 deletions

View file

@ -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 /= '-'