Inline 宏处理器扩展示例
- 目的
-
将宏表情符号替换为对应的文本表情符号。
EmoticonInlineMacroProcessor
emoticon-inline-macro-processor.js
module.exports = function (registry) {
registry.inlineMacro('emoticon', function () {
var self = this
self.process(function (parent, target) {
var text
if (target === 'grin') {
text = ':D'
} else if (target === 'wink') {
text = ';)'
} else {
text = ':)'
}
return self.createInline(parent, 'quoted', text, { 'type': 'strong' })
})
})
}