posthtml-render
Version:
Renders PostHTML Tree to HTML/XML
76 lines (65 loc) • 1.49 kB
TypeScript
import { NodeText, NodeTag } from 'posthtml-parser';
enum closingSingleTagOptionEnum {
tag = 'tag',
slash = 'slash',
default = 'default',
closeAs = 'closeAs'
}
enum closingSingleTagTypeEnum {
tag = 'tag',
slash = 'slash',
default = 'default'
}
enum quoteStyleEnum {
Smart,
Single,
Double
}
type Options = {
/**
* Custom single tags (selfClosing).
*
* @default []
*/
singleTags?: Array<string | RegExp>;
/**
* Closing format for single tag.
*
* Formats:
*
* tag: `<br></br>`, slash: `<br />`, default: `<br>`
*
*/
closingSingleTag?: closingSingleTagOptionEnum;
/**
* If all attributes should be quoted.
* Otherwise attributes will be unquoted when allowed.
*
* @default true
*/
quoteAllAttributes?: boolean;
/**
* Replaces quotes in attribute values with `"e;`.
*
* @default true
*/
replaceQuote?: boolean;
/**
* Quote style
*
* 0 - Smart quotes
* <img src="https://example.com/example.png" onload='testFunc("test")'>
* 1 - Single quotes
* <img src='https://example.com/example.png' onload='testFunc("test")'>
* 2 - double quotes
* <img src="https://example.com/example.png" onload="testFunc("test")">
*
* @default 2
*/
quoteStyle?: quoteStyleEnum;
};
declare type Node = NodeText | NodeTag & {
closeAs?: closingSingleTagTypeEnum;
};
declare function render(tree?: Node | Node[], options?: Options): string;
export default render;