Update emoji parser using markdown-it-emoji instead of emojify to solve issue #217

This commit is contained in:
Wu Cheng-Han 2016-10-18 16:50:58 +08:00
parent eb724b05a7
commit d44e830366
895 changed files with 27 additions and 412 deletions

View file

@ -246,12 +246,6 @@ function finishView(view) {
if ($(value).children().length == 0)
$(value).gist(viewAjaxCallback);
});
//emojify
try {
emojify.run(view[0]);
} catch (err) {
console.warn(err);
}
//mathjax
var mathjaxdivs = view.find('span.mathjax.raw').removeClass("raw").toArray();
try {
@ -823,15 +817,6 @@ function highlightRender(code, lang) {
return result.value;
}
emojify.setConfig({
blacklist: {
elements: ['script', 'textarea', 'a', 'pre', 'code', 'svg'],
classes: ['no-emojify']
},
img_dir: serverurl + '/vendor/emojify/images',
ignore_emoticons: true
});
var markdownit = require('markdown-it');
var markdownitContainer = require('markdown-it-container');
@ -855,6 +840,25 @@ md.use(require('markdown-it-sup'));
md.use(require('../vendor/markdown-it-mathjax'));
md.use(require('markdown-it-imsize'));
md.use(require('markdown-it-emoji'), {
shortcuts: false
});
var emojify = require('emojify.js');
emojify.setConfig({
blacklist: {
elements: ['script', 'textarea', 'a', 'pre', 'code', 'svg'],
classes: ['no-emojify']
},
img_dir: serverurl + '/vendor/emojify.js/dist/images/basic',
ignore_emoticons: true
});
md.renderer.rules.emoji = function(token, idx) {
return emojify.replace(':' + token[idx].markup + ':');
};
function renderContainer(tokens, idx, options, env, self) {
tokens[idx].attrJoin('role', 'alert');
tokens[idx].attrJoin('class', 'alert');

View file

@ -3732,6 +3732,8 @@ function matchInContainer(text) {
}
}
var emojify = require('emojify.js');
$(editor.getInputField())
.textcomplete([
{ // emoji strategy
@ -3751,7 +3753,7 @@ $(editor.getInputField())
callback(list);
},
template: function (value) {
return '<img class="emoji" src="' + serverurl + '/vendor/emojify/images/' + value + '.png"></img> ' + value;
return '<img class="emoji" src="' + serverurl + '/vendor/emojify.js/dist/images/basic/' + value + '.png"></img> ' + value;
},
replace: function (value) {
return '$1:' + value + ': ';