From 2423c3fedea3f357fd61cda9da9cec131cfa5286 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Wed, 14 Jul 2021 15:42:17 -0400 Subject: [PATCH 1/6] fix(types) begin, match, end all now take arrays --- types/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 0dd8534f8f..d254b352d4 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -209,9 +209,9 @@ declare module 'highlight.js' { } interface ModeDetails { - begin?: RegExp | string - match?: RegExp | string - end?: RegExp | string + begin?: RegExp | string | (RegExp | string)[] + match?: RegExp | string | (RegExp | string)[] + end?: RegExp | string | (RegExp | string)[] className?: string _emit?: Record scope?: string | Record From 79eb4e9e4f5dbae2c7c202e684e6c65e0ab9c294 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Wed, 14 Jul 2021 15:42:37 -0400 Subject: [PATCH 2/6] fix(types) _emit now a scope attribute, not mode attribute --- types/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index d254b352d4..5a85f54dc5 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -213,7 +213,6 @@ declare module 'highlight.js' { match?: RegExp | string | (RegExp | string)[] end?: RegExp | string | (RegExp | string)[] className?: string - _emit?: Record scope?: string | Record beginScope?: string | Record contains?: ("self" | Mode)[] From 389b96bab63a7f9d43ae4650df330417d6d07633 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Wed, 14 Jul 2021 15:43:35 -0400 Subject: [PATCH 3/6] fix(types) do not forget about endScope --- types/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/index.d.ts b/types/index.d.ts index 5a85f54dc5..41826aef6a 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -212,9 +212,11 @@ declare module 'highlight.js' { begin?: RegExp | string | (RegExp | string)[] match?: RegExp | string | (RegExp | string)[] end?: RegExp | string | (RegExp | string)[] + // deprecated in favor of `scope` className?: string scope?: string | Record beginScope?: string | Record + endScope?: string | Record contains?: ("self" | Mode)[] endsParent?: boolean endsWithParent?: boolean From 8c1349b99a8bd0abe9f66a3a03dcc805ba5acbde Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Wed, 14 Jul 2021 15:50:34 -0400 Subject: [PATCH 4/6] remove dead code --- src/highlight.js | 2 +- types/index.d.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/highlight.js b/src/highlight.js index deb545bd11..29ef8a8713 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -428,7 +428,7 @@ const HLJS = function(hljs) { } } do { - if (top.scope && !top.isMultiClass) { + if (top.scope) { emitter.closeNode(); } if (!top.skip && !top.subLanguage) { diff --git a/types/index.d.ts b/types/index.d.ts index 41826aef6a..db758101fd 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -201,7 +201,6 @@ declare module 'highlight.js' { illegalRe: RegExp matcher: any isCompiled: true - isMultiClass?: boolean starts?: CompiledMode parent?: CompiledMode beginScope?: Record & {_emit?: Record, _multi?: boolean, _wrap?: string} From 0b80bb8640dbe6dea62527a56ecf7949f29a85ee Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Wed, 14 Jul 2021 15:52:01 -0400 Subject: [PATCH 5/6] fix(types) make hljs not optional --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index db758101fd..d53ee2d515 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -74,7 +74,7 @@ declare module 'highlight.js' { RE_STARTERS_RE: string } - export type LanguageFn = (hljs?: HLJSApi) => Language + export type LanguageFn = (hljs: HLJSApi) => Language export type CompilerExt = (mode: Mode, parent: Mode | Language | null) => void export interface HighlightResult { From ef043393db904421956d967132e258f6ccf56cff Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Thu, 22 Jul 2021 20:45:24 -0400 Subject: [PATCH 6/6] changelog --- CHANGES.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 8c1e67b20e..327cdc8c4f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,11 @@ +## Version 11.2.0 (pending) + +Parser: + +- fix(types) Fix some type definition issues (#3274) [Josh Goebel][] + +[Josh Goebel]: https://github.com/joshgoebel + ## Version 11.1.0 Grammars: