Fix/issue 3972
Problem: When I use namespace as the name of the variable, everything that follows is highlighted incorrectly. While namespace is a TS keyword it's fine to use it as a variable name too. Solution: Used a multimatcher to solve it
Before:
After:
Resolves #3972
Changes
Before:
const NAMESPACE = {
beginKeywords: 'namespace',
end: /\{/,
excludeEnd: true,
contains: [ tsLanguage.exports.CLASS_REFERENCE ]
};
After:
const NAMESPACE = {
begin: [
/namespace/,
/\s+/,
hljs.IDENT_RE
],
beginScope: {
1: "keyword",
3: "variable"
},
end: /\{/,
excludeEnd: true,
contains: [tsLanguage.exports.CLASS_REFERENCE]
};
Checklist
- [x] Added markup tests, or they don't apply here because...
- [x] Updated the changelog at
CHANGES.md
Build Size Report
Changes to minified artifacts in /build, after gzip compression.
5 files changed
Total change +40 B
View Changes
| file | base | pr | diff |
|---|---|---|---|
| es/core.min.js | 8.17 KB | 8.17 KB | -1 B |
| es/highlight.min.js | 8.17 KB | 8.17 KB | -1 B |
| es/languages/typescript.min.js | 3.15 KB | 3.17 KB | +22 B |
| highlight.min.js | 8.21 KB | 8.2 KB | -2 B |
| languages/typescript.min.js | 3.16 KB | 3.18 KB | +22 B |
Build Size Report
Changes to minified artifacts in /build, after gzip compression.
5 files changed
Total change +31 B
View Changes
| file | base | pr | diff |
|---|---|---|---|
| es/core.min.js | 8.17 KB | 8.18 KB | +2 B |
| es/highlight.min.js | 8.17 KB | 8.18 KB | +2 B |
| es/languages/typescript.min.js | 3.15 KB | 3.16 KB | +12 B |
| highlight.min.js | 8.21 KB | 8.21 KB | +2 B |
| languages/typescript.min.js | 3.16 KB | 3.17 KB | +13 B |
Build Size Report
Changes to minified artifacts in /build, after gzip compression.
3 files changed
Total change +24 B
View Changes
| file | base | pr | diff |
|---|---|---|---|
| es/languages/typescript.min.js | 3.15 KB | 3.16 KB | +12 B |
| highlight.min.js | 8.21 KB | 8.21 KB | -1 B |
| languages/typescript.min.js | 3.16 KB | 3.17 KB | +13 B |
Build Size Report
Changes to minified artifacts in /build, after gzip compression.
3 files changed
Total change +12 B
View Changes
| file | base | pr | diff |
|---|---|---|---|
| es/languages/typescript.min.js | 3.15 KB | 3.16 KB | +6 B |
| highlight.min.js | 8.21 KB | 8.21 KB | -1 B |
| languages/typescript.min.js | 3.16 KB | 3.17 KB | +7 B |
Build Size Report
Changes to minified artifacts in /build, after gzip compression.
3 files changed
Total change +12 B
View Changes
| file | base | pr | diff |
|---|---|---|---|
| es/languages/typescript.min.js | 3.15 KB | 3.16 KB | +6 B |
| highlight.min.js | 8.21 KB | 8.21 KB | -1 B |
| languages/typescript.min.js | 3.16 KB | 3.17 KB | +7 B |