fix: close rather than clear style tags (#541)
This commit is contained in:
parent
9cb3f72969
commit
232f4d469b
2 changed files with 20 additions and 8 deletions
|
|
@ -143,13 +143,13 @@ func (mt *MessagesText) createMsg(msg discord.Message) {
|
|||
|
||||
func (mt *MessagesText) drawTimestamps(ts discord.Timestamp) {
|
||||
time := ts.Time().In(time.Local).Format(mt.cfg.Timestamps.Format)
|
||||
fmt.Fprintf(mt, "[::d]%s[::-] ", time)
|
||||
fmt.Fprintf(mt, "[::d]%s[::D] ", time)
|
||||
}
|
||||
|
||||
func (mt *MessagesText) drawAuthor(msg discord.Message) {
|
||||
name := mt.authorName(msg.Author, msg.GuildID)
|
||||
color := mt.authorColor(msg.Author, msg.GuildID)
|
||||
fmt.Fprintf(mt, "[%s]%s[-:-:-] ", color, name)
|
||||
fmt.Fprintf(mt, "[%s]%s[-] ", color, name)
|
||||
}
|
||||
|
||||
func (mt *MessagesText) drawContent(msg discord.Message) {
|
||||
|
|
@ -167,7 +167,7 @@ func (mt *MessagesText) createDefaultMsg(msg discord.Message) {
|
|||
mt.drawContent(msg)
|
||||
|
||||
if msg.EditedTimestamp.IsValid() {
|
||||
io.WriteString(mt, " [::d](edited)[::-]")
|
||||
io.WriteString(mt, " [::d](edited)[::D]")
|
||||
}
|
||||
|
||||
for _, a := range msg.Attachments {
|
||||
|
|
@ -183,9 +183,10 @@ func (mt *MessagesText) createDefaultMsg(msg discord.Message) {
|
|||
func (mt *MessagesText) createReplyMsg(msg discord.Message) {
|
||||
// reply
|
||||
fmt.Fprintf(mt, "[::d]%s ", mt.cfg.Theme.MessagesText.ReplyIndicator)
|
||||
if msg.ReferencedMessage != nil {
|
||||
mt.drawAuthor(*msg.ReferencedMessage)
|
||||
mt.drawContent(*msg.ReferencedMessage)
|
||||
if refMsg := msg.ReferencedMessage; refMsg != nil {
|
||||
refMsg.GuildID = msg.GuildID
|
||||
mt.drawAuthor(*refMsg)
|
||||
mt.drawContent(*refMsg)
|
||||
}
|
||||
|
||||
io.WriteString(mt, tview.NewLine)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,18 @@ func (r *renderer) Render(w io.Writer, source []byte, n ast.Node) error {
|
|||
io.WriteString(w, "[::r]")
|
||||
}
|
||||
} else {
|
||||
io.WriteString(w, "[::-]")
|
||||
switch n.Attr {
|
||||
case discordmd.AttrBold:
|
||||
io.WriteString(w, "[::B]")
|
||||
case discordmd.AttrItalics:
|
||||
io.WriteString(w, "[::I]")
|
||||
case discordmd.AttrUnderline:
|
||||
io.WriteString(w, "[::U]")
|
||||
case discordmd.AttrStrikethrough:
|
||||
io.WriteString(w, "[::S]")
|
||||
case discordmd.AttrMonospace:
|
||||
io.WriteString(w, "[::R]")
|
||||
}
|
||||
}
|
||||
case *discordmd.Mention:
|
||||
if entering {
|
||||
|
|
@ -105,7 +116,7 @@ func (r *renderer) Render(w io.Writer, source []byte, n ast.Node) error {
|
|||
io.WriteString(w, "@"+n.GuildRole.Name)
|
||||
}
|
||||
} else {
|
||||
io.WriteString(w, "[::-]")
|
||||
io.WriteString(w, "[::B]")
|
||||
}
|
||||
case *discordmd.Emoji:
|
||||
if entering {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue