diff --git a/src/core/render/emojify.js b/src/core/render/emojify.js index 39d7a4ce3..52467c8f8 100644 --- a/src/core/render/emojify.js +++ b/src/core/render/emojify.js @@ -35,6 +35,10 @@ export function emojify(text, useNativeEmoji) { ) // Mark colons in comments .replace(//g, m => m.replace(/:/g, '__colon__')) + // Mark colons in URIs + .replace(/([a-z]{2,}:)?\/\/[^\s'">)]+/gi, m => + m.replace(/:/g, '__colon__') + ) // Replace emoji shorthand codes .replace(/:([a-z0-9_\-+]+?):/g, (m, $1) => replaceEmojiShorthand(m, $1, useNativeEmoji) diff --git a/test/integration/__snapshots__/emoji.test.js.snap b/test/integration/__snapshots__/emoji.test.js.snap index 105cf9df2..1446cbd86 100644 --- a/test/integration/__snapshots__/emoji.test.js.snap +++ b/test/integration/__snapshots__/emoji.test.js.snap @@ -2,6 +2,10 @@ exports[`Emoji Ignores all emoji shorthand codes (noEmoji:true) 1`] = `"
:smile:
:smile::smile:
:smile: :smile:
:smile::smile::smile:
:smile: :smile: :smile:
text:smile:
:smile:text
text:smile:text
"`; +exports[`Emoji Ignores emoji shorthand codes in URIs 1`] = `"Url https://docsify.js.org/:foo:/ http://docsify.js.org/:100:/ ftp://docsify.js.org/:smile:/
"`; + +exports[`Emoji Ignores emoji shorthand codes in URIs while handling anchor content 1`] = `""`; + exports[`Emoji Ignores emoji shorthand codes in code, pre, script, and template tags 1`] = ` ":100:@@ -16,6 +20,10 @@ exports[`Emoji Ignores emoji shorthand codes in code, pre, script, and template exports[`Emoji Ignores emoji shorthand codes in comments 1`] = `"
Text
"`; +exports[`Emoji Ignores emoji shorthand codes in html attributes 1`] = `""`; + +exports[`Emoji Ignores emoji shorthand codes in style url() values 1`] = `""`; + exports[`Emoji Ignores unmatched emoji shorthand codes 1`] = `"hh:mm
hh:mm:ss
Namespace::SubNameSpace
Namespace::SubNameSpace::Class
2014-12-29T16:11:20+00:00
"`; exports[`Emoji Renders GitHub emoji images (nativeEmoji:false) 1`] = `"
text
text
texttext