From 6148d7b32749257bc23750fa178dae08c8a0fafe Mon Sep 17 00:00:00 2001 From: Vania Kucher Date: Tue, 28 Apr 2020 01:39:03 +0300 Subject: [PATCH 1/9] fix(javascript) prevent setter keyword 'set' conflicting with setTimeout|setInterval (#2514) --- CHANGES.md | 1 + src/languages/javascript.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index b5f7f6b497..e3d27ccbf4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Deprecations: Language Improvements: +- fix(javascript) prevent setter keyword `set` conflicting with setTimeout|setInterval (#2514) [Vania Kucher][] - fix(cpp) Fix highlighting of unterminated raw strings (#2261) [David Benjamin][] - fix(javascript) `=>` function with nested `()` in params now works (#2502) [Josh Goebel][] - fix(typescript) `=>` function with nested `()` in params now works (#2502) [Josh Goebel][] diff --git a/src/languages/javascript.js b/src/languages/javascript.js index 0ad9b3f18f..0e7b3f6efc 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -263,7 +263,7 @@ export default function(hljs) { beginKeywords: 'constructor', end: /\{/, excludeEnd: true }, { - begin:'(get|set)\\s*(?=' + IDENT_RE+ '\\()', + begin: "(get|set)\\s+(?=" + IDENT_RE + "\\()", end: /{/, keywords: "get set", contains: [ From 7b54beb617df03e2bf931fb67389d301674062dd Mon Sep 17 00:00:00 2001 From: Vania Kucher Date: Tue, 28 Apr 2020 01:42:59 +0300 Subject: [PATCH 2/9] enh(javascript) setTimeout|setInterval now highlighted (#2514) --- CHANGES.md | 1 + src/languages/javascript.js | 6 ++++++ .../javascript/keyword-as-part-of-method-name.expect.txt | 2 ++ test/markup/javascript/keyword-as-part-of-method-name.txt | 2 ++ 4 files changed, 11 insertions(+) create mode 100644 test/markup/javascript/keyword-as-part-of-method-name.expect.txt create mode 100644 test/markup/javascript/keyword-as-part-of-method-name.txt diff --git a/CHANGES.md b/CHANGES.md index e3d27ccbf4..9957d2832d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Deprecations: Language Improvements: +- enh(javascript) setTimeout|setInterval now highlighted (#2514) [Vania Kucher][] - fix(javascript) prevent setter keyword `set` conflicting with setTimeout|setInterval (#2514) [Vania Kucher][] - fix(cpp) Fix highlighting of unterminated raw strings (#2261) [David Benjamin][] - fix(javascript) `=>` function with nested `()` in params now works (#2502) [Josh Goebel][] diff --git a/src/languages/javascript.js b/src/languages/javascript.js index 0e7b3f6efc..302142d04c 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -272,6 +272,12 @@ export default function(hljs) { PARAMS ] + }, + { + beginKeywords: "(setInterval|setTimeout)", + keywords: "setInterval setTimeout", + end: /\(/, + excludeEnd: true, } ], illegal: /#(?!!)/ diff --git a/test/markup/javascript/keyword-as-part-of-method-name.expect.txt b/test/markup/javascript/keyword-as-part-of-method-name.expect.txt new file mode 100644 index 0000000000..e73ace0dca --- /dev/null +++ b/test/markup/javascript/keyword-as-part-of-method-name.expect.txt @@ -0,0 +1,2 @@ +setTimeout(); +setInterval(); \ No newline at end of file diff --git a/test/markup/javascript/keyword-as-part-of-method-name.txt b/test/markup/javascript/keyword-as-part-of-method-name.txt new file mode 100644 index 0000000000..30d71a2e36 --- /dev/null +++ b/test/markup/javascript/keyword-as-part-of-method-name.txt @@ -0,0 +1,2 @@ +setTimeout(); +setInterval(); \ No newline at end of file From 71df8674e4e86e93a77541ebe9283a64292b8e0c Mon Sep 17 00:00:00 2001 From: Vania Kucher Date: Tue, 28 Apr 2020 01:58:30 +0300 Subject: [PATCH 3/9] fix (javascript) add setTimeout|setInterval to build-it keywords --- src/languages/javascript.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/languages/javascript.js b/src/languages/javascript.js index 302142d04c..041212998a 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -33,7 +33,7 @@ export default function(hljs) { 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' + 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' + 'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect ' + - 'Promise' + 'Promise setInterval setTimeout' }; var NUMBER = { className: 'number', @@ -263,7 +263,7 @@ export default function(hljs) { beginKeywords: 'constructor', end: /\{/, excludeEnd: true }, { - begin: "(get|set)\\s+(?=" + IDENT_RE + "\\()", + begin: '(get|set)\\s+(?=" + IDENT_RE + "\\()', end: /{/, keywords: "get set", contains: [ @@ -272,12 +272,6 @@ export default function(hljs) { PARAMS ] - }, - { - beginKeywords: "(setInterval|setTimeout)", - keywords: "setInterval setTimeout", - end: /\(/, - excludeEnd: true, } ], illegal: /#(?!!)/ From 3039ea2dea216e6241a367deee74935b0248e675 Mon Sep 17 00:00:00 2001 From: Vania Kucher Date: Tue, 28 Apr 2020 01:59:46 +0300 Subject: [PATCH 4/9] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 9957d2832d..0c16210410 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,7 @@ Language Improvements: [Josh Goebel]: https://github.com/yyyc514 [Peter Plantinga]: https://github.com/pplantinga [David Benjamin]: https://github.com/davidben +[Vania Kucher]: https://github.com/qWici ## Version 10.0.1 From 892cd302991b1d0665c18566066c37158524c903 Mon Sep 17 00:00:00 2001 From: Vania Kucher Date: Tue, 28 Apr 2020 02:01:03 +0300 Subject: [PATCH 5/9] Okey prettier just stop joking --- src/languages/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/javascript.js b/src/languages/javascript.js index 041212998a..752887b209 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -263,7 +263,7 @@ export default function(hljs) { beginKeywords: 'constructor', end: /\{/, excludeEnd: true }, { - begin: '(get|set)\\s+(?=" + IDENT_RE + "\\()', + begin: '(get|set)\\s+(?=' + IDENT_RE + '\\()', end: /{/, keywords: "get set", contains: [ From dd5cb35e01af66fa2f26c6902f8e3a914d7b3bfb Mon Sep 17 00:00:00 2001 From: Vania Kucher Date: Tue, 28 Apr 2020 02:03:26 +0300 Subject: [PATCH 6/9] enh (javascript) clearInterval and clearTimeout now highlighted --- src/languages/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/javascript.js b/src/languages/javascript.js index 752887b209..eb0d62adc0 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -33,7 +33,7 @@ export default function(hljs) { 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' + 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' + 'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect ' + - 'Promise setInterval setTimeout' + 'Promise setInterval setTimeout clearInterval clearTimeout' }; var NUMBER = { className: 'number', From 551ccde713cd19d2fffbf4d574e5f642ed91228a Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Mon, 27 Apr 2020 19:07:50 -0400 Subject: [PATCH 7/9] Update CHANGES.md --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0c16210410..edbd57023f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,8 +13,8 @@ Deprecations: Language Improvements: -- enh(javascript) setTimeout|setInterval now highlighted (#2514) [Vania Kucher][] -- fix(javascript) prevent setter keyword `set` conflicting with setTimeout|setInterval (#2514) [Vania Kucher][] +- enh(javascript) add setInterval, setTimeout, clearInterval, clearTimeout (#2514) [Vania Kucher][] +- fix(javascript) prevent `set` keyword conflicting with setTimeout, etc. (#2514) [Vania Kucher][] - fix(cpp) Fix highlighting of unterminated raw strings (#2261) [David Benjamin][] - fix(javascript) `=>` function with nested `()` in params now works (#2502) [Josh Goebel][] - fix(typescript) `=>` function with nested `()` in params now works (#2502) [Josh Goebel][] From f34e50153f7219533352b5a4aecbfa27489f793b Mon Sep 17 00:00:00 2001 From: Vania Kucher Date: Tue, 28 Apr 2020 02:14:40 +0300 Subject: [PATCH 8/9] Fix markup test --- .../javascript/keyword-as-part-of-method-name.expect.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/markup/javascript/keyword-as-part-of-method-name.expect.txt b/test/markup/javascript/keyword-as-part-of-method-name.expect.txt index e73ace0dca..5a004f4fa0 100644 --- a/test/markup/javascript/keyword-as-part-of-method-name.expect.txt +++ b/test/markup/javascript/keyword-as-part-of-method-name.expect.txt @@ -1,2 +1,2 @@ -setTimeout(); -setInterval(); \ No newline at end of file +setTimeout(); +setInterval(); \ No newline at end of file From 872d07912b51e5bffad54a4ef03f15f3c85d2e38 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Tue, 28 Apr 2020 11:55:04 -0400 Subject: [PATCH 9/9] add parity with TypeScript --- CHANGES.md | 1 + src/languages/typescript.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index edbd57023f..d8cbfee4b4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Deprecations: Language Improvements: +- enh(typescript) add setInterval, setTimeout, clearInterval, clearTimeout (#2514) [Josh Goebel][] - enh(javascript) add setInterval, setTimeout, clearInterval, clearTimeout (#2514) [Vania Kucher][] - fix(javascript) prevent `set` keyword conflicting with setTimeout, etc. (#2514) [Vania Kucher][] - fix(cpp) Fix highlighting of unterminated raw strings (#2261) [David Benjamin][] diff --git a/src/languages/typescript.js b/src/languages/typescript.js index 9266b55e6b..fd7f59ad7f 100644 --- a/src/languages/typescript.js +++ b/src/languages/typescript.js @@ -25,7 +25,8 @@ export default function(hljs) { 'TypeError URIError Number Math Date String RegExp Array Float32Array ' + 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' + 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' + - 'module console window document any number boolean string void Promise' + 'module console window document any number boolean string void Promise ' + + 'setInterval setTimeout clearInterval clearTimeout' }; var DECORATOR = { className: 'meta',