MCPcopy
hub / github.com/docsifyjs/docsify / emojify

Function emojify

src/core/render/emojify.js:28–49  ·  view source on GitHub ↗
(text, useNativeEmoji)

Source from the content-addressed store, hash-verified

26}
27
28export function emojify(text, useNativeEmoji) {
29 return (
30 text
31 // Mark colons in tags
32 .replace(
33 /<(code|pre|script|template)[^>]*?>[\s\S]+?<\/(code|pre|script|template)>/g,
34 m => m.replace(/:/g, '__colon__')
35 )
36 // Mark colons in comments
37 .replace(/<!--[\s\S]+?-->/g, m => m.replace(/:/g, '__colon__'))
38 // Mark colons in URIs
39 .replace(/([a-z]{2,}:)?\/\/[^\s'">)]+/gi, m =>
40 m.replace(/:/g, '__colon__')
41 )
42 // Replace emoji shorthand codes
43 .replace(/:([a-z0-9_\-+]+?):/g, (m, $1) =>
44 replaceEmojiShorthand(m, $1, useNativeEmoji)
45 )
46 // Restore colons in tags and comments
47 .replace(/__colon__/g, ':')
48 );
49}

Callers 1

constructorMethod · 0.90

Calls 1

replaceEmojiShorthandFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…