diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2018-07-24 10:40:01 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2018-07-24 07:40:01 -0700 |
commit | c8d3e421391520af45d8e0f60a884fee139652a0 (patch) | |
tree | 963d24f65d75cd413ba539779935223b165ae938 /utils/markdown/commonmark_test.go | |
parent | bfb2640451c95b242ae7b8bb8528538b706412ef (diff) | |
download | chat-c8d3e421391520af45d8e0f60a884fee139652a0.tar.gz chat-c8d3e421391520af45d8e0f60a884fee139652a0.tar.bz2 chat-c8d3e421391520af45d8e0f60a884fee139652a0.zip |
MM-11451 Added autolinking to Markdown parser (#9151)
* MM-11451 Added autolinking to Markdown parser
* Added missing headers
* Added mailto and tel links
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)) + }) + } +} |