ng-prism
Version:
An Angular2 codeblock highlighting component using Prismjs.
110 lines (109 loc) • 2.92 kB
TypeScript
import { Renderer } from '@angular/core';
import 'prismjs/components/prism-bash';
import 'prismjs/components/prism-powershell';
import 'prismjs/components/prism-javascript';
import 'prismjs/plugins/line-numbers/prism-line-numbers';
import 'prismjs/plugins/command-line/prism-command-line';
import 'prismjs/plugins/normalize-whitespace/prism-normalize-whitespace';
/**
* Code highlighting component
*
* Used internally by a codeblock to perform the actual highlighting.
*/
export declare class CodeRendererComponent {
/**
* The code to highlight
*/
code: string;
/**
* The language to use when highlighting the code.
*/
language: string;
/**
* Whether or not to display line numbers.
*/
lineNumbers: boolean;
/**
* Display a prompt in the codeblock. Set to 'bash' or 'powershell'.
*/
shell: string;
/**
* The prompt to use when displaying as a shell.
*/
prompt: string;
/**
* A comma separated list of lines or groups of lines to treat as output
* in a shell display.
*/
outputLines: string;
/**
* The template <pre> that will contain the code.
*/
_pre: any;
private _renderer;
constructor(_renderer: Renderer);
render(): void;
/**
* Clear the code.
*/
empty(): void;
/**
* Place the new code element in the template
*/
private _replaceCode();
/**
* Perform the actual highlighting
*/
private _highlight();
/**
* Code prepared for highlighting and display
*/
private readonly _processedCode;
/**
* Format markup for display.
*/
private _processMarkup(text);
/**
* Change all opening < changed to < to render markup correctly inside pre
* tags
*/
private _replaceTags(text);
/**
* Remove both template tags and styling attributes added by the angular2
* parser and fix indentation within code elements created by structural
* directives.
*/
private _removeAngularMarkup(html);
/**
* Is the language given a markup language?
*/
private _isMarkup(language);
/**
* Create a <code> element with the proper classes and formatted code
*/
private _buildCodeElement();
/**
* Styling classes
*/
readonly languageClass: string;
readonly lineNumbersClass: string;
readonly shellClass: string;
readonly codeClasses: string;
readonly preClasses: string;
/**
* The code element within <pre>
*/
private readonly _codeEl;
/**
* Adds back padding on output shells because of floated left prompt
*/
private _fixPromptOutputPadding();
/**
* Get the actually applied style of an element
*/
private _getStyle(oElm, strCssRule);
/**
* Remove extra indentation in ngSwitches
*/
private _fixIndentation(html);
}