ngx-highlightjs
Version:
Instant code highlighting, auto-detect language, super easy to use.
91 lines (90 loc) • 4.64 kB
TypeScript
import { Observable } from 'rxjs';
import { HighlightConfig, HighlightResult, HighlightLibrary, HighlightOptions, HighlightAutoResult } from './highlight.model';
import { HighlightLoader } from './highlight.loader';
import * as i0 from "@angular/core";
export declare class HighlightJS {
private _loader;
private _hljs;
get hljs(): HighlightLibrary | null;
constructor(_loader: HighlightLoader, options: HighlightOptions);
/**
* Core highlighting function. Accepts the code to highlight (string) and a list of options (object)
* @param code Accepts the code to highlight
* @param language must be present and specify the language name or alias of the grammar to be used for highlighting
* @param ignoreIllegals (optional) when set to true it forces highlighting to finish even in case of detecting illegal syntax for the language instead of throwing an exception.
*/
highlight(code: string, { language, ignoreIllegals }: {
language: string;
ignoreIllegals: boolean;
}): Observable<HighlightResult>;
/**
* Highlighting with language detection.
* @param value Accepts a string with the code to highlight
* @param languageSubset An optional array of language names and aliases restricting detection to only those languages.
* The subset can also be set with configure, but the local parameter overrides the option if set.
*/
highlightAuto(value: string, languageSubset: string[]): Observable<HighlightAutoResult>;
/**
* Applies highlighting to a DOM node containing code.
* This function is the one to use to apply highlighting dynamically after page load or within initialization code of third-party JavaScript frameworks.
* The function uses language detection by default but you can specify the language in the class attribute of the DOM node. See the scopes reference for all available language names and scopes.
* @param element
*/
highlightElement(element: HTMLElement): Observable<any>;
/**
* Applies highlighting to all elements on a page matching the configured cssSelector. The default cssSelector value is 'pre code',
* which highlights all code blocks. This can be called before or after the page’s onload event has fired.
*/
highlightAll(): Observable<any>;
/**
* @deprecated in version 12
* Configures global options:
* @param config HighlightJs configuration argument
*/
configure(config: HighlightConfig): Observable<void>;
/**
* Adds new language to the library under the specified name. Used mostly internally.
* @param languageName A string with the name of the language being registered
* @param languageDefinition A function that returns an object which represents the language definition.
* The function is passed the hljs object to be able to use common regular expressions defined within it.
*/
registerLanguage(languageName: string, languageDefinition: () => any): Observable<HighlightLibrary>;
/**
* Removes a language and its aliases from the library. Used mostly internall
* @param languageName: a string with the name of the language being removed.
*/
unregisterLanguage(languageName: string): Observable<any>;
/**
* Adds new language alias or aliases to the library for the specified language name defined under languageName key.
* @param alias: A string or array with the name of alias being registered
* @param languageName: the language name as specified by registerLanguage.
*/
registerAliases(alias: string | string[], { languageName }: {
languageName: string;
}): Observable<any>;
/**
* @return The languages names list.
*/
listLanguages(): Observable<string[] | undefined>;
/**
* Looks up a language by name or alias.
* @param name Language name
* @return The language object if found, undefined otherwise.
*/
getLanguage(name: string): Observable<any>;
/**
* Enables safe mode. This is the default mode, providing the most reliable experience for production usage.
*/
safeMode(): Observable<any>;
/**
* Enables debug/development mode.
*/
debugMode(): Observable<any>;
/**
* Display line numbers
* @param el Code element
*/
lineNumbersBlock(el: HTMLElement): Observable<any>;
static ɵfac: i0.ɵɵFactoryDeclaration<HighlightJS, [null, { optional: true; }]>;
static ɵprov: i0.ɵɵInjectableDeclaration<HighlightJS>;
}