From 6b3245df1d0da06cdd7fc74a849a83edf40deb45 Mon Sep 17 00:00:00 2001 From: Saad <57033728+akhtarmdsaad@users.noreply.github.com> Date: Sun, 28 Jan 2024 06:35:56 +0000 Subject: [PATCH 1/7] ABC --- run.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 run.html diff --git a/run.html b/run.html new file mode 100644 index 0000000000..38a868c36f --- /dev/null +++ b/run.html @@ -0,0 +1,21 @@ + + + + + + Document + + + + +
+        
+            const saad = "saad is";
+        
+    
+ + + + \ No newline at end of file From 77434cef0ed81e1ea6948763a26f36de3c6294c4 Mon Sep 17 00:00:00 2001 From: Saad <57033728+akhtarmdsaad@users.noreply.github.com> Date: Sun, 18 Feb 2024 05:52:02 +0000 Subject: [PATCH 2/7] Fix issue #3972 --- run.html | 21 --------------------- src/languages/typescript.js | 12 ++++++++++-- 2 files changed, 10 insertions(+), 23 deletions(-) delete mode 100644 run.html diff --git a/run.html b/run.html deleted file mode 100644 index 38a868c36f..0000000000 --- a/run.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - Document - - - - -
-        
-            const saad = "saad is";
-        
-    
- - - - \ No newline at end of file diff --git a/src/languages/typescript.js b/src/languages/typescript.js index 5e95bcbdd2..93f433c0fe 100644 --- a/src/languages/typescript.js +++ b/src/languages/typescript.js @@ -28,10 +28,18 @@ export default function(hljs) { "unknown" ]; const NAMESPACE = { - beginKeywords: 'namespace', + begin: [ + /namespace/, + /\s+/, + hljs.IDENT_RE + ], + beginScope: { + 1: "keyword", + 3: "variable" + }, end: /\{/, excludeEnd: true, - contains: [ tsLanguage.exports.CLASS_REFERENCE ] + contains: [tsLanguage.exports.CLASS_REFERENCE] }; const INTERFACE = { beginKeywords: 'interface', From e0bfab15ae000fad5fb92c354a63bd0da97be384 Mon Sep 17 00:00:00 2001 From: Saad <57033728+akhtarmdsaad@users.noreply.github.com> Date: Sun, 18 Feb 2024 06:23:33 +0000 Subject: [PATCH 3/7] Added markup test --- test/markup/typescript/namespace_as_identifier.expect.txt | 4 ++++ test/markup/typescript/namespace_as_identifier.txt | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 test/markup/typescript/namespace_as_identifier.expect.txt create mode 100644 test/markup/typescript/namespace_as_identifier.txt diff --git a/test/markup/typescript/namespace_as_identifier.expect.txt b/test/markup/typescript/namespace_as_identifier.expect.txt new file mode 100644 index 0000000000..edcd9eef12 --- /dev/null +++ b/test/markup/typescript/namespace_as_identifier.expect.txt @@ -0,0 +1,4 @@ + + const message = 'foo'; + const namespace = 'bar'; + function baz() {} \ No newline at end of file diff --git a/test/markup/typescript/namespace_as_identifier.txt b/test/markup/typescript/namespace_as_identifier.txt new file mode 100644 index 0000000000..ed0b42ef2d --- /dev/null +++ b/test/markup/typescript/namespace_as_identifier.txt @@ -0,0 +1,3 @@ + const message = 'foo'; + const namespace = 'bar'; + function baz() {} \ No newline at end of file From 695e52cbe604f4ad4c9346588dadcc5d4d5c382f Mon Sep 17 00:00:00 2001 From: Saad <57033728+akhtarmdsaad@users.noreply.github.com> Date: Sun, 18 Feb 2024 06:27:43 +0000 Subject: [PATCH 4/7] Updated Changes.md file --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index cd133d7c7d..6c3a9ea883 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -88,6 +88,7 @@ New Grammars: Core Grammars: +- fix(cpp) fixed highlighter break state [Md Saad Akhtar][] - fix(rust) added negative-lookahead for callable keywords `if` `while` `for` [Omar Hussein][] - enh(armasm) added `x0-x30` and `w0-w30` ARMv8 registers [Nicholas Thompson][] - enh(haxe) added `final`, `is`, `macro` keywords and `$` identifiers [Robert Borghese][] From 457ce3dcca64a9c2a876a1de183ef0bf8ccfa840 Mon Sep 17 00:00:00 2001 From: Saad <57033728+akhtarmdsaad@users.noreply.github.com> Date: Sat, 24 Feb 2024 16:36:47 +0000 Subject: [PATCH 5/7] Removed unnecessary modes --- src/languages/typescript.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/languages/typescript.js b/src/languages/typescript.js index 93f433c0fe..3acdce6243 100644 --- a/src/languages/typescript.js +++ b/src/languages/typescript.js @@ -35,11 +35,8 @@ export default function(hljs) { ], beginScope: { 1: "keyword", - 3: "variable" - }, - end: /\{/, - excludeEnd: true, - contains: [tsLanguage.exports.CLASS_REFERENCE] + 3: "title.class" + } }; const INTERFACE = { beginKeywords: 'interface', From 3f616e94bda1dc49a494bf64c2e46031917d3180 Mon Sep 17 00:00:00 2001 From: Saad <57033728+akhtarmdsaad@users.noreply.github.com> Date: Sun, 25 Feb 2024 03:23:25 +0000 Subject: [PATCH 6/7] Fixed ts_specific keywords --- src/languages/typescript.js | 2 +- test/markup/typescript/namespace_as_identifier.expect.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/typescript.js b/src/languages/typescript.js index 3acdce6243..26d1594081 100644 --- a/src/languages/typescript.js +++ b/src/languages/typescript.js @@ -55,7 +55,7 @@ export default function(hljs) { }; const TS_SPECIFIC_KEYWORDS = [ "type", - "namespace", + // "namespace", "interface", "public", "private", diff --git a/test/markup/typescript/namespace_as_identifier.expect.txt b/test/markup/typescript/namespace_as_identifier.expect.txt index edcd9eef12..e5f56f9998 100644 --- a/test/markup/typescript/namespace_as_identifier.expect.txt +++ b/test/markup/typescript/namespace_as_identifier.expect.txt @@ -1,4 +1,4 @@ const message = 'foo'; - const namespace = 'bar'; + const namespace = 'bar'; function baz() {} \ No newline at end of file From fcf18a70cc99ca294ff0fefca014cddcbe0f7bc7 Mon Sep 17 00:00:00 2001 From: Saad <57033728+akhtarmdsaad@users.noreply.github.com> Date: Sun, 25 Feb 2024 03:28:26 +0000 Subject: [PATCH 7/7] Added the reason for the change --- src/languages/typescript.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/languages/typescript.js b/src/languages/typescript.js index 26d1594081..4e818849c8 100644 --- a/src/languages/typescript.js +++ b/src/languages/typescript.js @@ -67,6 +67,13 @@ export default function(hljs) { "enum", "override" ]; + + /* + namespace is a TS keyword but it's fine to use it as a variable name too. + const message = 'foo'; + const namespace = 'bar'; + */ + const KEYWORDS = { $pattern: ECMAScript.IDENT_RE, keyword: ECMAScript.KEYWORDS.concat(TS_SPECIFIC_KEYWORDS),