/**
*/
class type_output_html implements type_output
{
public readonly kind : string = "html";
public readonly data : {};
public constructor(data : {}) {this.data = data;}
/**
*/
private render_object_internal(
object : type_object,
options : {
level ?: int;
depth ?: int;
} = {}
) : lib_plankton.xml.class_node
{
options = Object.assign(
{
"level": 0,
"depth": 0,
},
options
);
return lib_plankton.call.distinguish(
object,
{
"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_object_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_object_internal(
content,
{
"level": (options.level + 1),
"depth": (options.depth + 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_object_internal(
item,
{
"level": options.level,
"depth": (options.depth + 1),
}
),
]
)
)
),
),
},
{
"fallback": (object) => new lib_plankton.xml.class_node_complex(
"pre",
{
"class": "sd-unhandled",
"rel": object.kind,
},
[
new lib_plankton.xml.class_node_text(
JSON.stringify(object, undefined, " "),
)
]
),
}
);
}
/**
* @implementation
*/
public render_object(
object : type_object
) : string
{
return this.render_object_internal(object).compile();
}
/**
* @implementation
*/
public render_document(
document : type_document
) : string
{
return lib_plankton.string.coin(
"\n{{html}}",
{
"html": new lib_plankton.xml.class_node_complex(
"html",
{},
[
new lib_plankton.xml.class_node_complex(
"head",
{
},
[
new lib_plankton.xml.class_node_complex(
"meta",
{
"charset": "utf-8",
},
[
]
),
new lib_plankton.xml.class_node_complex(
"title",
{
},
[
new lib_plankton.xml.class_node_text(
document.content_title
),
]
),
]
),
new lib_plankton.xml.class_node_complex(
"body",
{
},
[
this.render_object_internal(
document.content_main,
{
"depth": 1,
}
),
]
)
]
).compile()
}
);
}
}
/**
*/
output_kind_register(
"html",
(data, sub) => (
new type_output_html(
{
}
)
)
);