Locally add prismjs

This commit is contained in:
Aroy-Art 2024-11-26 21:16:11 +01:00
parent 35af792c6a
commit 6aa044cf9b
Signed by: Aroy
GPG key ID: 583642324A1D2070
701 changed files with 35787 additions and 0 deletions

View file

@ -0,0 +1,3 @@
.token a {
color: inherit;
}

View file

@ -0,0 +1,76 @@
(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 */ }
}
});
}());

View file

@ -0,0 +1 @@
.token a{color:inherit}

View file

@ -0,0 +1 @@
!function(){if("undefined"!=typeof Prism){var i=/\b([a-z]{3,7}:\/\/|tel:)[\w\-+%~/.:=&!$'()*,;@]+(?:\?[\w\-+%~/.:=?&!$'()*,;@]*)?(?:#[\w\-+%~/.:#=?&!$'()*,;@]*)?/,n=/\b\S+@[\w.]+[a-z]{2}/,t=/\[([^\]]+)\]\(([^)]+)\)/,e=["comment","url","attr-value","string"];Prism.plugins.autolinker={processGrammar:function(r){r&&!r["url-link"]&&(Prism.languages.DFS(r,(function(r,a,l){e.indexOf(l)>-1&&!Array.isArray(a)&&(a.pattern||(a=this[r]={pattern:a}),a.inside=a.inside||{},"comment"==l&&(a.inside["md-link"]=t),"attr-value"==l?Prism.languages.insertBefore("inside","punctuation",{"url-link":i},a):a.inside["url-link"]=i,a.inside["email-link"]=n)})),r["url-link"]=i,r["email-link"]=n)}},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(t);n=e[2],i.content=e[1]}i.attributes.href=n;try{i.content=decodeURIComponent(i.content)}catch(i){}}}))}}();