Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Parser:

Grammars:

- fix(js/ts) `Float32Array` highlighted incorrectly (#3353) [Josh Goebel][]
- fix(css) single-colon psuedo-elements no longer break highlighting (#3240) [Josh Goebel][]
- fix(scss) single-colon psuedo-elements no longer break highlighting (#3240) [Josh Goebel][]
- enh(fsharp) rewrite most of the grammar, with many improvements [Melvyn Laïly][]
Expand Down
10 changes: 9 additions & 1 deletion src/languages/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,15 @@ export default function(hljs) {

const CLASS_REFERENCE = {
relevance: 0,
match: /\b[A-Z][a-z]+([A-Z][a-z]+)*/,
match:
regex.either(
// Float32Array
/\b[A-Z][a-z]+([A-Z][a-z]+|\d)*/,
// CSSFactory
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+/,
// BLAH
// this will be flagged as a UPPER_CASE_CONSTANT instead
),
className: "title.class",
keywords: {
_: [
Expand Down
7 changes: 7 additions & 0 deletions test/markup/javascript/class.expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@
<span class="hljs-keyword">if</span>(value) {}
<span class="hljs-keyword">switch</span>(value) {}
<span class="hljs-keyword">try</span> {} <span class="hljs-keyword">catch</span>(err) {}

<span class="hljs-title class_">Car</span>
<span class="hljs-title class_">Vehicle</span>
<span class="hljs-title class_">SelfDrivingTruck</span>
<span class="hljs-title class_">CSSParser</span>
<span class="hljs-title class_">Float32Array</span>
<span class="hljs-title class_">BigInt64Array</span>
7 changes: 7 additions & 0 deletions test/markup/javascript/class.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ while(value) {}
if(value) {}
switch(value) {}
try {} catch(err) {}

Car
Vehicle
SelfDrivingTruck
CSSParser
Float32Array
BigInt64Array