mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 14:14:09 +00:00
core, ui, website: small text markdown (#6697)
* core: small text markdown * ios: small markdown * desktop, android: small markdown * fix font size * small markdown on website * update ios core library * update bot api docs --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
co-authored by
Evgeny Poberezkin
parent
2472bee6b6
commit
a8a8883027
@@ -53,6 +53,7 @@ data Format
|
||||
| StrikeThrough
|
||||
| Snippet
|
||||
| Secret
|
||||
| Small
|
||||
| Colored {color :: FormatColor}
|
||||
| Uri
|
||||
-- showText is Nothing for the usual Uri without text
|
||||
@@ -202,7 +203,7 @@ markdownP = mconcat <$> A.many' fragmentP
|
||||
'~' -> formattedP '~' StrikeThrough
|
||||
'`' -> formattedP '`' Snippet
|
||||
'#' -> A.char '#' *> secretP
|
||||
'!' -> coloredP <|> wordP
|
||||
'!' -> styledP <|> wordP
|
||||
'@' -> mentionP <|> wordP
|
||||
'/' -> commandP <|> wordP
|
||||
'[' -> sowLinkP <|> wordP
|
||||
@@ -228,13 +229,13 @@ markdownP = mconcat <$> A.many' fragmentP
|
||||
| otherwise = markdown Secret $ T.init ss
|
||||
where
|
||||
ss = b <> s <> a
|
||||
coloredP :: Parser Markdown
|
||||
coloredP = do
|
||||
clr <- A.char '!' *> colorP <* A.space
|
||||
styledP :: Parser Markdown
|
||||
styledP = do
|
||||
f <- A.char '!' *> ((A.char '-' $> Small) <|> (colored <$> colorP)) <* A.space
|
||||
s <- ((<>) <$> A.takeWhile1 (\c -> c /= ' ' && c /= '!') <*> A.takeTill (== '!')) <* A.char '!'
|
||||
if T.null s || T.last s == ' '
|
||||
then fail "not colored"
|
||||
else pure $ markdown (colored clr) s
|
||||
then fail "not styled"
|
||||
else pure $ markdown f s
|
||||
mentionP = prefixedStringP '@' displayNameTextP_ Mention
|
||||
commandP = prefixedStringP '/' commandTextP Command
|
||||
prefixedStringP pfx parser format = do
|
||||
@@ -441,6 +442,7 @@ markdownText (FormattedText f_ t) = case f_ of
|
||||
StrikeThrough -> around '~'
|
||||
Snippet -> around '`'
|
||||
Secret -> around '#'
|
||||
Small -> "!- " <> t <> "!"
|
||||
Colored (FormatColor c) -> color c
|
||||
Uri -> t
|
||||
HyperLink {} -> t
|
||||
|
||||
@@ -75,6 +75,7 @@ sgr = \case
|
||||
StrikeThrough -> [SetSwapForegroundBackground True]
|
||||
Colored (FormatColor c) -> [SetColor Foreground Vivid c]
|
||||
Secret -> [SetColor Foreground Dull Black, SetColor Background Dull Black]
|
||||
Small -> [SetConsoleIntensity FaintIntensity]
|
||||
_ -> []
|
||||
|
||||
unStyle :: StyledString -> String
|
||||
|
||||
Reference in New Issue
Block a user