android: show markdown in messages (#361)

* android: show markdown in messages

* empty line
This commit is contained in:
Evgeny Poberezkin
2022-02-23 12:30:48 +00:00
committed by GitHub
parent 8f21453e82
commit 470b18786e
9 changed files with 143 additions and 32 deletions
+6 -6
View File
@@ -32,7 +32,7 @@ data Format
| StrikeThrough
| Snippet
| Secret
| Colored {formatColor :: FormatColor}
| Colored {color :: FormatColor}
| Uri
| Email
| Phone
@@ -178,13 +178,13 @@ markdownP = mconcat <$> A.many' fragmentP
ss = b <> s <> a
coloredP :: Parser Markdown
coloredP = do
color <- A.takeWhile (\c -> c /= ' ' && c /= colorMD)
case M.lookup color colors of
cStr <- A.takeWhile (\c -> c /= ' ' && c /= colorMD)
case M.lookup cStr colors of
Just c ->
let f = Colored c
in (A.char ' ' *> formattedP colorMD (color `T.snoc` ' ') f)
<|> noFormat (colorMD `T.cons` color)
_ -> noFormat (colorMD `T.cons` color)
in (A.char ' ' *> formattedP colorMD (cStr `T.snoc` ' ') f)
<|> noFormat (colorMD `T.cons` cStr)
_ -> noFormat (colorMD `T.cons` cStr)
wordsP :: Parser Markdown
wordsP = do
word <- wordMD <$> A.takeTill (== ' ')
+2 -2
View File
@@ -83,8 +83,8 @@ data ChatItem (c :: ChatType) (d :: MsgDirection) = ChatItem
deriving (Show, Generic)
instance ToJSON (ChatItem c d) where
toJSON = J.genericToJSON J.defaultOptions
toEncoding = J.genericToEncoding J.defaultOptions
toJSON = J.genericToJSON J.defaultOptions {J.omitNothingFields = True}
toEncoding = J.genericToEncoding J.defaultOptions {J.omitNothingFields = True}
data CIDirection (c :: ChatType) (d :: MsgDirection) where
CIDirectSnd :: CIDirection 'CTDirect 'MDSnd