New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix "is not a module" #2603 #2606
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import './types'; | ||
|
||
declare const hljs: HLJSApi; | ||
|
||
export = hljs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import './types'; | ||
|
||
declare const hljs: HLJSApi; | ||
|
||
export = hljs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,212 +1,5 @@ | ||
/* Public API */ | ||
import './types'; | ||
|
||
// eslint-disable-next-line | ||
declare const hljs : HLJSApi; | ||
declare const hljs: HLJSApi; | ||
|
||
interface HLJSApi { | ||
highlight: (languageName: string, code: string, ignoreIllegals?: boolean, continuation?: Mode) => HighlightResult | ||
highlightAuto: (code: string, languageSubset?: string[]) => AutoHighlightResult | ||
fixMarkup: (html: string) => string | ||
highlightBlock: (element: HTMLElement) => void | ||
configure: (options: Partial<HLJSOptions>) => void | ||
initHighlighting: () => void | ||
initHighlightingOnLoad: () => void | ||
registerLanguage: (languageName: string, language: LanguageFn) => void | ||
listLanguages: () => string[] | ||
registerAliases: (aliasList: string | string[], { languageName } : {languageName: string}) => void | ||
getLanguage: (languageName: string) => Language | undefined | ||
requireLanguage: (languageName: string) => Language | never | ||
autoDetection: (languageName: string) => boolean | ||
inherit: <T>(original: T, ...args: Record<string, any>[]) => T | ||
addPlugin: (plugin: HLJSPlugin) => void | ||
debugMode: () => void | ||
safeMode: () => void | ||
versionString: string | ||
} | ||
|
||
interface HLJSApi { | ||
SHEBANG: (mode?: Partial<Mode> & {binary?: string | RegExp}) => Mode | ||
BACKSLASH_ESCAPE: Mode | ||
QUOTE_STRING_MODE: Mode | ||
APOS_STRING_MODE: Mode | ||
PHRASAL_WORDS_MODE: Mode | ||
COMMENT: (begin: string | RegExp, end: string | RegExp, modeOpts?: Mode | {}) => Mode | ||
C_LINE_COMMENT_MODE: Mode | ||
C_BLOCK_COMMENT_MODE: Mode | ||
HASH_COMMENT_MODE: Mode | ||
NUMBER_MODE: Mode | ||
C_NUMBER_MODE: Mode | ||
BINARY_NUMBER_MODE: Mode | ||
CSS_NUMBER_MODE: Mode | ||
REGEXP_MODE: Mode | ||
TITLE_MODE: Mode | ||
UNDERSCORE_TITLE_MODE: Mode | ||
METHOD_GUARD: Mode | ||
END_SAME_AS_BEGIN: (mode: Mode) => Mode | ||
// build in regex | ||
IDENT_RE: string | ||
UNDERSCORE_IDENT_RE: string | ||
NUMBER_RE: string | ||
C_NUMBER_RE: string | ||
BINARY_NUMBER_RE: string | ||
RE_STARTERS_RE: string | ||
} | ||
|
||
type LanguageFn = (hljs: HLJSApi) => Language | ||
|
||
// interface RawLanguage { | ||
// name?: string | ||
// aliases?: string[] | ||
// rawDefinition?: () => Language | ||
// } | ||
|
||
interface HighlightResult { | ||
relevance : number | ||
value : string | ||
language? : string | ||
emitter : Emitter | ||
illegal : boolean | ||
top? : Language | CompiledMode | ||
illegalBy? : illegalData | ||
sofar? : string | ||
errorRaised? : Error | ||
// * for auto-highlight | ||
second_best? : Omit<HighlightResult, 'second_best'> | ||
} | ||
|
||
interface illegalData { | ||
msg: string | ||
context: string | ||
mode: CompiledMode | ||
} | ||
|
||
interface AutoHighlightResult extends HighlightResult { | ||
} | ||
|
||
type PluginEvent = | ||
'before:highlight' | ||
| 'after:highlight' | ||
| 'before:highlightBlock' | ||
| 'after:highlightBlock' | ||
|
||
type HLJSPlugin = { [K in PluginEvent]? : any } | ||
|
||
interface EmitterConstructor { | ||
new (opts: any): Emitter | ||
} | ||
|
||
interface HLJSOptions { | ||
noHighlightRe: RegExp | ||
languageDetectRe: RegExp | ||
classPrefix: string | ||
tabReplace?: string | ||
useBR: boolean | ||
languages?: string[] | ||
__emitter: EmitterConstructor | ||
} | ||
|
||
interface CallbackResponse { | ||
data: Record<string, any> | ||
ignoreMatch: () => void | ||
} | ||
|
||
/************ | ||
PRIVATE API | ||
************/ | ||
|
||
/* for jsdoc annotations in the JS source files */ | ||
|
||
type AnnotatedError = Error & {mode?: Mode | Language, languageName?: string, badRule?: Mode} | ||
|
||
type ModeCallback = (match: RegExpMatchArray, response: CallbackResponse) => void | ||
type HighlightedHTMLElement = HTMLElement & {result?: object, second_best?: object, parentNode: HTMLElement} | ||
type EnhancedMatch = RegExpMatchArray & {rule: CompiledMode, type: MatchType} | ||
type MatchType = "begin" | "end" | "illegal" | ||
|
||
interface Emitter { | ||
addKeyword(text: string, kind: string): void | ||
addText(text: string): void | ||
toHTML(): string | ||
finalize(): void | ||
closeAllNodes(): void | ||
openNode(kind: string): void | ||
closeNode(): void | ||
addSublanguage(emitter: Emitter, subLanguageName: string): void | ||
} | ||
|
||
/* modes */ | ||
|
||
interface ModeCallbacks { | ||
"on:end"?: Function, | ||
"on:begin"?: Function, | ||
} | ||
|
||
interface Mode extends ModeCallbacks, ModeDetails { | ||
|
||
} | ||
|
||
interface LanguageDetail { | ||
name?: string | ||
rawDefinition?: () => Language | ||
aliases?: string[] | ||
disableAutodetect?: boolean | ||
contains: ("self"|Mode)[] | ||
case_insensitive?: boolean | ||
keywords?: Record<string, any> | string | ||
compiled?: boolean | ||
} | ||
|
||
type Language = LanguageDetail & Partial<Mode> | ||
|
||
interface CompiledLanguage extends LanguageDetail, CompiledMode { | ||
compiled: true | ||
contains: CompiledMode[] | ||
keywords: Record<string, any> | ||
} | ||
|
||
type KeywordData = [string, number]; | ||
type KeywordDict = Record<string, KeywordData> | ||
|
||
type CompiledMode = Omit<Mode, 'contains'> & | ||
{ | ||
contains: CompiledMode[] | ||
keywords: KeywordDict | ||
data: Record<string, any> | ||
terminator_end: string | ||
keywordPatternRe: RegExp | ||
beginRe: RegExp | ||
endRe: RegExp | ||
illegalRe: RegExp | ||
matcher: any | ||
compiled: true | ||
starts?: CompiledMode | ||
parent?: CompiledMode | ||
} | ||
|
||
interface ModeDetails { | ||
begin?: RegExp | string | ||
end?: RegExp | string | ||
className?: string | ||
contains?: ("self" | Mode)[] | ||
endsParent?: boolean | ||
endsWithParent?: boolean | ||
endSameAsBegin?: boolean | ||
skip?: boolean | ||
excludeBegin?: boolean | ||
excludeEnd?: boolean | ||
returnBegin?: boolean | ||
returnEnd?: boolean | ||
__beforeBegin?: Function | ||
parent?: Mode | ||
starts?:Mode | ||
lexemes?: string | RegExp | ||
keywords?: Record<string, any> | string | ||
beginKeywords?: string | ||
relevance?: number | ||
illegal?: string | RegExp | ||
variants?: Mode[] | ||
cached_variants?: Mode[] | ||
// parsed | ||
subLanguage?: string | string[] | ||
compiled?: boolean | ||
} | ||
export = hljs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import './types'; | ||
|
||
declare const basic: LanguageFn; | ||
|
||
export = basic; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 180+ languages... this is why I'm not a fan of the individual file approach here.