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 /= '-'
|
||||
|
|
|
@ -145,13 +145,6 @@ altButton i (Image {label, path, nsfw, warning}) = [b|@4
|
|||
path' = pageFile path
|
||||
warning' = ifJust warning \w -> [b| data-warning="$*w"|]
|
||||
|
||||
escId :: Strict.Text -> Builder
|
||||
escId = foldMap esc1 . Strict.unpack where
|
||||
esc1 c
|
||||
| Char.isSpace c = ""
|
||||
| c < 'ÿ' && not (Char.isAlphaNum c || c == '-') = "_"
|
||||
| otherwise = [b|$'c|]
|
||||
|
||||
makeTags :: [Strict.Text] -> Builder
|
||||
makeTags tags =
|
||||
if null tags then "" else [b|@4
|
||||
|
|
Loading…
Reference in a new issue