all repos — honk @ 11b9fed2bd760a86c413c477b0ea2aa561a11bc5

my fork of honk

reorder link matching to not eat other tags
Ted Unangst tedu@tedunangst.com
Thu, 24 Oct 2019 23:38:36 -0400
commit

11b9fed2bd760a86c413c477b0ea2aa561a11bc5

parent

e04db806f61b44af0525b956da0fce5c17869474

2 files changed, 15 insertions(+), 2 deletions(-)

jump to
M markitzero.gomarkitzero.go

@@ -72,11 +72,11 @@ }

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_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>") - s = re_link.ReplaceAllStringFunc(s, linkreplacer) - s = re_zerolink.ReplaceAllString(s, `<a class="mention u-url" href="$2">$1</a>`) // restore images s = strings.Replace(s, "&lt;img x&gt;", "<img x>", -1)
M markitzero_test.gomarkitzero_test.go

@@ -65,6 +65,19 @@ output := `quoted "<a class="mention u-url" 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>` + doonezerotest(t, input, output) +} + +func TestBoldLink(t *testing.T) { + t.SkipNow() + 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>` + 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>`