mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-11 06:47:01 +00:00
fix: md format
This commit is contained in:
parent
ceb5873272
commit
19f358ef9c
@ -1,3 +1,5 @@
|
||||
import sequtils
|
||||
|
||||
proc sectionIdentifier(message: Message): string =
|
||||
result = message.fromAuthor
|
||||
# Force section change, because group status messages are sent with the
|
||||
@ -15,16 +17,15 @@ proc mention(self: ChatMessageList, pubKey: string): string =
|
||||
proc renderInline(self: ChatMessageList, elem: TextItem): string =
|
||||
case elem.textType:
|
||||
of "": result = elem.literal
|
||||
of "code": result = fmt("<span style=\"background-color: #1a356b; color: #FFFFFF\">{elem.literal}</span> ")
|
||||
of "emph": result = fmt("<span style=\"font-style: italic;\">{elem.literal}</span> ")
|
||||
of "strong": result = fmt("<span style=\"font-weight: bold;\">{elem.literal}</span> ")
|
||||
of "code": result = fmt("<code>{elem.literal.strip}</code> ")
|
||||
of "emph": result = fmt("<em>{elem.literal}</em> ")
|
||||
of "strong": result = fmt("<strong>{elem.literal}</strong> ")
|
||||
of "link": result = elem.destination
|
||||
of "mention": result = fmt("<a href=\"//{elem.literal}\" style=\"font-weight: bold; color: #000000;\">{self.mention(elem.literal)}</a> ")
|
||||
of "mention": result = fmt("<a href=\"//{elem.literal}\" class=\"mention\">{self.mention(elem.literal)}</a> ")
|
||||
of "status-tag": result = fmt("<a href=\"#{elem.literal}\" class=\"status-tag\">{elem.literal}</a> ")
|
||||
|
||||
# See render-block in status-react/src/status_im/ui/screens/chat/message/message.cljs
|
||||
proc renderBlock(self: ChatMessageList, message: Message): string =
|
||||
# TODO: find out how to extract the css styles
|
||||
for pMsg in message.parsedText:
|
||||
case pMsg.textType:
|
||||
of "paragraph":
|
||||
@ -33,9 +34,8 @@ proc renderBlock(self: ChatMessageList, message: Message): string =
|
||||
result = result & self.renderInline(children)
|
||||
result = result & "</p>"
|
||||
of "blockquote":
|
||||
# TODO: extract this from the theme somehow
|
||||
var color = if message.isCurrentUser: "#FFFFFF" else: "#666666"
|
||||
result = result & fmt("<span style=\"color: {color}\">▍ ") & pMsg.literal & "</span>"
|
||||
result = result & pMsg.literal.strip.split("\n").mapIt("<span>▍ " & it & "</span>").join("<br />")
|
||||
of "codeblock":
|
||||
result = result & "<table style=\"background-color: #1a356b;\"><tr><td style=\"padding: 5px;\"><code style=\"color: #ffffff\">" & pMsg.literal & "</code></td></tr></table>"
|
||||
result = result.replace("\n", "<br />")
|
||||
result = result & "<code>" & pMsg.literal.strip & "</code>"
|
||||
result = result.strip()
|
||||
|
||||
|
@ -366,10 +366,39 @@ Item {
|
||||
textFormat: TextEdit.RichText
|
||||
text: {
|
||||
if(contentType === Constants.stickerType) return "";
|
||||
let msg = linkify(message);
|
||||
if(isEmoji){
|
||||
return Emoji.parse(linkify(message), "72x72");
|
||||
return Emoji.parse(msg, "72x72");
|
||||
} else {
|
||||
return Emoji.parse(linkify(message), "26x26");
|
||||
return `<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
code {
|
||||
background-color: #1a356b;
|
||||
color: #FFFFFF;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
p {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
a.mention {
|
||||
color: ${isCurrentUser ? Style.current.black : Style.current.white}
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
${Emoji.parse(msg, "26x26")}
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user