diff options
Diffstat (limited to 'utils/markdown/commonmark_test.go')
-rw-r--r-- | utils/markdown/commonmark_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/utils/markdown/commonmark_test.go b/utils/markdown/commonmark_test.go index 0a0959030..13e61f52d 100644 --- a/utils/markdown/commonmark_test.go +++ b/utils/markdown/commonmark_test.go @@ -999,3 +999,46 @@ func TestCommonMarkReferenceStrings(t *testing.T) { }) } } + +func TestCommonMarkRefernceAutolinks(t *testing.T) { + // These tests are adapted from the GitHub-flavoured CommonMark extension tests located at + // https://github.com/github/cmark/blob/master/test/extensions.txt + for name, tc := range map[string]struct { + Markdown string + ExpectedHTML string + }{ + "autolinks-1": { + Markdown: `: http://google.com https://google.com + +http://google.com/รฅ + +www.github.com www.github.com/รก + +www.google.com/a_b + +![http://inline.com/image](http://inline.com/image) + +Full stop outside parens shouldn't be included http://google.com/ok. + +(Full stop inside parens shouldn't be included http://google.com/ok.) + +"http://google.com" + +'http://google.com' + +http://๐.ga/ http://x๐.ga/`, + ExpectedHTML: `<p>: <a href="http://google.com">http://google.com</a> <a href="https://google.com">https://google.com</a></p><p><a href="http://google.com/%C3%A5">http://google.com/รฅ</a></p><p><a href="http://www.github.com">www.github.com</a> <a href="http://www.github.com/%C3%A1">www.github.com/รก</a></p><p><a href="http://www.google.com/a_b">www.google.com/a_b</a></p><p><img src="http://inline.com/image" alt="http://inline.com/image" /></p><p>Full stop outside parens shouldn't be included <a href="http://google.com/ok">http://google.com/ok</a>.</p><p>(Full stop inside parens shouldn't be included <a href="http://google.com/ok">http://google.com/ok</a>.)</p><p>"<a href="http://google.com">http://google.com</a>"</p><p>'<a href="http://google.com">http://google.com</a>'</p><p><a href="http://%F0%9F%8D%84.ga/">http://๐.ga/</a> <a href="http://x%F0%9F%8D%84.ga/">http://x๐.ga/</a></p>`, + }, + "autolinks-2": { + Markdown: `These should not link: + +* @a.b.c@. x +* n@. b`, + ExpectedHTML: `<p>These should not link:</p><ul><li>@a.b.c@. x</li><li>n@. b</li></ul>`, + }, + } { + t.Run(name, func(t *testing.T) { + assert.Equal(t, tc.ExpectedHTML, RenderHTML(tc.Markdown)) + }) + } +} |