remove autolinker
This commit is contained in:
parent
8cfbefc303
commit
f1ae99f931
1 changed files with 2 additions and 79 deletions
79
js/prism.js
79
js/prism.js
|
@ -1,5 +1,5 @@
|
||||||
/* PrismJS 1.24.1
|
/* PrismJS 1.24.1
|
||||||
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+apacheconf+arduino+aspnet+bash+batch+c+csharp+cpp+cmake+docker+gcode+git+go+ignore+java+json+json5+makefile+markdown+markup-templating+php+powershell+properties+python+jsx+tsx+sas+sass+scss+sql+typescript+typoscript+yaml&plugins=line-numbers+autolinker */
|
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+apacheconf+arduino+aspnet+bash+batch+c+csharp+cpp+cmake+docker+gcode+git+go+ignore+java+json+json5+makefile+markdown+markup-templating+php+powershell+properties+python+jsx+tsx+sas+sass+scss+sql+typescript+typoscript+yaml&plugins=line-numbers */
|
||||||
/// <reference lib="WebWorker"/>
|
/// <reference lib="WebWorker"/>
|
||||||
|
|
||||||
var _self = (typeof window !== 'undefined')
|
var _self = (typeof window !== 'undefined')
|
||||||
|
@ -5174,80 +5174,3 @@ Prism.languages.sql = {
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
if (typeof Prism === 'undefined') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var url = /\b([a-z]{3,7}:\/\/|tel:)[\w\-+%~/.:=&@]+(?:\?[\w\-+%~/.:=?&!$'()*,;@]*)?(?:#[\w\-+%~/.:#=?&!$'()*,;@]*)?/;
|
|
||||||
var email = /\b\S+@[\w.]+[a-z]{2}/;
|
|
||||||
var linkMd = /\[([^\]]+)\]\(([^)]+)\)/;
|
|
||||||
|
|
||||||
// Tokens that may contain URLs and emails
|
|
||||||
var candidates = ['comment', 'url', 'attr-value', 'string'];
|
|
||||||
|
|
||||||
Prism.plugins.autolinker = {
|
|
||||||
processGrammar: function (grammar) {
|
|
||||||
// Abort if grammar has already been processed
|
|
||||||
if (!grammar || grammar['url-link']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Prism.languages.DFS(grammar, function (key, def, type) {
|
|
||||||
if (candidates.indexOf(type) > -1 && !Array.isArray(def)) {
|
|
||||||
if (!def.pattern) {
|
|
||||||
def = this[key] = {
|
|
||||||
pattern: def
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
def.inside = def.inside || {};
|
|
||||||
|
|
||||||
if (type == 'comment') {
|
|
||||||
def.inside['md-link'] = linkMd;
|
|
||||||
}
|
|
||||||
if (type == 'attr-value') {
|
|
||||||
Prism.languages.insertBefore('inside', 'punctuation', { 'url-link': url }, def);
|
|
||||||
} else {
|
|
||||||
def.inside['url-link'] = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
def.inside['email-link'] = email;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
grammar['url-link'] = url;
|
|
||||||
grammar['email-link'] = email;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Prism.hooks.add('before-highlight', function (env) {
|
|
||||||
Prism.plugins.autolinker.processGrammar(env.grammar);
|
|
||||||
});
|
|
||||||
|
|
||||||
Prism.hooks.add('wrap', function (env) {
|
|
||||||
if (/-link$/.test(env.type)) {
|
|
||||||
env.tag = 'a';
|
|
||||||
|
|
||||||
var href = env.content;
|
|
||||||
|
|
||||||
if (env.type == 'email-link' && href.indexOf('mailto:') != 0) {
|
|
||||||
href = 'mailto:' + href;
|
|
||||||
} else if (env.type == 'md-link') {
|
|
||||||
// Markdown
|
|
||||||
var match = env.content.match(linkMd);
|
|
||||||
|
|
||||||
href = match[2];
|
|
||||||
env.content = match[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
env.attributes.href = href;
|
|
||||||
|
|
||||||
// Silently catch any error thrown by decodeURIComponent (#1186)
|
|
||||||
try {
|
|
||||||
env.content = decodeURIComponent(env.content);
|
|
||||||
} catch (e) { /* noop */ }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}());
|
|
||||||
|
|
Loading…
Reference in a new issue