Skip to content

Commit 84bcd12

Browse files
committed
Merge remote-tracking branch 'upstream/main' into fix/rust-attribute-ensure-bracket-balance
2 parents 16ce416 + 9a70b83 commit 84bcd12

18 files changed

+118
-5
lines changed

CHANGES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,30 @@
33
New Grammars:
44

55
- added 3rd party Aiken grammar to SUPPORTED_LANGUAGES [Josh Marchand][]
6+
- added 3rd party VoltScript grammar to SUPPORTED_LANGUAGES [Chester Moses][]
67

78
Core Grammars:
89

10+
- fix(javascript) correctly highlight 'for await' again [wolfgang42][]
911
- enh(csp) add missing directives / keywords from MDN (7 more) [Max Liashuk][]
1012
- enh(ada) add new `parallel` keyword, allow `[]` for Ada 2022 [Max Reznik][]
13+
- fix(ex) adds support for `?'` char literal and missing `defguardp` keyword [Kevin Bloch][]
14+
- fix(diff) fix unified diff hunk header regex to allow unpaired numbers [Chris Wilson][]
15+
- enh(php) support single line and hash comments in attributes, constructor and functions [Antoine Musso][]
1116
- fix(rust) ensure brackets are balanced within attributes [ewwwin][]
1217

1318
CONTRIBUTORS
1419

1520
[Josh Marchand]: https://github.com/yHSJ
1621
[Max Liashuk]: https://github.com/probil
1722
[Max Reznik]: https://github.com/reznikmm
23+
[Kevin Bloch]: https://github.com/codingthat
24+
[Chris Wilson]: https://github.com/sushicw
25+
[Antoine Musso]: https://github.com/hashar
26+
[Chester Moses]: https://github.com/Chester-Moses-HCL
1827
[ewwwin]: https://github.com/ewwwin
1928

29+
2030
## Version 11.11.1
2131

2232
- Fixes regression with Rust grammar.

SUPPORTED_LANGUAGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ The table below shows the full list of languages (and corresponding classes/alia
253253
| Vala | vala | |
254254
| Verilog | verilog, v | |
255255
| Vim Script | vim | |
256+
| VoltScript | voltscript, vss, lotusscript, lss | [highlightjs-voltscript](https://github.com/HCL-TECH-SOFTWARE/highlightjs-voltscript) |
256257
| WGSL | wgsl | [highlightjs-wgsl](https://github.com/highlightjs/highlightjs-wgsl) |
257258
| X# | xsharp, xs, prg | [highlightjs-xsharp](https://github.com/InfomindsAg/highlightjs-xsharp) |
258259
| X++ | axapta, x++ | |

src/languages/diff.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export default function(hljs) {
1717
className: 'meta',
1818
relevance: 10,
1919
match: regex.either(
20-
/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,
20+
/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/, // @@ -1,2 +1,2 @@
21+
/^@@ +-\d+ +\+\d+,\d+ +@@/, // @@ -1 +1,2 @@
22+
/^@@ +-\d+,\d+ +\+\d+ +@@/, // @@ -1,2 +1 @@
23+
/^@@ +-\d+ +\+\d+ +@@/, // @@ -1 +1 @@
2124
/^\*\*\* +\d+,\d+ +\*\*\*\*$/,
2225
/^--- +\d+,\d+ +----$/
2326
)

src/languages/elixir.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default function(hljs) {
2020
"cond",
2121
"defstruct",
2222
"defguard",
23+
"defguardp",
2324
"do",
2425
"else",
2526
"end",
@@ -228,7 +229,13 @@ export default function(hljs) {
228229
beginKeywords: 'defimpl defmodule defprotocol defrecord',
229230
end: /\bdo\b|$|;/
230231
});
232+
const CHAR_LITERAL = {
233+
scope: 'string',
234+
match: /\?'/,
235+
relevance: 0
236+
};
231237
const ELIXIR_DEFAULT_CONTAINS = [
238+
CHAR_LITERAL,
232239
STRING,
233240
REGEX_SIGIL,
234241
UPCASE_SIGIL,

src/languages/javascript.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ export default function(hljs) {
387387
noneOf([
388388
...ECMAScript.BUILT_IN_GLOBALS,
389389
"super",
390-
"import"
390+
"import",
391+
"await",
391392
].map(x => `${x}\\s*\\(`)),
392393
IDENT_RE, regex.lookahead(/\s*\(/)),
393394
className: "title.function",

src/languages/php.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ export default function(hljs) {
414414
VARIABLE,
415415
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
416416
hljs.C_BLOCK_COMMENT_MODE,
417+
hljs.C_LINE_COMMENT_MODE,
418+
hljs.HASH_COMMENT_MODE,
417419
STRING,
418420
NUMBER,
419421
CONSTRUCTOR_CALL,
@@ -438,6 +440,8 @@ export default function(hljs) {
438440
NAMED_ARGUMENT,
439441
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
440442
hljs.C_BLOCK_COMMENT_MODE,
443+
hljs.C_LINE_COMMENT_MODE,
444+
hljs.HASH_COMMENT_MODE,
441445
STRING,
442446
NUMBER,
443447
CONSTRUCTOR_CALL,
@@ -566,6 +570,8 @@ export default function(hljs) {
566570
VARIABLE,
567571
LEFT_AND_RIGHT_SIDE_OF_DOUBLE_COLON,
568572
hljs.C_BLOCK_COMMENT_MODE,
573+
hljs.C_LINE_COMMENT_MODE,
574+
hljs.HASH_COMMENT_MODE,
569575
STRING,
570576
NUMBER
571577
]

test/detect/elixir/default.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ guy = Person.new first_name: "Guy"
1010
guy.name
1111

1212
defmodule ListServer do
13+
defguardp apostrophe?(c) when c == ?'
1314
@moduledoc """
1415
This module provides an easy to use ListServer, useful for keeping
1516
lists of things.

test/markup/diff/git-format-patch.expect.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,26 @@
1212
<span class="hljs-meta">@@ -28,2 +28,2 @@</span>
1313
<span class="hljs-deletion">- removal</span>
1414
<span class="hljs-addition">+ addition</span>
15+
<span class="hljs-comment">diff --git a/file.txt b/file.txt</span>
16+
<span class="hljs-comment">index 8baef1b..24c5735 100644</span>
17+
<span class="hljs-comment">--- a/file.txt</span>
18+
<span class="hljs-comment">+++ b/file.txt</span>
19+
<span class="hljs-meta">@@ -1 +1 @@</span>
20+
<span class="hljs-deletion">-removal</span>
21+
<span class="hljs-addition">+addition</span>
22+
<span class="hljs-comment">diff --git a/file.txt b/file.txt</span>
23+
<span class="hljs-comment">index f9308d8..f39c17d 100644</span>
24+
<span class="hljs-comment">--- a/file.txt</span>
25+
<span class="hljs-comment">+++ b/file.txt</span>
26+
<span class="hljs-meta">@@ -1,2 +1 @@</span>
27+
<span class="hljs-deletion">-removal1</span>
28+
<span class="hljs-deletion">-removal2</span>
29+
<span class="hljs-addition">+addition</span>
30+
<span class="hljs-comment">diff --git a/file.txt b/file.txt</span>
31+
<span class="hljs-comment">index 1037b05..54addbd 100644</span>
32+
<span class="hljs-comment">--- a/file.txt</span>
33+
<span class="hljs-comment">+++ b/file.txt</span>
34+
<span class="hljs-meta">@@ -1 +1,2 @@</span>
35+
<span class="hljs-deletion">-removal</span>
36+
<span class="hljs-addition">+addition1</span>
37+
<span class="hljs-addition">+addition2</span>

test/markup/diff/git-format-patch.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,26 @@ index 123456..789abc 100644
1212
@@ -28,2 +28,2 @@
1313
- removal
1414
+ addition
15+
diff --git a/file.txt b/file.txt
16+
index 8baef1b..24c5735 100644
17+
--- a/file.txt
18+
+++ b/file.txt
19+
@@ -1 +1 @@
20+
-removal
21+
+addition
22+
diff --git a/file.txt b/file.txt
23+
index f9308d8..f39c17d 100644
24+
--- a/file.txt
25+
+++ b/file.txt
26+
@@ -1,2 +1 @@
27+
-removal1
28+
-removal2
29+
+addition
30+
diff --git a/file.txt b/file.txt
31+
index 1037b05..54addbd 100644
32+
--- a/file.txt
33+
+++ b/file.txt
34+
@@ -1 +1,2 @@
35+
-removal
36+
+addition1
37+
+addition2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<span class="hljs-keyword">defguardp</span> apostrophe?(c) <span class="hljs-keyword">when</span> c == <span class="hljs-string">?&#x27;</span>
2+
<span class="hljs-keyword">defguardp</span> upper?(c) <span class="hljs-keyword">when</span> (c &gt;= ?A <span class="hljs-keyword">and</span> c &lt;= ?Z)

test/markup/elixir/char-literal.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
defguardp apostrophe?(c) when c == ?'
2+
defguardp upper?(c) when (c >= ?A and c <= ?Z)

test/markup/javascript/keywords.expect.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@
1111
<span class="hljs-keyword">return</span> <span class="hljs-regexp">/\d+[\s/]/g</span>;
1212
}
1313
<span class="hljs-keyword">using</span> val = <span class="hljs-title function_">condition</span>();
14+
<span class="hljs-keyword">for</span> <span class="hljs-keyword">await</span> (<span class="hljs-keyword">const</span> item <span class="hljs-keyword">of</span> items) {
15+
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(item);
16+
}
1417
}

test/markup/javascript/keywords.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ function $initHighlight(block, cls) {
1111
return /\d+[\s/]/g;
1212
}
1313
using val = condition();
14+
for await (const item of items) {
15+
console.log(item);
16+
}
1417
}

test/markup/php/attributes.expect.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@
4444
<span class="hljs-attr">fields</span>: [
4545
<span class="hljs-string">&#x27;authorEmail&#x27;</span> =&gt; <span class="hljs-keyword">new</span> <span class="hljs-title class_">Assert\Email</span>,
4646
<span class="hljs-string">&#x27;shortDesc&#x27;</span> =&gt; [
47-
<span class="hljs-comment">/*something*/</span>
47+
<span class="hljs-comment">// C line comment</span>
4848
<span class="hljs-keyword">new</span> <span class="hljs-title class_">Assert\NotBlank</span>,
49+
<span class="hljs-comment">/* C block comment */</span>
4950
<span class="hljs-keyword">new</span> <span class="hljs-title class_">Assert\Length</span>(
5051
<span class="hljs-attr">max</span>: <span class="hljs-number">200</span>,
5152
<span class="hljs-attr">maxMessage</span>: <span class="hljs-string">&#x27;Your short desc is too long&#x27;</span>
5253
)
54+
<span class="hljs-comment"># Hash comment</span>
5355
],
5456
],
5557
<span class="hljs-attr">allowMissingFields</span>: <span class="hljs-literal">true</span>,

test/markup/php/attributes.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ class Book
4444
fields: [
4545
'authorEmail' => new Assert\Email,
4646
'shortDesc' => [
47-
/*something*/
47+
// C line comment
4848
new Assert\NotBlank,
49+
/* C block comment */
4950
new Assert\Length(
5051
max: 200,
5152
maxMessage: 'Your short desc is too long'
5253
)
54+
# Hash comment
5355
],
5456
],
5557
allowMissingFields: true,

test/markup/php/functions.expect.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,15 @@
4949
<span class="hljs-attr">label</span>: <span class="hljs-string">&#x27;foo&#x27;</span>,
5050
<span class="hljs-attr">time</span>:<span class="hljs-title function_ invoke__">time</span>() + <span class="hljs-keyword">array</span>(<span class="hljs-number">5</span>)[<span class="hljs-number">0</span>] + <span class="hljs-title class_">Foo</span>::<span class="hljs-variable constant_">HOUR</span>,
5151
);
52+
53+
<span class="hljs-title function_ invoke__">header</span>(
54+
<span class="hljs-comment">// Contained C line comment</span>
55+
<span class="hljs-comment">/* Contained C block comment */</span>
56+
<span class="hljs-comment"># Contained hash comment</span>
57+
);
58+
59+
<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params">
60+
<span class="hljs-variable">$x</span>, <span class="hljs-comment">// C line comment</span>
61+
<span class="hljs-comment">/* C block comment */</span>
62+
<span class="hljs-variable">$y</span>, <span class="hljs-comment"># Contained hash comment</span>
63+
</span>) =&gt;</span> <span class="hljs-variable">$x</span> / <span class="hljs-variable">$y</span>;

test/markup/php/functions.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,15 @@ setAlarm(
4949
label: 'foo',
5050
time:time() + array(5)[0] + Foo::HOUR,
5151
);
52+
53+
header(
54+
// Contained C line comment
55+
/* Contained C block comment */
56+
# Contained hash comment
57+
);
58+
59+
fn(
60+
$x, // C line comment
61+
/* C block comment */
62+
$y, # Contained hash comment
63+
) => $x / $y;

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ declare module 'highlight.js' {
3030

3131
interface PublicApi {
3232
highlight(code: string, options: HighlightOptions): HighlightResult
33-
/** @deprecated use `higlight(code, {lang: ..., ignoreIllegals: ...})` */
33+
/** @deprecated use `highlight(code, {language: ..., ignoreIllegals: ...})` */
3434
highlight(languageName: string, code: string, ignoreIllegals?: boolean): HighlightResult
3535
highlightAuto: (code: string, languageSubset?: string[]) => AutoHighlightResult
3636
highlightBlock: (element: HTMLElement) => void

0 commit comments

Comments
 (0)