From 3aef37a445a0b68bf1bd525f0e8d10f63d08b562 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 11 Mar 2017 19:30:38 +0800 Subject: [PATCH] feat(emojify): add no-emoji option --- docs/configuration.md | 10 ++++++++++ docs/zh-cn/configuration.md | 10 ++++++++++ src/core/config.js | 1 + src/core/render/emojify.js | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index f5880f0ae..8aa1c41e9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -295,3 +295,13 @@ window.$docsify = { ``` Note that if you are running an external script, e.g. an embedded jsfiddle demo, make sure to include the [external-script](plugins?id=external-script) plugin. + +## no-emoji + +Disabled emoji parse. + +```js +window.$docsify = { + noEmoji: true +} +``` diff --git a/docs/zh-cn/configuration.md b/docs/zh-cn/configuration.md index 103e88439..3ef44c056 100644 --- a/docs/zh-cn/configuration.md +++ b/docs/zh-cn/configuration.md @@ -305,3 +305,13 @@ window.$docsify = { ``` 注意如果执行的是一个外链脚本,比如 jsfiddle 的内嵌 demo,请确保引入 [external-script](zh-cn/plugins?id=外链脚本-external-script) 插件。 + +## no-emoji + +禁用 emoji 解析。 + +```js +window.$docsify = { + noEmoji: true +} +``` diff --git a/src/core/config.js b/src/core/config.js index 2cccfc503..705051967 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -16,6 +16,7 @@ const config = merge({ nameLink: window.location.pathname, autoHeader: false, executeScript: null, + noEmoji: false, ga: '' }, window.$docsify) diff --git a/src/core/render/emojify.js b/src/core/render/emojify.js index 8d7983c3e..b8d41aaff 100644 --- a/src/core/render/emojify.js +++ b/src/core/render/emojify.js @@ -3,7 +3,7 @@ function replace (m, $1) { } export function emojify (text) { - return 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, ':')