Skip to content

Commit

Permalink
🎨 改进自动链接解析 #190 Vanessa219/vditor#1513
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 13, 2023
1 parent 39c4b6c commit cae466b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion javascript/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/lute.min.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions parse/auto_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func (t *Tree) parseGFMAutoLink0(node *ast.Node) {
addr = append(addr, protocol...)
}
addr = append(addr, domain...)
addr = append(addr, port...)
addr = append(addr, path...)
linkText := addr
if bytes.HasPrefix(linkText, []byte("https://github.com/")) && bytes.Contains(linkText, []byte("/issues/")) {
Expand Down
6 changes: 3 additions & 3 deletions test/autolink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (

var autoLinkTests = []parseTest{

{"29", "www.test.com:8080/bar/baz", "<p><a href=\"http://www.test.com:8080/bar/baz\">www.test.com/bar/baz</a></p>\n"},
{"28", "www.test.com:8080(测试地址)", "<p><a href=\"http://www.test.com:8080\">www.test.com</a>(测试地址)</p>\n"},
{"27", "http://127.0.0.1:8080(测试地址)", "<p><a href=\"http://127.0.0.1:8080\">http://127.0.0.1</a>(测试地址)</p>\n"},
{"29", "www.test.com:8080/bar/baz", "<p><a href=\"http://www.test.com:8080/bar/baz\">www.test.com:8080/bar/baz</a></p>\n"},
{"28", "www.test.com:8080(测试地址)", "<p><a href=\"http://www.test.com:8080\">www.test.com:8080</a>(测试地址)</p>\n"},
{"27", "http://127.0.0.1:8080(测试地址)", "<p><a href=\"http://127.0.0.1:8080\">http://127.0.0.1:8080</a>(测试地址)</p>\n"},
{"26", "https://www.baidu.help", "<p><a href=\"https://www.baidu.help\">https://www.baidu.help</a></p>\n"},
{"25", "https://www.baidu.wang", "<p><a href=\"https://www.baidu.wang\">https://www.baidu.wang</a></p>\n"},
{"24", "https://www.google.com.np/", "<p><a href=\"https://www.google.com.np/\">https://www.google.com.np/</a></p>\n"},
Expand Down
2 changes: 1 addition & 1 deletion test/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

var debugTests = []parseTest{

{"74", "https://foo.com:443/bar/baz", "<p><a href=\"https://foo.com:443/bar/baz\">https://foo.com/bar/baz</a></p>\n"},
{"74", "https://foo.com:443/bar/baz", "<p><a href=\"https://foo.com:443/bar/baz\">https://foo.com:443/bar/baz</a></p>\n"},
{"73", "| $foo\\\\\\|bar$ |\n| - |", "<table>\n<thead>\n<tr>\n<th><span class=\"language-math\">foo\\\\\\|bar</span></th>\n</tr>\n</thead>\n</table>\n"},
{"72", "| $foo\\\\|bar$ |\n| - |", "<table>\n<thead>\n<tr>\n<th><span class=\"language-math\">foo\\\\|bar</span></th>\n</tr>\n</thead>\n</table>\n"},
{"71", "| $foo\\|bar$ |\n| - |", "<table>\n<thead>\n<tr>\n<th><span class=\"language-math\">foo\\|bar</span></th>\n</tr>\n</thead>\n</table>\n"},
Expand Down

0 comments on commit cae466b

Please sign in to comment.