fix changes requested
This commit is contained in:
parent
0f77c17e9c
commit
3439b94e0e
@ -50,11 +50,7 @@ type UserPreferences struct {
|
|||||||
DisableHTML bool `yaml:"disable_html"`
|
DisableHTML bool `yaml:"disable_html"`
|
||||||
DisableDownloads bool `yaml:"disable_downloads"`
|
DisableDownloads bool `yaml:"disable_downloads"`
|
||||||
DisableNotifications bool `yaml:"disable_notifications"`
|
DisableNotifications bool `yaml:"disable_notifications"`
|
||||||
<<<<<<< HEAD
|
|
||||||
DisableShowURLs bool `yaml:"disable_show_urls"`
|
DisableShowURLs bool `yaml:"disable_show_urls"`
|
||||||
=======
|
|
||||||
DisableShowurls bool `yaml:"disable_show_urls"`
|
|
||||||
>>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config contains the main config of gomuks.
|
// Config contains the main config of gomuks.
|
||||||
|
@ -766,11 +766,7 @@ func cmdToggle(cmd *Command) {
|
|||||||
case "unverified":
|
case "unverified":
|
||||||
val = &cmd.Config.SendToVerifiedOnly
|
val = &cmd.Config.SendToVerifiedOnly
|
||||||
case "showurls":
|
case "showurls":
|
||||||
<<<<<<< HEAD
|
|
||||||
val = &cmd.Config.Preferences.DisableShowURLs
|
val = &cmd.Config.Preferences.DisableShowURLs
|
||||||
=======
|
|
||||||
val = &cmd.Config.Preferences.DisableShowurls
|
|
||||||
>>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0
|
|
||||||
default:
|
default:
|
||||||
cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing)
|
cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing)
|
||||||
return
|
return
|
||||||
|
@ -41,16 +41,8 @@ import (
|
|||||||
var matrixToURL = regexp.MustCompile("^(?:https?://)?(?:www\\.)?matrix\\.to/#/([#@!].*)")
|
var matrixToURL = regexp.MustCompile("^(?:https?://)?(?:www\\.)?matrix\\.to/#/([#@!].*)")
|
||||||
|
|
||||||
type htmlParser struct {
|
type htmlParser struct {
|
||||||
<<<<<<< HEAD
|
prefs *config.UserPreferences
|
||||||
prefs *config.UserPreferences
|
room *rooms.Room
|
||||||
room *rooms.Room
|
|
||||||
sameURL bool
|
|
||||||
=======
|
|
||||||
prefs *config.UserPreferences
|
|
||||||
room *rooms.Room
|
|
||||||
mautrixnolink bool
|
|
||||||
sameURL bool
|
|
||||||
>>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0
|
|
||||||
|
|
||||||
keepLinebreak bool
|
keepLinebreak bool
|
||||||
}
|
}
|
||||||
@ -208,7 +200,6 @@ func (parser *htmlParser) linkToEntity(node *html.Node) Entity {
|
|||||||
if len(entity.Children) == 1 {
|
if len(entity.Children) == 1 {
|
||||||
entity, ok := entity.Children[0].(*TextEntity)
|
entity, ok := entity.Children[0].(*TextEntity)
|
||||||
if ok && entity.Text == href {
|
if ok && entity.Text == href {
|
||||||
<<<<<<< HEAD
|
|
||||||
sameURL = true
|
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 {
|
if !parser.prefs.DisableShowURLs && !parser.hasAttribute(node, "data-mautrix-no-link") && !sameURL {
|
||||||
|
|
||||||
entity.Children = append(entity.Children, NewTextEntity(fmt.Sprintf(" (%s)", href)))
|
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)
|
match := matrixToURL.FindStringSubmatch(href)
|
||||||
@ -435,24 +415,13 @@ const TabLength = 4
|
|||||||
// Parse parses a HTML-formatted Matrix event into a UIMessage.
|
// 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 {
|
func Parse(prefs *config.UserPreferences, room *rooms.Room, content *event.MessageEventContent, sender id.UserID, senderDisplayname string) Entity {
|
||||||
htmlData := content.FormattedBody
|
htmlData := content.FormattedBody
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
DataMautrixNoLink := false
|
|
||||||
>>>>>>> 67c0262587404c2b2912e934092dacdba7cc2ed0
|
|
||||||
|
|
||||||
if content.Format != event.FormatHTML {
|
if content.Format != event.FormatHTML {
|
||||||
htmlData = strings.Replace(html.EscapeString(content.Body), "\n", "<br/>", -1)
|
htmlData = strings.Replace(html.EscapeString(content.Body), "\n", "<br/>", -1)
|
||||||
}
|
}
|
||||||
htmlData = strings.Replace(htmlData, "\t", strings.Repeat(" ", TabLength), -1)
|
htmlData = strings.Replace(htmlData, "\t", strings.Repeat(" ", TabLength), -1)
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
parser := htmlParser{room: room, prefs: prefs}
|
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)
|
root := parser.Parse(htmlData)
|
||||||
beRoot := root.(*ContainerEntity)
|
beRoot := root.(*ContainerEntity)
|
||||||
beRoot.Block = false
|
beRoot.Block = false
|
||||||
|
Loading…
Reference in New Issue
Block a user