Skip to content

Commit a52946f

Browse files
committed
emojify: simply either enable emojis or not
1 parent 719dcbe commit a52946f

File tree

5 files changed

+13
-29
lines changed

5 files changed

+13
-29
lines changed

docs/configuration.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -398,20 +398,6 @@ window.$docsify = {
398398

399399
Note that if you are running an external script, e.g. an embedded jsfiddle demo, make sure to include the [external-script](plugins.md?id=external-script) plugin.
400400

401-
## noEmoji
402-
403-
- type: `Boolean`
404-
405-
Disabled emoji parse.
406-
407-
```js
408-
window.$docsify = {
409-
noEmoji: true,
410-
};
411-
```
412-
413-
?> If this option is `false` but you don't want to emojify some specific colons, [refer to this](https://github.com/docsifyjs/docsify/issues/742#issuecomment-586313143)
414-
415401
## mergeNavbar
416402

417403
- type: `Boolean`

docs/plugins.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,18 @@ Configure by `data-ga`.
9191

9292
## emoji
9393

94-
The default is to support parsing emoji. For example `:100:` will be parsed to :100:. But it is not precise because there is no matching non-emoji string. If you need to correctly parse the emoji string, you need install this plugin.
94+
Emoji parsing is disabled by default.
95+
To enable emoji parsing, you need to add the following plugin.
9596

9697
```html
9798
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/emoji.min.js"></script>
9899
```
99100

100-
?> If you don't want to parse to emoji, you can use __colon_<span>_</span> or `&#58;`. If you need to use in the title, we recommend using `&#58;`. For example, `&#58;100:`
101+
Only [Github emojis](https://gist.github.com/rxaviers/7360908) are searched and replaced.
102+
103+
Code blocks are not parsed, thus :100: won't be rendered here: `:100:`.
104+
105+
?> If you don't want a specific emoji to be parsed, you can replace a colon by __colon_<span>_</span> or `&#58;`. If you need to use in the title, we recommend using `&#58;`. For example, `&#58;100:`
101106

102107
## External Script
103108

src/core/config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export default function(vm) {
2121
nameLink: window.location.pathname,
2222
autoHeader: false,
2323
executeScript: null,
24-
noEmoji: false,
2524
ga: '',
2625
ext: '.md',
2726
mergeNavbar: false,

src/core/render/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class Compiler {
103103
html = compile.parser(text);
104104
}
105105

106-
html = config.noEmoji ? html : emojify(html);
106+
html = emojify(html);
107107
slugify.clear();
108108

109109
return html;

src/core/render/emojify.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
import { inBrowser } from '../util/env';
22

3-
function replace(m, $1) {
4-
return (
5-
'<img class="emoji" src="https://github.githubassets.com/images/icons/emoji/' +
6-
$1 +
7-
'.png" alt="' +
8-
$1 +
9-
'" />'
10-
);
11-
}
12-
133
export function emojify(text) {
4+
if (!window.emojify) {
5+
return text.replace(/__colon__/g, ':');
6+
}
7+
148
return text
159
.replace(/<(pre|template|code)[^>]*?>[\s\S]+?<\/(pre|template|code)>/g, m =>
1610
m.replace(/:/g, '__colon__')
1711
)
18-
.replace(/:([a-z0-9_\-\+]+?):/g, (inBrowser && window.emojify) || replace)
12+
.replace(/:([a-z0-9_\-\+]+?):/g, inBrowser && window.emojify)
1913
.replace(/__colon__/g, ':');
2014
}

0 commit comments

Comments
 (0)