mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
11 lines
422 B
JavaScript
11 lines
422 B
JavaScript
function replace (m, $1) {
|
|
return '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' + $1 + '.png" alt="' + $1 + '" />'
|
|
}
|
|
|
|
export function emojify (text) {
|
|
return $docsify.noEmoji ? text : text
|
|
.replace(/<(pre|template|code)[^>]*?>[\s\S]+?<\/(pre|template|code)>/g, m => m.replace(/:/g, '__colon__'))
|
|
.replace(/:(\w+?):/ig, window.emojify || replace)
|
|
.replace(/__colon__/g, ':')
|
|
}
|