mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-10 22:06:24 +10:00
13 lines
448 B
JavaScript
13 lines
448 B
JavaScript
import {inBrowser} from '../util/env'
|
|
|
|
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 text
|
|
.replace(/<(pre|template|code)[^>]*?>[\s\S]+?<\/(pre|template|code)>/g, m => m.replace(/:/g, '__colon__'))
|
|
.replace(/:(\w+?):/ig, (inBrowser && window.emojify) || replace)
|
|
.replace(/__colon__/g, ':')
|
|
}
|