ngx-highlightjs
Version:
Instant code highlighting, auto-detect language, super easy to use.
73 lines (72 loc) • 3.16 kB
TypeScript
import { Signal } from '@angular/core';
import type { HLJSApi, LanguageFn, HLJSOptions, HighlightResult, HighlightOptions, AutoHighlightResult } from 'highlight.js';
import { LineNumbersOptions } from './highlight.model';
import * as i0 from "@angular/core";
export declare class HighlightJS {
private readonly loader;
private readonly options;
private readonly hljsSignal;
readonly hljs: Signal<HLJSApi>;
constructor();
/**
* Core highlighting function. Accepts the code to highlight (string) and a list of options (object)
*/
highlight(code: string, options: HighlightOptions): Promise<HighlightResult>;
/**
* Highlighting with language detection.
*/
highlightAuto(value: string, languageSubset: string[]): Promise<AutoHighlightResult>;
/**
* 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.
*/
highlightElement(element: HTMLElement): Promise<void>;
/**
* 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(): Promise<void>;
/**
* @deprecated in version 12
* Configures global options:
*/
configure(config: Partial<HLJSOptions>): Promise<void>;
/**
* Adds new language to the library under the specified name. Used mostly internally.
* The function is passed the hljs object to be able to use common regular expressions defined within it.
*/
registerLanguage(languageName: string, languageDefinition: LanguageFn): Promise<void>;
/**
* Removes a language and its aliases from the library. Used mostly internally
*/
unregisterLanguage(languageName: string): Promise<void>;
/**
* Adds new language alias or aliases to the library for the specified language name defined under languageName key.
*/
registerAliases(alias: string | string[], { languageName }: {
languageName: string;
}): Promise<void>;
/**
* @return The languages names list.
*/
listLanguages(): Promise<string[]>;
/**
* Looks up a language by name or alias.
*/
getLanguage(name: string): Promise<any>;
/**
* Enables safe mode. This is the default mode, providing the most reliable experience for production usage.
*/
safeMode(): Promise<void>;
/**
* Enables debug/development mode.
*/
debugMode(): Promise<void>;
/**
* Display line numbers
*/
lineNumbersBlock(el: HTMLElement, options: LineNumbersOptions): Promise<void>;
static ɵfac: i0.ɵɵFactoryDeclaration<HighlightJS, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<HighlightJS>;
}