2024-02-08 10:41:17 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
class type_output_html implements type_output<string>
|
|
|
|
|
{
|
|
|
|
|
public readonly kind : string = "html";
|
|
|
|
|
public readonly data : {};
|
|
|
|
|
public constructor(data : {}) {this.data = data;}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2024-02-08 16:57:51 +01:00
|
|
|
private render_element_internal(
|
|
|
|
|
element : type_element,
|
|
|
|
|
options : {
|
|
|
|
|
depth ?: int;
|
|
|
|
|
level ?: int;
|
|
|
|
|
} = {}
|
|
|
|
|
) : lib_plankton.xml.class_node
|
2024-02-08 10:41:17 +01:00
|
|
|
{
|
2024-02-08 16:57:51 +01:00
|
|
|
options = Object.assign(
|
|
|
|
|
{
|
|
|
|
|
"depth": 0,
|
|
|
|
|
"level": 0,
|
|
|
|
|
},
|
|
|
|
|
options
|
|
|
|
|
);
|
|
|
|
|
return lib_plankton.call.distinguish<lib_plankton.xml.class_node>(
|
2024-02-08 10:41:17 +01:00
|
|
|
element,
|
|
|
|
|
{
|
2024-02-08 16:57:51 +01:00
|
|
|
"text": ({"content": content}) => new lib_plankton.xml.class_node_complex(
|
|
|
|
|
"span",
|
|
|
|
|
{
|
|
|
|
|
"class": "sd-text",
|
|
|
|
|
},
|
|
|
|
|
[
|
|
|
|
|
new lib_plankton.xml.class_node_text(content),
|
|
|
|
|
]
|
2024-02-08 10:41:17 +01:00
|
|
|
),
|
2024-02-08 16:57:51 +01:00
|
|
|
"group": ({"members": members}) => new lib_plankton.xml.class_node_complex(
|
|
|
|
|
"div",
|
|
|
|
|
{
|
|
|
|
|
"class": "sd-group",
|
|
|
|
|
},
|
2024-02-08 11:10:07 +01:00
|
|
|
(
|
2024-02-08 16:57:51 +01:00
|
|
|
members
|
|
|
|
|
.map(
|
|
|
|
|
x => this.render_element_internal(
|
|
|
|
|
x,
|
|
|
|
|
{
|
|
|
|
|
"depth": options.depth,
|
|
|
|
|
"level": options.level,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
)
|
2024-02-08 11:10:07 +01:00
|
|
|
)
|
|
|
|
|
),
|
2024-02-08 16:57:51 +01:00
|
|
|
"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),
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
2024-02-08 11:10:07 +01:00
|
|
|
),
|
2024-02-08 10:41:17 +01:00
|
|
|
},
|
|
|
|
|
{
|
2024-02-08 16:57:51 +01:00
|
|
|
"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, " "),
|
|
|
|
|
)
|
|
|
|
|
]
|
2024-02-08 10:41:17 +01:00
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-08 16:57:51 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @implementation
|
|
|
|
|
*/
|
|
|
|
|
public render_element(
|
|
|
|
|
element : type_element
|
|
|
|
|
) : string
|
|
|
|
|
{
|
|
|
|
|
return this.render_element_internal(element).compile();
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-08 10:41:17 +01:00
|
|
|
}
|
2024-02-08 11:10:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
output_kind_register(
|
|
|
|
|
"html",
|
|
|
|
|
(data, sub) => (
|
|
|
|
|
new type_output_html(
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|