Merge pull request #1034 from SISheogorath/fix/emojiPlugin

Again: Replace emoji-plugin regex
This commit is contained in:
Christoph (Sheogorath) Kern 2018-11-06 19:11:56 +01:00 committed by GitHub
commit e17522add9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -1147,16 +1147,15 @@ const pdfPlugin = new Plugin(
const emojijsPlugin = new Plugin( const emojijsPlugin = new Plugin(
// regexp to match emoji shortcodes :something: // regexp to match emoji shortcodes :something:
/:([^\s:]+):/, // We generate an universal regex that guaranteed only contains the
// emojies we have available. This should prevent all false-positives
new RegExp(':(' + window.emojify.emojiNames.map((item) => { return RegExp.escape(item) }).join('|') + '):', 'i'),
(match, utils) => { (match, utils) => {
const emoji = match[1] ? match[1].toLowerCase() : undefined const emoji = match[1].toLowerCase()
if (window.emojify.emojiNames.includes(emoji)) {
const div = $(`<img class="emoji" src="${serverurl}/build/emojify.js/dist/images/basic/${emoji}.png"></img>`) const div = $(`<img class="emoji" src="${serverurl}/build/emojify.js/dist/images/basic/${emoji}.png"></img>`)
return div[0].outerHTML return div[0].outerHTML
} }
return match[0]
}
) )
// yaml meta, from https://github.com/eugeneware/remarkable-meta // yaml meta, from https://github.com/eugeneware/remarkable-meta