Skip to content

Commit ba8735f

Browse files
authored
fix(types) Fix some type definition issues (#3274)
* fix(types) begin, match, end all now take arrays * fix(types) _emit now a scope attribute, not mode attribute * fix(types) do not forget about endScope * remove dead code * fix(types) make hljs not optional * changelog
1 parent 83ad2fb commit ba8735f

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Version 11.2.0 (pending)
2+
3+
Parser:
4+
5+
- fix(types) Fix some type definition issues (#3274) [Josh Goebel][]
6+
7+
[Josh Goebel]: https://github.com/joshgoebel
8+
19
## Version 11.1.0
210

311
Grammars:

src/highlight.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ const HLJS = function(hljs) {
428428
}
429429
}
430430
do {
431-
if (top.scope && !top.isMultiClass) {
431+
if (top.scope) {
432432
emitter.closeNode();
433433
}
434434
if (!top.skip && !top.subLanguage) {

types/index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ declare module 'highlight.js' {
7474
RE_STARTERS_RE: string
7575
}
7676

77-
export type LanguageFn = (hljs?: HLJSApi) => Language
77+
export type LanguageFn = (hljs: HLJSApi) => Language
7878
export type CompilerExt = (mode: Mode, parent: Mode | Language | null) => void
7979

8080
export interface HighlightResult {
@@ -201,21 +201,21 @@ declare module 'highlight.js' {
201201
illegalRe: RegExp
202202
matcher: any
203203
isCompiled: true
204-
isMultiClass?: boolean
205204
starts?: CompiledMode
206205
parent?: CompiledMode
207206
beginScope?: Record<number, string> & {_emit?: Record<number,boolean>, _multi?: boolean, _wrap?: string}
208207
endScope?: Record<number, string> & {_emit?: Record<number,boolean>, _multi?: boolean, _wrap?: string}
209208
}
210209

211210
interface ModeDetails {
212-
begin?: RegExp | string
213-
match?: RegExp | string
214-
end?: RegExp | string
211+
begin?: RegExp | string | (RegExp | string)[]
212+
match?: RegExp | string | (RegExp | string)[]
213+
end?: RegExp | string | (RegExp | string)[]
214+
// deprecated in favor of `scope`
215215
className?: string
216-
_emit?: Record<number, boolean>
217216
scope?: string | Record<number, string>
218217
beginScope?: string | Record<number, string>
218+
endScope?: string | Record<number, string>
219219
contains?: ("self" | Mode)[]
220220
endsParent?: boolean
221221
endsWithParent?: boolean

0 commit comments

Comments
 (0)