Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(misc) Misc fixes from looking at LGTM #2852

Merged
merged 3 commits into from Nov 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Expand Up @@ -22,6 +22,9 @@ New Languages:

Language Improvements:

- fix(r) fixed keywords not properly spaced (#2852) [Josh Goebel][]
- fix(javascript) fix potential catastrophic backtracking (#2852) [Josh Goebel][]
- fix(livescript) fix potential catastrophic backtracking (#2852) [Josh Goebel][]
- bug(xml) XML grammar was far too imprecise/fuzzy [Josh Goebel][]
- enh(xml) Improve precision to prevent false auto-detect positives [Josh Goebel][]
- fix(js/ts) Prevent for/while/if/switch from falsly matching as functions (#2803) [Josh Goebel][]
Expand Down
2 changes: 1 addition & 1 deletion src/languages/1c.js
Expand Up @@ -515,5 +515,5 @@ export default function(hljs) {
STRINGS,
DATE
]
}
};
}
2 changes: 1 addition & 1 deletion src/languages/hy.js
Expand Up @@ -101,5 +101,5 @@ export default function(hljs) {
aliases: ['hylang'],
illegal: /\S/,
contains: [hljs.SHEBANG(), LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER, LITERAL]
}
};
}
2 changes: 0 additions & 2 deletions src/languages/java.js
Expand Up @@ -5,8 +5,6 @@ Category: common, enterprise
Website: https://www.java.com/
*/

import * as regex from '../lib/regex.js';

export default function(hljs) {
var JAVA_IDENT_RE = '[\u00C0-\u02B8a-zA-Z_$][\u00C0-\u02B8a-zA-Z_$0-9]*';
var GENERIC_IDENT_RE = JAVA_IDENT_RE + '(<' + JAVA_IDENT_RE + '(\\s*,\\s*' + JAVA_IDENT_RE + ')*>)?';
Expand Down
6 changes: 2 additions & 4 deletions src/languages/javascript.js
Expand Up @@ -18,7 +18,7 @@ export default function(hljs) {
* @param {{after:number}} param1
*/
const hasClosingTag = (match, { after }) => {
const tag = match[0].replace("<", "</");
const tag = "</" + match[0].slice(1);
const pos = match.input.indexOf(tag, after);
return pos !== -1;
};
Expand Down Expand Up @@ -256,9 +256,7 @@ export default function(hljs) {
regex.lookahead(regex.concat(
// we also need to allow for multiple possible comments inbetween
// the first key:value pairing
/(\/\/.*$)*/,
/(\/\*(.|\n)*\*\/)*/,
/\s*/,
/(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/,
IDENT_RE + '\\s*:'))),
relevance: 0,
contains: [
Expand Down
2 changes: 1 addition & 1 deletion src/languages/kotlin.js
Expand Up @@ -66,7 +66,7 @@ export default function(hljs) {
}
]
};
SUBST.contains.push(STRING)
SUBST.contains.push(STRING);

var ANNOTATION_USE_SITE = {
className: 'meta', begin: '@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*' + hljs.UNDERSCORE_IDENT_RE + ')?'
Expand Down
2 changes: 1 addition & 1 deletion src/languages/livescript.js
Expand Up @@ -115,7 +115,7 @@ export default function(hljs) {
{
// regex can't start with space to parse x / 2 / 3 as two divisions
// regex can't start with *, and it supports an "illegal" in the main mode
begin: /\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W)/
begin: /\/(?![ *])(\\.|[^\\\n])*?\/[gim]*(?=\W)/
joshgoebel marked this conversation as resolved.
Show resolved Hide resolved
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/languages/mercury.js
Expand Up @@ -49,7 +49,7 @@ export default function(hljs) {
begin: '\\\\[abfnrtv]\\|\\\\x[0-9a-fA-F]*\\\\\\|%[-+# *.0-9]*[dioxXucsfeEgGp]',
relevance: 0
};
STRING.contains = STRING.contains.slice() // we need our own copy of contains
STRING.contains = STRING.contains.slice(); // we need our own copy of contains
STRING.contains.push(STRING_FMT);

var IMPLICATION = {
Expand Down
2 changes: 1 addition & 1 deletion src/languages/parser3.js
Expand Up @@ -20,7 +20,7 @@ export default function(hljs) {
contains: [
hljs.COMMENT('^#', '$'),
hljs.COMMENT(
/\\^rem\{/,
/\^rem\{/,
/\}/,
{
relevance: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/languages/powershell.js
Expand Up @@ -242,7 +242,7 @@ export default function(hljs) {
)
};

PS_METHODS.contains.unshift(PS_TYPE)
PS_METHODS.contains.unshift(PS_TYPE);

return {
name: 'PowerShell',
Expand Down
32 changes: 16 additions & 16 deletions src/languages/r.js
Expand Up @@ -32,22 +32,22 @@ export default function(hljs) {
// Primitive functions
// These are all the functions in `base` that are implemented as a
// `.Primitive`, minus those functions that are also keywords.
'abs acos acosh all any anyNA Arg as.call as.character' +
'as.complex as.double as.environment as.integer as.logical' +
'as.null.default as.numeric as.raw asin asinh atan atanh attr' +
'attributes baseenv browser c call ceiling class Conj cos cosh' +
'cospi cummax cummin cumprod cumsum digamma dim dimnames' +
'emptyenv exp expression floor forceAndCall gamma gc.time' +
'globalenv Im interactive invisible is.array is.atomic is.call' +
'is.character is.complex is.double is.environment is.expression' +
'is.finite is.function is.infinite is.integer is.language' +
'is.list is.logical is.matrix is.na is.name is.nan is.null' +
'is.numeric is.object is.pairlist is.raw is.recursive is.single' +
'is.symbol lazyLoadDBfetch length lgamma list log max min' +
'missing Mod names nargs nzchar oldClass on.exit pos.to.env' +
'proc.time prod quote range Re rep retracemem return round' +
'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt' +
'standardGeneric substitute sum switch tan tanh tanpi tracemem' +
'abs acos acosh all any anyNA Arg as.call as.character ' +
'as.complex as.double as.environment as.integer as.logical ' +
'as.null.default as.numeric as.raw asin asinh atan atanh attr ' +
'attributes baseenv browser c call ceiling class Conj cos cosh ' +
'cospi cummax cummin cumprod cumsum digamma dim dimnames ' +
'emptyenv exp expression floor forceAndCall gamma gc.time ' +
'globalenv Im interactive invisible is.array is.atomic is.call ' +
'is.character is.complex is.double is.environment is.expression ' +
'is.finite is.function is.infinite is.integer is.language ' +
'is.list is.logical is.matrix is.na is.name is.nan is.null ' +
'is.numeric is.object is.pairlist is.raw is.recursive is.single ' +
'is.symbol lazyLoadDBfetch length lgamma list log max min ' +
'missing Mod names nargs nzchar oldClass on.exit pos.to.env ' +
'proc.time prod quote range Re rep retracemem return round ' +
'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt ' +
'standardGeneric substitute sum switch tan tanh tanpi tracemem ' +
'trigamma trunc unclass untracemem UseMethod xtfrm',
},

Expand Down
2 changes: 1 addition & 1 deletion src/languages/swift.js
Expand Up @@ -50,7 +50,7 @@ export default function(hljs) {
var OPTIONAL_USING_TYPE = {
className: 'type',
begin: '\\b[A-Z][\\w\u00C0-\u02B8\']*[!?]'
}
};
var BLOCK_COMMENT = hljs.COMMENT(
'/\\*',
'\\*/',
Expand Down
4 changes: 2 additions & 2 deletions tools/developer.html
Expand Up @@ -57,7 +57,7 @@
}
</style>
</head>
<body id>
<body>
<div class="editor" id="app">
<h3>Code</h3>
<div>
Expand Down Expand Up @@ -295,7 +295,7 @@ <h3>Markup</h3>
this.refreshKlass();
}
}
})
});
</script>
</body>
</html>