mirror of https://github.com/zulip/zulip.git
parent
abe2dab88c
commit
8b443a25b8
|
@ -439,6 +439,9 @@ exports.initialize = function () {
|
||||||
// Our links have title= and target=_blank
|
// Our links have title= and target=_blank
|
||||||
r.link = function (href, title, text) {
|
r.link = function (href, title, text) {
|
||||||
title = title || href;
|
title = title || href;
|
||||||
|
if (!text.trim()) {
|
||||||
|
text = href;
|
||||||
|
}
|
||||||
var out = '<a href="' + href + '"' + ' target="_blank" title="' +
|
var out = '<a href="' + href + '"' + ' target="_blank" title="' +
|
||||||
title + '"' + '>' + text + '</a>';
|
title + '"' + '>' + text + '</a>';
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -1802,6 +1802,10 @@ class LinkInlineProcessor(markdown.inlinepatterns.LinkInlineProcessor):
|
||||||
el.set("href", href)
|
el.set("href", href)
|
||||||
fixup_link(el, target_blank=(href[:1] != '#'))
|
fixup_link(el, target_blank=(href[:1] != '#'))
|
||||||
|
|
||||||
|
# Show link href if title is empty
|
||||||
|
if not el.text.strip():
|
||||||
|
el.text = href
|
||||||
|
|
||||||
# Prevent realm_filters from running on the content of a Markdown link, breaking up the link.
|
# Prevent realm_filters from running on the content of a Markdown link, breaking up the link.
|
||||||
# This is a monkey-patch, but it might be worth sending a version of this change upstream.
|
# This is a monkey-patch, but it might be worth sending a version of this change upstream.
|
||||||
if not isinstance(el, str):
|
if not isinstance(el, str):
|
||||||
|
|
|
@ -373,6 +373,21 @@
|
||||||
"input": "https://github.com",
|
"input": "https://github.com",
|
||||||
"expected_output": "<p><a href=\"https://github.com\" target=\"_blank\" title=\"https://github.com\">https://github.com</a></p>"
|
"expected_output": "<p><a href=\"https://github.com\" target=\"_blank\" title=\"https://github.com\">https://github.com</a></p>"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "link_with_text",
|
||||||
|
"input": "[hello](https://github.com)",
|
||||||
|
"expected_output": "<p><a href=\"https://github.com\" target=\"_blank\" title=\"https://github.com\">hello</a></p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "link_without_text",
|
||||||
|
"input": "[](https://github.com)",
|
||||||
|
"expected_output": "<p><a href=\"https://github.com\" target=\"_blank\" title=\"https://github.com\">https://github.com</a></p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "link_with_empty_text",
|
||||||
|
"input": "[ ](https://github.com)",
|
||||||
|
"expected_output": "<p><a href=\"https://github.com\" target=\"_blank\" title=\"https://github.com\">https://github.com</a></p>"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "nl2br",
|
"name": "nl2br",
|
||||||
"input": "test\nbar",
|
"input": "test\nbar",
|
||||||
|
|
Loading…
Reference in New Issue