all repos — honk @ 9059c7452b81f408e5c46487a1c2a26af2589ddb

my fork of honk

hackish, but yet more effective, means of getting class=mention on all links
Ted Unangst tedu@tedunangst.com
Mon, 28 Oct 2019 16:05:18 -0400
commit

9059c7452b81f408e5c46487a1c2a26af2589ddb

parent

ddc61615a1aafa81de8da6e6c55697e11e134bd9

3 files changed, 13 insertions(+), 12 deletions(-)

jump to
M fun.gofun.go

@@ -220,6 +220,7 @@ p, _ := htf.String(honk.Precis)

n, _ := htf.String(honk.Noise) honk.Precis = string(p) honk.Noise = string(n) + honk.Noise = strings.Replace(honk.Noise, "<a href=", "<a class=\"mention u-url\" href=", -1) } j := 0 for i := 0; i < len(honk.Donks); i++ {

@@ -469,7 +470,7 @@ if h[0] != '#' {

p = h[:1] h = h[1:] } - return fmt.Sprintf(`%s<a class="mention u-url" href="https://%s/o/%s">%s</a>`, p, serverName, + return fmt.Sprintf(`%s<a href="https://%s/o/%s">%s</a>`, p, serverName, strings.ToLower(h[1:]), h) }) return s
M markitzero.gomarkitzero.go

@@ -73,7 +73,7 @@ s = string(buf)

// mark it zero s = re_link.ReplaceAllStringFunc(s, linkreplacer) - s = re_zerolink.ReplaceAllString(s, `<a class="mention u-url" href="$2">$1</a>`) + s = re_zerolink.ReplaceAllString(s, `<a href="$2">$1</a>`) s = re_bolder.ReplaceAllString(s, "$1<b>$2</b>$3") s = re_italicer.ReplaceAllString(s, "$1<i>$2</i>$3") s = re_quoter.ReplaceAllString(s, "<blockquote>$1</blockquote><p>")

@@ -128,7 +128,7 @@ if strings.HasSuffix(url, ".") {

url = url[:len(url)-1] adddot = true } - url = fmt.Sprintf(`<a class="mention u-url" href="%s">%s</a>`, url, url) + url = fmt.Sprintf(`<a href="%s">%s</a>`, url, url) if adddot { url += "." }
M markitzero_test.gomarkitzero_test.go

@@ -13,7 +13,7 @@ }

func TestBasictest(t *testing.T) { input := `link to https://example.com/ with **bold** text` - output := `link to <a class="mention u-url" href="https://example.com/">https://example.com/</a> with <b>bold</b> text` + output := `link to <a href="https://example.com/">https://example.com/</a> with <b>bold</b> text` doonezerotest(t, input, output) }

@@ -49,48 +49,48 @@ }

func TestSimplelink(t *testing.T) { input := "This is a [link](https://example.com)." - output := `This is a <a class="mention u-url" href="https://example.com">link</a>.` + output := `This is a <a href="https://example.com">link</a>.` doonezerotest(t, input, output) } func TestSimplelink2(t *testing.T) { input := "See (http://example.com) for examples." - output := `See (<a class="mention u-url" href="http://example.com">http://example.com</a>) for examples.` + output := `See (<a href="http://example.com">http://example.com</a>) for examples.` doonezerotest(t, input, output) } func TestWikilink(t *testing.T) { input := "I watched [Hackers](https://en.wikipedia.org/wiki/Hackers_(film))" - output := `I watched <a class="mention u-url" href="https://en.wikipedia.org/wiki/Hackers_(film)">Hackers</a>` + output := `I watched <a href="https://en.wikipedia.org/wiki/Hackers_(film)">Hackers</a>` doonezerotest(t, input, output) } func TestQuotedlink(t *testing.T) { input := `quoted "https://example.com/link" here` - output := `quoted "<a class="mention u-url" href="https://example.com/link">https://example.com/link</a>" here` + output := `quoted "<a href="https://example.com/link">https://example.com/link</a>" here` doonezerotest(t, input, output) } func TestLinkinQuote(t *testing.T) { input := `> a quote and https://example.com/link` - output := `<blockquote>a quote and <a class="mention u-url" href="https://example.com/link">https://example.com/link</a></blockquote><p>` + output := `<blockquote>a quote and <a href="https://example.com/link">https://example.com/link</a></blockquote><p>` doonezerotest(t, input, output) } func TestBoldLink(t *testing.T) { input := `**b https://example.com/link b**` - output := `<b>b <a class="mention u-url" href="https://example.com/link">https://example.com/link</a> b</b>` + output := `<b>b <a href="https://example.com/link">https://example.com/link</a> b</b>` doonezerotest(t, input, output) } func TestHonklink(t *testing.T) { input := `https://en.wikipedia.org/wiki/Honk!` - output := `<a class="mention u-url" href="https://en.wikipedia.org/wiki/Honk!">https://en.wikipedia.org/wiki/Honk!</a>` + output := `<a href="https://en.wikipedia.org/wiki/Honk!">https://en.wikipedia.org/wiki/Honk!</a>` doonezerotest(t, input, output) } func TestImagelink(t *testing.T) { input := `an image <img alt="caption" src="https://example.com/wherever"> and linked [<img src="there">](example.com)` - output := `an image <img alt="caption" src="https://example.com/wherever"> and linked <a class="mention u-url" href="example.com"><img src="there"></a>` + output := `an image <img alt="caption" src="https://example.com/wherever"> and linked <a href="example.com"><img src="there"></a>` doonezerotest(t, input, output) }