forked from projects/fipamo
ro
1e37580869
dropped in js from the old site to begin the process of wiring up the API, but this time around, scripts will be served directly in browswer rather than being transpiled through NPM/Babel, eliminating the need for NPM. also scripting will new modularized and served specifically for the requirements of the page loading it. no more front loading everything. only script that is needed for that page will be retrieved. if no scripting is needed, none will be loaded. The only casualty so far has been syntax highlighting due to prismjs still being a common js module, but either this will be replaced with another library or a custom syntax enginge will be created at a later date
101 lines
2.5 KiB
JavaScript
101 lines
2.5 KiB
JavaScript
Prism.languages.markup = {
|
|
'comment': /<!--[\s\S]*?-->/,
|
|
'prolog': /<\?[\s\S]+?\?>/,
|
|
'doctype': /<!DOCTYPE[\s\S]+?>/i,
|
|
'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
|
|
'tag': {
|
|
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,
|
|
greedy: true,
|
|
inside: {
|
|
'tag': {
|
|
pattern: /^<\/?[^\s>\/]+/i,
|
|
inside: {
|
|
'punctuation': /^<\/?/,
|
|
'namespace': /^[^\s>\/:]+:/
|
|
}
|
|
},
|
|
'attr-value': {
|
|
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,
|
|
inside: {
|
|
'punctuation': [
|
|
/^=/,
|
|
{
|
|
pattern: /^(\s*)["']|["']$/,
|
|
lookbehind: true
|
|
}
|
|
]
|
|
}
|
|
},
|
|
'punctuation': /\/?>/,
|
|
'attr-name': {
|
|
pattern: /[^\s>\/]+/,
|
|
inside: {
|
|
'namespace': /^[^\s>\/:]+:/
|
|
}
|
|
}
|
|
|
|
}
|
|
},
|
|
'entity': /&#?[\da-z]{1,8};/i
|
|
};
|
|
|
|
Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
|
|
Prism.languages.markup['entity'];
|
|
|
|
// Plugin to make entity title show the real entity, idea by Roman Komarov
|
|
Prism.hooks.add('wrap', function(env) {
|
|
|
|
if (env.type === 'entity') {
|
|
env.attributes['title'] = env.content.replace(/&/, '&');
|
|
}
|
|
});
|
|
|
|
Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
|
|
/**
|
|
* Adds an inlined language to markup.
|
|
*
|
|
* An example of an inlined language is CSS with `<style>` tags.
|
|
*
|
|
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
|
* case insensitive.
|
|
* @param {string} lang The language key.
|
|
* @example
|
|
* addInlined('style', 'css');
|
|
*/
|
|
value: function addInlined(tagName, lang) {
|
|
var includedCdataInside = {};
|
|
includedCdataInside['language-' + lang] = {
|
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
lookbehind: true,
|
|
inside: Prism.languages[lang]
|
|
};
|
|
includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
|
|
|
|
var inside = {
|
|
'included-cdata': {
|
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
inside: includedCdataInside
|
|
}
|
|
};
|
|
inside['language-' + lang] = {
|
|
pattern: /[\s\S]+/,
|
|
inside: Prism.languages[lang]
|
|
};
|
|
|
|
var def = {};
|
|
def[tagName] = {
|
|
pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'),
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: inside
|
|
};
|
|
|
|
Prism.languages.insertBefore('markup', 'cdata', def);
|
|
}
|
|
});
|
|
|
|
Prism.languages.xml = Prism.languages.extend('markup', {});
|
|
Prism.languages.html = Prism.languages.markup;
|
|
Prism.languages.mathml = Prism.languages.markup;
|
|
Prism.languages.svg = Prism.languages.markup;
|