Преглед на файлове

feat: add ability to disable markdown (#544)

Ted преди 11 месеца
родител
ревизия
af2b0995ba
променени са 2 файла, в които са добавени 9 реда и са изтрити 1 реда
  1. 5 1
      cmd/messages_text.go
  2. 4 0
      internal/config/config.go

+ 5 - 1
cmd/messages_text.go

@@ -162,7 +162,11 @@ func (mt *MessagesText) drawAuthor(msg discord.Message) {
 func (mt *MessagesText) drawContent(msg discord.Message) {
 	c := []byte(tview.Escape(msg.Content))
 	ast := discordmd.ParseWithMessage(c, *discordState.Cabinet, &msg, false)
-	markdown.DefaultRenderer.Render(mt, c, ast)
+	if app.cfg.MarkdownEnabled {
+		markdown.DefaultRenderer.Render(mt, c, ast)
+	} else {
+		mt.Write(c) // write the content as is
+	}
 }
 
 func (mt *MessagesText) drawSnapshotContent(msg discord.MessageSnapshotMessage) {

+ 4 - 0
internal/config/config.go

@@ -45,6 +45,8 @@ type (
 		ShowAttachmentLinks bool  `toml:"show_attachment_links"`
 		MessagesLimit       uint8 `toml:"messages_limit"`
 
+		MarkdownEnabled bool `toml:"markdown_enabled"`
+
 		Timestamps    Timestamps    `toml:"timestamps"`
 		Identify      Identify      `toml:"identify"`
 		Notifications Notifications `toml:"notifications"`
@@ -63,6 +65,8 @@ func defaultConfig() *Config {
 		ShowAttachmentLinks: true,
 		MessagesLimit:       50,
 
+		MarkdownEnabled: true,
+
 		Timestamps: Timestamps{
 			Enabled: true,
 			Format:  time.Kitchen,