From 3439b94e0ee1f063f710197ec8303854332536b8 Mon Sep 17 00:00:00 2001 From: ReK2 Date: Mon, 17 Aug 2020 21:03:28 +0200 Subject: [PATCH] fix changes requested --- config/config.go | 4 ---- ui/commands.go | 4 ---- ui/messages/html/parser.go | 35 ++--------------------------------- 3 files changed, 2 insertions(+), 41 deletions(-) diff --git a/config/config.go b/config/config.go index 3f7ff1c..7afe21f 100644 --- a/config/config.go +++ b/config/config.go @@ -50,11 +50,7 @@ type UserPreferences struct { DisableHTML bool `yaml:"disable_html"` DisableDownloads bool `yaml:"disable_downloads"` DisableNotifications bool `yaml:"disable_notifications"` -<<<<<<< HEAD DisableShowURLs bool `yaml:"disable_show_urls"` -======= - DisableShowurls bool `yaml:"disable_show_urls"` ->>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0 } // Config contains the main config of gomuks. diff --git a/ui/commands.go b/ui/commands.go index e666cdc..d9469fc 100644 --- a/ui/commands.go +++ b/ui/commands.go @@ -766,11 +766,7 @@ func cmdToggle(cmd *Command) { case "unverified": val = &cmd.Config.SendToVerifiedOnly case "showurls": -<<<<<<< HEAD val = &cmd.Config.Preferences.DisableShowURLs -======= - val = &cmd.Config.Preferences.DisableShowurls ->>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0 default: cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing) return diff --git a/ui/messages/html/parser.go b/ui/messages/html/parser.go index 342d2d2..fd5db96 100644 --- a/ui/messages/html/parser.go +++ b/ui/messages/html/parser.go @@ -41,16 +41,8 @@ import ( var matrixToURL = regexp.MustCompile("^(?:https?://)?(?:www\\.)?matrix\\.to/#/([#@!].*)") type htmlParser struct { -<<<<<<< HEAD - prefs *config.UserPreferences - room *rooms.Room - sameURL bool -======= - prefs *config.UserPreferences - room *rooms.Room - mautrixnolink bool - sameURL bool ->>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0 + prefs *config.UserPreferences + room *rooms.Room keepLinebreak bool } @@ -208,7 +200,6 @@ func (parser *htmlParser) linkToEntity(node *html.Node) Entity { if len(entity.Children) == 1 { entity, ok := entity.Children[0].(*TextEntity) if ok && entity.Text == href { -<<<<<<< HEAD sameURL = true } } @@ -216,17 +207,6 @@ func (parser *htmlParser) linkToEntity(node *html.Node) Entity { if !parser.prefs.DisableShowURLs && !parser.hasAttribute(node, "data-mautrix-no-link") && !sameURL { entity.Children = append(entity.Children, NewTextEntity(fmt.Sprintf(" (%s)", href))) -======= - parser.sameURL = true - } - } - - if !parser.prefs.DisableShowurls && !parser.mautrixnolink && !parser.sameURL { - entity.Children = append( - []Entity{NewTextEntity("(" + href + ") ")}, - parser.nodeToEntities(node.FirstChild)..., - ) ->>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0 } match := matrixToURL.FindStringSubmatch(href) @@ -435,24 +415,13 @@ const TabLength = 4 // Parse parses a HTML-formatted Matrix event into a UIMessage. func Parse(prefs *config.UserPreferences, room *rooms.Room, content *event.MessageEventContent, sender id.UserID, senderDisplayname string) Entity { htmlData := content.FormattedBody -<<<<<<< HEAD -======= - DataMautrixNoLink := false ->>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0 if content.Format != event.FormatHTML { htmlData = strings.Replace(html.EscapeString(content.Body), "\n", "
", -1) } htmlData = strings.Replace(htmlData, "\t", strings.Repeat(" ", TabLength), -1) -<<<<<<< HEAD parser := htmlParser{room: room, prefs: prefs} -======= - if strings.Contains(htmlData, "data-mautrix-no-link") { - DataMautrixNoLink = true - } - parser := htmlParser{room: room, prefs: prefs, mautrixnolink: DataMautrixNoLink} ->>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0 root := parser.Parse(htmlData) beRoot := root.(*ContainerEntity) beRoot.Block = false