all repos — honk @ dba7053a450858409dfe6ceb087b2af50f222db6

my fork of honk

better quick rename needs to be earlier for consistency
Ted Unangst tedu@tedunangst.com
Sat, 09 Nov 2019 16:33:34 -0500
commit

dba7053a450858409dfe6ceb087b2af50f222db6

parent

22ce83ee5f3c1c8f53a09e344c1fa90bfedaddcc

2 files changed, 9 insertions(+), 6 deletions(-)

jump to
M fun.gofun.go

@@ -204,7 +204,6 @@ }

honk.Precis = markitzero(strings.TrimSpace(honk.Precis)) noise = strings.TrimSpace(noise) - noise = quickrename(noise, honk.UserID) noise = markitzero(noise) honk.Noise = noise honk.Onts = oneofakind(ontologies(honk.Noise))

@@ -375,7 +374,7 @@ }

honk.Noise = re_memes.ReplaceAllStringFunc(honk.Noise, repl) } -var re_quickmention = regexp.MustCompile("(^| )@[[:alnum:]]+( |$)") +var re_quickmention = regexp.MustCompile("(^|[ \n])@[[:alnum:]]+([ \n]|$)") func quickrename(s string, userid int64) string { nonstop := true

@@ -383,13 +382,15 @@ for nonstop {

nonstop = false s = re_quickmention.ReplaceAllStringFunc(s, func(m string) string { prefix := "" - if m[0] == ' ' { - prefix = " " + if m[0] == ' ' || m[0] == '\n' { + prefix = m[:1] m = m[1:] } prefix += "@" m = m[1:] - if m[len(m)-1] == ' ' { + tail := "" + if m[len(m)-1] == ' ' || m[len(m)-1] == '\n' { + tail = m[len(m)-1:] m = m[:len(m)-1] }

@@ -402,7 +403,7 @@ nonstop = true

m = name } } - return prefix + m + " " + return prefix + m + tail }) } return s
M web.goweb.go

@@ -1342,6 +1342,8 @@ Format: "markdown",

} } + noise = strings.Replace(noise, "\r", "", -1) + noise = quickrename(noise, userinfo.UserID) noise = hooterize(noise) honk.Noise = noise translate(honk, false)