/** */ class type_output_html implements type_output { public readonly kind : string = "html"; public readonly data : {}; public constructor(data : {}) {this.data = data;} /** */ private render_element_internal( element : type_element, options : { depth ?: int; level ?: int; } = {} ) : lib_plankton.xml.class_node { options = Object.assign( { "depth": 0, "level": 0, }, options ); return lib_plankton.call.distinguish( element, { "text": ({"content": content}) => new lib_plankton.xml.class_node_complex( "span", { "class": "sd-text", }, [ new lib_plankton.xml.class_node_text(content), ] ), "group": ({"members": members}) => new lib_plankton.xml.class_node_complex( "div", { "class": "sd-group", }, ( members .map( x => this.render_element_internal( x, { "depth": options.depth, "level": options.level, } ) ) ) ), "section": ({"title": title, "content": content}) => new lib_plankton.xml.class_node_complex( "section", { "class": "sd-section", }, [ new lib_plankton.xml.class_node_complex( ("h" + (options.level + 1).toFixed(0)), {}, [ new lib_plankton.xml.class_node_text(title), ] ), this.render_element_internal( content, { "depth": (options.depth + 1), "level": (options.level + 1), } ), ] ), "list": ({"items": items}) => new lib_plankton.xml.class_node_complex( "ul", { "class": "sd-list", }, ( items .map( item => new lib_plankton.xml.class_node_complex( "li", {}, [ this.render_element_internal( item, { "level": options.level, "depth": (options.depth + 1), } ), ] ) ) ), ), }, { "fallback": (element) => new lib_plankton.xml.class_node_complex( "pre", { "class": "sd-unhandled", "rel": element.kind, }, [ new lib_plankton.xml.class_node_text( JSON.stringify(element, undefined, " "), ) ] ), } ); } /** * @implementation */ public render_element( element : type_element ) : string { return this.render_element_internal(element).compile(); } } /** */ output_kind_register( "html", (data, sub) => ( new type_output_html( { } ) ) );