Skip to content

Commit 8816ad0

Browse files
authored
Update codeit-autolinker.js
1 parent 91759ed commit 8816ad0

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

lib/plugins/codeit-autolinker.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,40 @@
4545
};
4646

4747
Prism.hooks.add('before-tokenize', function (env) {
48-
if (env.language !== 'markdown') {
49-
Prism.plugins.autolinker.processGrammar(env.grammar);
50-
}
48+
if (env.language !== 'markdown') {
49+
Prism.plugins.autolinker.processGrammar(env.grammar);
50+
}
5151
});
5252

5353
Prism.hooks.add('wrap', function (env) {
54-
if (env.language !== 'markdown') {
55-
if (/-link$/.test(env.type)) {
56-
env.tag = 'a';
57-
58-
var href = env.content;
59-
60-
if (env.type == 'email-link' && href.indexOf('mailto:') != 0) {
61-
href = 'mailto:' + href;
62-
} else if (env.type == 'md-link') {
63-
// Markdown
64-
var match = env.content.match(linkMd);
65-
66-
href = match[2];
67-
env.content = match[1];
68-
}
69-
70-
var isMac = navigator.platform.indexOf('Mac') > -1;
71-
72-
env.attributes.href = href.replaceAll('\'','').replaceAll('"','').replaceAll('`','');
73-
env.attributes.onclick = 'if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); window.open(this.href, "_blank") }';
74-
env.attributes.title = isMac ? '⌘ + shift + click to open link' : 'Ctrl + shift + click to open link';
75-
76-
// Silently catch any error thrown by decodeURIComponent (#1186)
77-
try {
78-
env.content = decodeURIComponent(env.content);
79-
} catch (e) { /* noop */ }
80-
}
81-
}
54+
if (env.language !== 'markdown') {
55+
if (/-link$/.test(env.type)) {
56+
env.tag = 'a';
57+
58+
var href = env.content;
59+
60+
if (env.type == 'email-link' && href.indexOf('mailto:') != 0) {
61+
href = 'mailto:' + href;
62+
} else if (env.type == 'md-link') {
63+
// Markdown
64+
var match = env.content.match(linkMd);
65+
66+
href = match[2];
67+
env.content = match[1];
68+
}
69+
70+
var isMac = navigator.platform.indexOf('Mac') > -1;
71+
72+
env.attributes.href = href.replaceAll('\'','').replaceAll('"','').replaceAll('`','');
73+
env.attributes.onclick = 'if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); window.open(this.href, "_blank") }';
74+
env.attributes.title = isMac ? '⌘ + shift + click to open link' : 'Ctrl + shift + click to open link';
75+
76+
// Silently catch any error thrown by decodeURIComponent (#1186)
77+
try {
78+
env.content = decodeURIComponent(env.content);
79+
} catch (e) { /* noop */ }
80+
}
81+
}
8282
});
8383

8484
}());

0 commit comments

Comments
 (0)