Skip to content

Commit

Permalink
Merge branch 'master' into more-plugin-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Oct 5, 2021
2 parents 1668ed7 + e8f84a6 commit df8ee50
Show file tree
Hide file tree
Showing 240 changed files with 14,574 additions and 2,053 deletions.
64 changes: 12 additions & 52 deletions assets/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,62 +179,22 @@
language.examplesPromise.then(function (contents) {
examples[id].innerHTML = buildContentsHeader(id) + contents;

loadLanguage(id).then(function () {
Prism.highlightAllUnder(examples[id]);
/** @type {HTMLElement} */
var container = examples[id];
container.innerHTML = buildContentsHeader(id) + contents;

// the current language might be an extension of a language
// so to be safe, we explicitly add a dependency to the current language
$$('pre', container).forEach(/** @param {HTMLElement} pre */function (pre) {
var dependencies = (pre.getAttribute('data-dependencies') || '').trim();
dependencies = dependencies ? dependencies + ',' + id : id;
pre.setAttribute('data-dependencies', dependencies);
});

Prism.highlightAllUnder(container);
});
} else {
examples[id].innerHTML = '';
}
}

/**
* Loads a language, including all dependencies
*
* @param {string} lang the language to load
* @returns {Promise} the promise which resolves as soon as everything is loaded
*/
function loadLanguage(lang) {
// at first we need to fetch all dependencies for the main language
// Note: we need to do this, even if the main language already is loaded (just to be sure..)
//
// We load an array of all dependencies and call recursively this function on each entry
//
// dependencies is now an (possibly empty) array of loading-promises
var dependencies = getDependenciesOfLanguage(lang).map(loadLanguage);

// We create a promise, which will resolve, as soon as all dependencies are loaded.
// They need to be fully loaded because the main language may extend them.
return Promise.all(dependencies)
.then(function () {

// If the main language itself isn't already loaded, load it now
// and return the newly created promise (we chain the promises).
// If the language is already loaded, just do nothing - the next .then()
// will immediately be called
if (!Prism.languages[lang]) {
return new Promise(function (resolve) {
$u.script('components/prism-' + lang + '.js', resolve);
});
}
});
}


/**
* Returns all dependencies (as identifiers) of a specific language
*
* @param {string} lang
* @returns {string[]} the list of dependencies. Empty if the language has none.
*/
function getDependenciesOfLanguage(lang) {
if (!components.languages[lang] || !components.languages[lang].require) {
return [];
}

return ($u.type(components.languages[lang].require) === 'array')
? components.languages[lang].require
: [components.languages[lang].require];
}

}());
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@
"title": "6502 Assembly",
"owner": "kzurawel"
},
"asmatmel": {
"title": "Atmel AVR Assembly",
"owner": "cerkit"
},
"autohotkey": {
"title": "AutoHotkey",
"owner": "aviaryan"
Expand Down
43 changes: 43 additions & 0 deletions components/prism-asmatmel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Prism.languages.asmatmel = {
'comment': {
pattern: /;.*/,
greedy: true
},
'string': {
pattern: /(["'`])(?:\\.|(?!\1)[^\\\r\n])*\1/,
greedy: true
},

'constant': /\b(?:PORT[A-Z]|DDR[A-Z]|(?:DD|P)[A-Z](?:\d|[0-2]\d|3[0-1]))\b/,

'directive': {
pattern: /\.\w+(?= )/,
alias: 'property'
},
'r-register': {
pattern: /\br(?:\d|[1-2]\d|3[0-1])\b/,
alias: 'variable'
},
'op-code': {
pattern: /\b(?:ADC|ADD|ADIW|AND|ANDI|ASR|BCLR|BLD|BRBC|BRBS|BRCC|BRCS|BREAK|BREQ|BRGE|BRHC|BRHS|BRID|BRIE|BRLO|BRLT|BRMI|BRNE|BRPL|BRSH|BRTC|BRTS|BRVC|BRVS|BSET|BST|CALL|CBI|CBR|CLC|CLH|CLI|CLN|CLR|CLS|CLT|CLV|CLZ|COM|CP|CPC|CPI|CPSE|DEC|DES|EICALL|EIJMP|ELPM|EOR|FMUL|FMULS|FMULSU|ICALL|IJMP|IN|INC|JMP|LAC|LAS|LAT|LD|LD[A-Za-z0-9]|LPM|LSL|LSR|MOV|MOVW|MUL|MULS|MULSU|NEG|NOP|OR|ORI|OUT|POP|PUSH|RCALL|RET|RETI|RJMP|ROL|ROR|SBC|SBCI|SBI|SBIC|SBIS|SBIW|SBR|SBRC|SBRS|SEC|SEH|SEI|SEN|SER|SES|SET|SEV|SEZ|SLEEP|SPM|ST|ST[A-Z0-9]|SUB|SUBI|SWAP|TST|WDR|XCH|adc|add|adiw|and|andi|asr|bclr|bld|brbc|brbs|brcc|brcs|break|breq|brge|brhc|brhs|brid|brie|brlo|brlt|brmi|brne|brpl|brsh|brtc|brts|brvc|brvs|bset|bst|call|cbi|cbr|clc|clh|cli|cln|clr|cls|clt|clv|clz|com|cp|cpc|cpi|cpse|dec|des|eicall|eijmp|elpm|eor|fmul|fmuls|fmulsu|icall|ijmp|in|inc|jmp|lac|las|lat|ld|ld[a-z0-9]|lpm|lsl|lsr|mov|movw|mul|muls|mulsu|neg|nop|or|ori|out|pop|push|rcall|ret|reti|rjmp|rol|ror|sbc|sbci|sbi|sbic|sbis|sbiw|sbr|sbrc|sbrs|sec|seh|sei|sen|ser|ses|set|sev|sez|sleep|spm|st|st[a-zA-Z0-9]|sub|subi|swap|tst|wdr|xch)\b/,
alias: 'keyword'
},
'hex-number': {
pattern: /#?\$[\da-f]{2,4}\b/i,
alias: 'number'
},
'binary-number': {
pattern: /#?%[01]+\b/,
alias: 'number'
},
'decimal-number': {
pattern: /#?\b\d+\b/,
alias: 'number'
},
'register': {
pattern: /\b[acznvshtixy]\b/i,
alias: 'variable'
},
'operator': />>=?|<<=?|&&?|\|\|?|[-+*/%&|^!=<>?]=?/,
'punctuation': /[(),:]/
};
1 change: 1 addition & 0 deletions components/prism-asmatmel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-birb.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Prism.languages.birb = Prism.languages.extend('clike', {
/\b[A-Z](?:[\d_]*[a-zA-Z]\w*)?\b/,

// matches variable and function return types (parameters as well).
/\b[A-Z]\w*(?=\s+\w+\s*[;,=()])/
/\b(?:[A-Z]\w*|(?!(?:var|void)\b)[a-z]\w*)(?=\s+\w+\s*[;,=()])/
],
'keyword': /\b(?:assert|break|case|class|const|default|else|enum|final|follows|for|grab|if|nest|new|next|noSeeb|return|static|switch|throw|var|void|while)\b/,
'operator': /\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?|:/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-birb.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions components/prism-bsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ Prism.languages.bsl = {
{
pattern: /\b(?:and|not|or)\b/i
}

],
'punctuation': /\(\.|\.\)|[()\[\]:;,.]/,
'directive': [
// Теги препроцессора вида &Клиент, &Сервер, ...
// Preprocessor tags of the type &Client, &Server, ...
{
pattern: /^(\s*)&.*/m,
pattern: /^([ \t]*)&.*/m,
lookbehind: true,
greedy: true,
alias: 'important'
},
// Инструкции препроцессора вида:
Expand All @@ -64,7 +64,9 @@ Prism.languages.bsl = {
// ...
// #EndIf
{
pattern: /^\s*#.*/gm,
pattern: /^([ \t]*)#.*/gm,
lookbehind: true,
greedy: true,
alias: 'important'
}
]
Expand Down
2 changes: 1 addition & 1 deletion components/prism-bsl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/prism-cil.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Prism.languages.cil = {

'keyword': /\b(?:abstract|ansi|assembly|auto|autochar|beforefieldinit|bool|bstr|byvalstr|catch|char|cil|class|currency|date|decimal|default|enum|error|explicit|extends|extern|famandassem|family|famorassem|final(?:ly)?|float32|float64|hidebysig|u?int(?:8|16|32|64)?|iant|idispatch|implements|import|initonly|instance|interface|iunknown|literal|lpstr|lpstruct|lptstr|lpwstr|managed|method|native(?:Type)?|nested|newslot|object(?:ref)?|pinvokeimpl|private|privatescope|public|reqsecobj|rtspecialname|runtime|sealed|sequential|serializable|specialname|static|string|struct|syschar|tbstr|unicode|unmanagedexp|unsigned|value(?:type)?|variant|virtual|void)\b/,

'function': /\b(?:(?:constrained|no|readonly|tail|unaligned|volatile)\.)?(?:conv\.(?:[iu][1248]?|ovf\.[iu][1248]?(?:\.un)?|r\.un|r4|r8)|ldc\.(?:i4(?:\.[0-9]+|\.[mM]1|\.s)?|i8|r4|r8)|ldelem(?:\.[iu][1248]?|\.r[48]|\.ref|a)?|ldind\.(?:[iu][1248]?|r[48]|ref)|stelem\.?(?:i[1248]?|r[48]|ref)?|stind\.(?:i[1248]?|r[48]|ref)?|end(?:fault|filter|finally)|ldarg(?:\.[0-3s]|a(?:\.s)?)?|ldloc(?:\.[0-9]+|\.s)?|sub(?:\.ovf(?:\.un)?)?|mul(?:\.ovf(?:\.un)?)?|add(?:\.ovf(?:\.un)?)?|stloc(?:\.[0-3s])?|refany(?:type|val)|blt(?:\.un)?(?:\.s)?|ble(?:\.un)?(?:\.s)?|bgt(?:\.un)?(?:\.s)?|bge(?:\.un)?(?:\.s)?|unbox(?:\.any)?|init(?:blk|obj)|call(?:i|virt)?|brfalse(?:\.s)?|bne\.un(?:\.s)?|ldloca(?:\.s)?|brzero(?:\.s)?|brtrue(?:\.s)?|brnull(?:\.s)?|brinst(?:\.s)?|starg(?:\.s)?|leave(?:\.s)?|shr(?:\.un)?|rem(?:\.un)?|div(?:\.un)?|clt(?:\.un)?|alignment|castclass|ldvirtftn|beq(?:\.s)?|ckfinite|ldsflda|ldtoken|localloc|mkrefany|rethrow|cgt\.un|arglist|switch|stsfld|sizeof|newobj|newarr|ldsfld|ldnull|ldflda|isinst|throw|stobj|stfld|ldstr|ldobj|ldlen|ldftn|ldfld|cpobj|cpblk|break|br\.s|xor|shl|ret|pop|not|nop|neg|jmp|dup|cgt|ceq|box|and|or|br)\b/,
'function': /\b(?:(?:constrained|no|readonly|tail|unaligned|volatile)\.)?(?:conv\.(?:[iu][1248]?|ovf\.[iu][1248]?(?:\.un)?|r\.un|r4|r8)|ldc\.(?:i4(?:\.\d+|\.[mM]1|\.s)?|i8|r4|r8)|ldelem(?:\.[iu][1248]?|\.r[48]|\.ref|a)?|ldind\.(?:[iu][1248]?|r[48]|ref)|stelem\.?(?:i[1248]?|r[48]|ref)?|stind\.(?:i[1248]?|r[48]|ref)?|end(?:fault|filter|finally)|ldarg(?:\.[0-3s]|a(?:\.s)?)?|ldloc(?:\.\d+|\.s)?|sub(?:\.ovf(?:\.un)?)?|mul(?:\.ovf(?:\.un)?)?|add(?:\.ovf(?:\.un)?)?|stloc(?:\.[0-3s])?|refany(?:type|val)|blt(?:\.un)?(?:\.s)?|ble(?:\.un)?(?:\.s)?|bgt(?:\.un)?(?:\.s)?|bge(?:\.un)?(?:\.s)?|unbox(?:\.any)?|init(?:blk|obj)|call(?:i|virt)?|brfalse(?:\.s)?|bne\.un(?:\.s)?|ldloca(?:\.s)?|brzero(?:\.s)?|brtrue(?:\.s)?|brnull(?:\.s)?|brinst(?:\.s)?|starg(?:\.s)?|leave(?:\.s)?|shr(?:\.un)?|rem(?:\.un)?|div(?:\.un)?|clt(?:\.un)?|alignment|castclass|ldvirtftn|beq(?:\.s)?|ckfinite|ldsflda|ldtoken|localloc|mkrefany|rethrow|cgt\.un|arglist|switch|stsfld|sizeof|newobj|newarr|ldsfld|ldnull|ldflda|isinst|throw|stobj|stfld|ldstr|ldobj|ldlen|ldftn|ldfld|cpobj|cpblk|break|br\.s|xor|shl|ret|pop|not|nop|neg|jmp|dup|cgt|ceq|box|and|or|br)\b/,

'boolean': /\b(?:false|true)\b/,
'number': /\b-?(?:0x[0-9a-f]+|[0-9]+)(?:\.[0-9a-f]+)?\b/i,
'number': /\b-?(?:0x[0-9a-f]+|\d+)(?:\.[0-9a-f]+)?\b/i,

'punctuation': /[{}[\];(),:=]|IL_[0-9A-Za-z]+/
};
2 changes: 1 addition & 1 deletion components/prism-cil.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit df8ee50

Please sign in to comment.