Skip to content

Commit

Permalink
Merge branch 'master' into regex-test-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed May 29, 2021
2 parents a23014b + 01cc18e commit 2aa89a7
Show file tree
Hide file tree
Showing 36 changed files with 83 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module.exports = {

// stylistic rules
'brace-style': ['warn', '1tbs', { allowSingleLine: true }],
'curly': ['warn', 'all'],
'eol-last': 'warn',
'no-multiple-empty-lines': ['warn', { max: 2, maxBOF: 0, maxEOF: 0 }],
'no-tabs': ['warn', { allowIndentationTabs: true }],
'no-var': 'error',
'one-var': ['warn', 'never'],
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Prism depends on community contributions to expand and cover a wider array of us

- Read the [documentation](https://prismjs.com/extending.html). Prism was designed to be extensible.
- Do not edit `prism.js`, it’s just the version of Prism used by the Prism website and is built automatically. Limit your changes to the unminified files in the `components/` folder. `prism.js` and all minified files are also generated automatically by our build system.
- Use `npm ci` to install Prism's dependencies. Do not use `npm install` because it will cause non-deterministic builds.
- The build system uses [gulp](https://github.com/gulpjs/gulp) to minify the files and build `prism.js`. With all of Prism's dependencies installed, you just need to run the command `npm run build`.
- Please follow the code conventions used in the files already. For example, I use [tabs for indentation and spaces for alignment](http://lea.verou.me/2012/01/why-tabs-are-clearly-superior/). Opening braces are on the same line, closing braces on their own line regardless of construct. There is a space before the opening brace. etc etc.
- Please try to err towards more smaller PRs rather than a few huge PRs. If a PR includes changes that I want to merge and also changes that I don't, handling it becomes difficult.
Expand Down
4 changes: 3 additions & 1 deletion assets/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@

// calc()
(function () {
if (!window.PrefixFree) return;
if (!window.PrefixFree) {
return;
}

if (PrefixFree.functions.indexOf('calc') == -1) {
var style = document.createElement('_').style;
Expand Down
9 changes: 6 additions & 3 deletions assets/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,16 @@
}

function getLanguageTitle(lang) {
if (!lang.aliasTitles)
if (!lang.aliasTitles) {
return lang.title;
}

var titles = [lang.title];
for (var alias in lang.aliasTitles)
if (lang.aliasTitles.hasOwnProperty(alias))
for (var alias in lang.aliasTitles) {
if (lang.aliasTitles.hasOwnProperty(alias)) {
titles.push(lang.aliasTitles[alias]);
}
}
return titles.join(' + ');
}

Expand Down
2 changes: 1 addition & 1 deletion components/prism-abap.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-ada.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Prism.languages.ada = {
'punctuation': /\.\.?|[,;():]/,
'char': /'.'/,
'variable': /\b[a-z](?:[_a-z\d])*\b/i
};
};
2 changes: 1 addition & 1 deletion components/prism-arff.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Prism.languages.arff = {
'keyword': /@(?:attribute|data|end|relation)\b/i,
'number': /\b\d+(?:\.\d+)?\b/,
'punctuation': /[{},]/
};
};
2 changes: 1 addition & 1 deletion components/prism-bbcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Prism.languages.bbcode = {
}
};

Prism.languages.shortcode = Prism.languages.bbcode;
Prism.languages.shortcode = Prism.languages.bbcode;
2 changes: 1 addition & 1 deletion components/prism-brainfuck.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Prism.languages.brainfuck = {
},
'operator': /[.,]/,
'comment': /\S+/
};
};
2 changes: 1 addition & 1 deletion components/prism-csp.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Prism.languages.csp = {
pattern: /(?:'unsafe-(?:allow-redirects|dynamic|eval|hash-attributes|hashed-attributes|hashes|inline)'|\*)/i,
alias: 'function'
}
};
};
1 change: 0 additions & 1 deletion components/prism-dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@
Prism.languages.gv = Prism.languages.dot;

}(Prism));

2 changes: 1 addition & 1 deletion components/prism-haxe.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Prism.languages.insertBefore('haxe', 'keyword', {
}
});
Prism.languages.haxe['string'].inside['interpolation'].inside.rest = Prism.languages.haxe;
delete Prism.languages.haxe['class-name'];
delete Prism.languages.haxe['class-name'];
2 changes: 1 addition & 1 deletion components/prism-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Prism.languages.icon = {
'function': /(?!\d)\w+(?=\s*[({]|\s*!\s*\[)/,
'operator': /[+-]:(?!=)|(?:[\/?@^%&]|\+\+?|--?|==?=?|~==?=?|\*\*?|\|\|\|?|<(?:->?|<?=?)|>>?=?)(?::=)?|:(?:=:?)?|[!.\\|~]/,
'punctuation': /[\[\](){},;]/
};
};
2 changes: 1 addition & 1 deletion components/prism-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|ext

Prism.languages.insertBefore('javascript', 'keyword', {
'regex': {
pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
lookbehind: true,
greedy: true,
inside: {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-javascript.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-keyman.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Prism.languages.keyman = {
'number': /\b(?:U\+[\dA-F]+|d\d+|x[\da-f]+|\d+)\b/i, // U+####, x###, d### characters and numbers
'operator': /[+>\\,()]/,
'tag': /\$(?:keyman|kmfl|weaver|keymanweb|keymanonly):/i // prefixes
};
};
3 changes: 2 additions & 1 deletion components/prism-markup-templating.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
var placeholder;

// Check for existing strings
while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1)
while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
++i;
}

// Create a sparse array
tokenStack[i] = match;
Expand Down
2 changes: 1 addition & 1 deletion components/prism-mizar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Prism.languages.mizar = {
'number': /(?:\b|-)\d+\b/,
'operator': /\.\.\.|->|&|\.?=/,
'punctuation': /\(#|#\)|[,:;\[\](){}]/
};
};
1 change: 0 additions & 1 deletion components/prism-neon.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ Prism.languages.neon = {
},
'punctuation': /[,:=[\]{}()-]/,
};

2 changes: 1 addition & 1 deletion components/prism-php-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Prism.languages.insertBefore('php', 'variable', {
punctuation: /::|\\/
}
}
});
});
2 changes: 1 addition & 1 deletion components/prism-soy.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@
Prism.languages['markup-templating'].tokenizePlaceholders(env, 'soy');
});

}(Prism));
}(Prism));
1 change: 0 additions & 1 deletion components/prism-stylus.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
},



// A selector can contain parentheses only as part of a pseudo-element
// It can span multiple lines.
// It must end with a comma or an accolade or have indented content.
Expand Down
2 changes: 1 addition & 1 deletion components/prism-v.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@
}
}
});
}(Prism));
}(Prism));
2 changes: 1 addition & 1 deletion components/prism-wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ Prism.languages.wasm = {
'variable': /\$[\w!#$%&'*+\-./:<=>?@\\^_`|~]+/i,
'number': /[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/,
'punctuation': /[()]/
};
};
2 changes: 1 addition & 1 deletion components/prism-xojo.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Prism.languages.xojo = {
'keyword': /\b(?:AddHandler|App|Array|As(?:signs)?|Auto|By(?:Ref|Val)|Boolean|Break|Byte|Call|Case|Catch|CFStringRef|CGFloat|Class|Color|Const|Continue|CString|Currency|CurrentMethodName|Declare|Delegate|Dim|Do(?:uble|wnTo)?|Each|Else(?:If)?|End|Enumeration|Event|Exception|Exit|Extends|False|Finally|For|Function|Get|GetTypeInfo|Global|GOTO|If|Implements|In|Inherits|Int(?:erface|eger|8|16|32|64)?|Lib|Loop|Me|Module|Next|Nil|Object|Optional|OSType|ParamArray|Private|Property|Protected|PString|Ptr|Raise(?:Event)?|ReDim|RemoveHandler|Return|Select(?:or)?|Self|Set|Single|Shared|Short|Soft|Static|Step|String|Sub|Super|Text|Then|To|True|Try|Ubound|UInt(?:eger|8|16|32|64)?|Until|Using|Var(?:iant)?|Wend|While|WindowPtr|WString)\b/i,
'operator': /<[=>]?|>=?|[+\-*\/\\^=]|\b(?:AddressOf|And|Ctype|IsA?|Mod|New|Not|Or|Xor|WeakAddressOf)\b/i,
'punctuation': /[.,;:()]/
};
};
4 changes: 3 additions & 1 deletion dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const getChangedMinifiedFiles = async () => {

// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript
const formatBytes = (bytes, decimals = 2) => {
if (bytes === 0) return '0 Bytes';
if (bytes === 0) {
return '0 Bytes';
}

const k = 1000;
const dm = decimals < 0 ? 0 : decimals;
Expand Down
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h2>Contribute to Prism!</h2>
<ul>
<li>Read the <a href="https://prismjs.com/extending.html">documentation</a>. Prism was designed to be extensible.</li>
<li>Do not edit <code>prism.js</code>, it’s just the version of Prism used by the Prism website and is built automatically. Limit your changes to the unminified files in the <code>components/</code> folder. <code>prism.js</code> and all minified files are also generated automatically by our build system.</li>
<li>Use <code>npm ci</code> to install Prism's dependencies. Do not use <code>npm install</code> because it will cause non-deterministic builds.</li>
<li>The build system uses <a href="https://github.com/gulpjs/gulp">gulp</a> to minify the files and build <code>prism.js</code>. With all of Prism's dependencies installed, you just need to run the command <code>npm run build</code>.</li>
<li>Please follow the code conventions used in the files already. For example, I use <a href="http://lea.verou.me/2012/01/why-tabs-are-clearly-superior/">tabs for indentation and spaces for alignment</a>. Opening braces are on the same line, closing braces on their own line regardless of construct. There is a space before the opening brace. etc etc.</li>
<li>Please try to err towards more smaller PRs rather than a few huge PRs. If a PR includes changes that I want to merge and also changes that I don't, handling it becomes difficult.</li>
Expand Down
15 changes: 15 additions & 0 deletions plugins/command-line/prism-command-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
return s;
}

/**
* Returns whether the given hook environment has a command line info object.
*
* @param {any} env
* @returns {boolean}
*/
function hasCommandLineInfo(env) {
var vars = env.vars = env.vars || {};
return 'command-line' in vars;
}
/**
* Returns the command line info object from the given hook environment.
*
Expand Down Expand Up @@ -129,6 +139,11 @@
});

Prism.hooks.add('complete', function (env) {
if (!hasCommandLineInfo(env)) {
// the previous hooks never ran
return;
}

var commandLine = getCommandLineInfo(env);

if (commandLine.complete) {
Expand Down
Loading

0 comments on commit 2aa89a7

Please sign in to comment.