08-27-周三_17-09-29
This commit is contained in:
3
node_modules/prismjs/plugins/autolinker/prism-autolinker.css
generated
vendored
Normal file
3
node_modules/prismjs/plugins/autolinker/prism-autolinker.css
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.token a {
|
||||
color: inherit;
|
||||
}
|
81
node_modules/prismjs/plugins/autolinker/prism-autolinker.js
generated
vendored
Normal file
81
node_modules/prismjs/plugins/autolinker/prism-autolinker.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
(function(){
|
||||
|
||||
if (
|
||||
typeof self !== 'undefined' && !self.Prism ||
|
||||
typeof global !== 'undefined' && !global.Prism
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
var url = /\b([a-z]{3,7}:\/\/|tel:)[\w\-+%~/.:=&@]+(?:\?[\w\-+%~/.:=?&!$'()*,;@]*)?(?:#[\w\-+%~/.:#=?&!$'()*,;@]*)?/,
|
||||
email = /\b\S+@[\w.]+[a-z]{2}/,
|
||||
linkMd = /\[([^\]]+)]\(([^)]+)\)/,
|
||||
|
||||
// Tokens that may contain URLs and emails
|
||||
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) {}
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
1
node_modules/prismjs/plugins/autolinker/prism-autolinker.min.js
generated
vendored
Normal file
1
node_modules/prismjs/plugins/autolinker/prism-autolinker.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(){if(("undefined"==typeof self||self.Prism)&&("undefined"==typeof global||global.Prism)){var t=/\b([a-z]{3,7}:\/\/|tel:)[\w\-+%~/.:=&@]+(?:\?[\w\-+%~/.:=?&!$'()*,;@]*)?(?:#[\w\-+%~/.:#=?&!$'()*,;@]*)?/,r=/\b\S+@[\w.]+[a-z]{2}/,a=/\[([^\]]+)]\(([^)]+)\)/,l=["comment","url","attr-value","string"];Prism.plugins.autolinker={processGrammar:function(i){i&&!i["url-link"]&&(Prism.languages.DFS(i,function(i,n,e){-1<l.indexOf(e)&&!Array.isArray(n)&&(n.pattern||(n=this[i]={pattern:n}),n.inside=n.inside||{},"comment"==e&&(n.inside["md-link"]=a),"attr-value"==e?Prism.languages.insertBefore("inside","punctuation",{"url-link":t},n):n.inside["url-link"]=t,n.inside["email-link"]=r)}),i["url-link"]=t,i["email-link"]=r)}},Prism.hooks.add("before-highlight",function(i){Prism.plugins.autolinker.processGrammar(i.grammar)}),Prism.hooks.add("wrap",function(i){if(/-link$/.test(i.type)){i.tag="a";var n=i.content;if("email-link"==i.type&&0!=n.indexOf("mailto:"))n="mailto:"+n;else if("md-link"==i.type){var e=i.content.match(a);n=e[2],i.content=e[1]}i.attributes.href=n;try{i.content=decodeURIComponent(i.content)}catch(i){}}})}}();
|
Reference in New Issue
Block a user