1
+ /* eslint-disable no-unused-vars */
2
+ /* eslint-disable no-use-before-define */
1
3
// For TS consumers who use Node and don't have dom in their tsconfig lib, import the necessary types here.
2
4
/// <reference lib="dom" />
3
5
@@ -77,6 +79,7 @@ interface HighlightResult {
77
79
errorRaised ? : Error
78
80
// * for auto-highlight
79
81
second_best ? : Omit < HighlightResult , 'second_best' >
82
+ code ?: string
80
83
}
81
84
interface AutoHighlightResult extends HighlightResult { }
82
85
@@ -86,14 +89,17 @@ interface illegalData {
86
89
mode : CompiledMode
87
90
}
88
91
89
- type PluginEvent =
90
- 'before:highlight'
91
- | 'after:highlight'
92
- | 'before:highlightBlock'
93
- | 'after:highlightBlock'
94
-
92
+ type BeforeHighlightContext = {
93
+ code : string ,
94
+ language : string ,
95
+ result ?: HighlightResult
96
+ }
97
+ type PluginEvent = keyof HLJSPlugin ;
95
98
type HLJSPlugin = {
96
- [ K in PluginEvent ] ? : any
99
+ 'after:highlight' ?: ( result : HighlightResult ) => void ,
100
+ 'before:highlight' ?: ( context : BeforeHighlightContext ) => void ,
101
+ 'after:highlightBlock' ?: ( data : { result : HighlightResult } ) => void ,
102
+ 'before:highlightBlock' ?: ( data : { block : Element , language : string } ) => void ,
97
103
}
98
104
99
105
interface EmitterConstructor {
@@ -162,6 +168,7 @@ interface LanguageDetail {
162
168
exports ?: any ,
163
169
classNameAliases ?: Record < string , string >
164
170
compilerExtensions ?: CompilerExt [ ]
171
+ supersetOf ?: string
165
172
}
166
173
167
174
type Language = LanguageDetail & Partial < Mode >
0 commit comments