@cisstech/nge
Version:
NG Essentials is a collection of libraries for Angular developers.
94 lines (93 loc) • 2.83 kB
TypeScript
import { Injector, InjectionToken, Provider, Type } from '@angular/core';
import { NgeMarkdownTransformer } from '../nge-markdown-transformer';
import { NgeMarkdownContribution } from '../nge-markdown-contribution';
import * as i0 from "@angular/core";
/**
* Highlight options.
*/
export interface NgeMarkdownHighlightOptions {
/** <code></code> element to colorize. */
element: HTMLElement;
/** Target language (default plaintext) */
language?: string;
/**
* Start line number or a space separated list of line numbers to show.
*
* Example:
*
* *Show all line numbers starting 1*
*
* `"1"`
*
* *Show all line numbers from 1 to 4*
*
* `"1-4"`
*
* *Show lines 2 4 5 6 7 9*
*
* `"2 4-7 9"`
*
*/
lines?: string;
/**
* A space separated list of line numbers to highlight.
*
* Example:
*
* *Highlight line 1*
*
* `"1"`
*
* *Highlight all lines from 1 to 4*
*
* `"1-4"`
*
* *Highlightw lines 2 4 5 6 7 9*
*
* `"2 4-7 9"`
*/
highlights?: string;
/** Filename to display */
filename?: string;
}
/**
* Highlighter service representation.
*/
export interface NgeMarkdownHighlighterService {
/**
* Function called to hightlight an HTMLElement code.
* @param injector Injector reference to use Angular dependency injection.
* @param options Highlight options.
*/
highligtht?(injector: Injector, options: NgeMarkdownHighlightOptions): void | Promise<void>;
}
/**
* Injection token to register a highlighter service.
*/
export declare const NGE_MARKDOWN_HIGHLIGHTER_SERVICE: InjectionToken<NgeMarkdownHighlighterService>;
/**
* Contribution to add an abstract syntax highlighter.
*/
export declare class NgeMarkdownHighlighter implements NgeMarkdownContribution {
private readonly injector;
private readonly options;
constructor(injector: Injector, options: NgeMarkdownHighlighterService);
contribute(transformer: NgeMarkdownTransformer): void;
private createAttributes;
private colorizeCodes;
private escapeHtml;
static ɵfac: i0.ɵɵFactoryDeclaration<NgeMarkdownHighlighter, [null, { optional: true; }]>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgeMarkdownHighlighter>;
}
/**
* Injection token to register `NgeMarkdownHighlighter` contribution.
*/
export declare const NgeMarkdownHighlighterProvider: Provider;
/**
* Provider to register `NgeMonacoColorizerService` as the syntax highlighter.
* @param type A reference to NgeMonacoColorizerService type.
*/
export declare function NgeMarkdownHighlighterMonacoProvider(type: Type<any>): {
provide: InjectionToken<NgeMarkdownHighlighterService>;
useValue: NgeMarkdownHighlighterService;
};