[Tablegen] Add function to generate the table as node child

This commit is contained in:
TennesseeTrash 2025-06-14 20:33:49 +02:00
parent 9fad3c41b2
commit e787b94ae1
2 changed files with 11 additions and 5 deletions

View file

@ -16,6 +16,8 @@ namespace Tablegen
void GeneratePage(const std::string& path, const Settings& settings = Settings::Default()); void GeneratePage(const std::string& path, const Settings& settings = Settings::Default());
# ifdef TABLEGEN_EXPOSE_XML # ifdef TABLEGEN_EXPOSE_XML
void GenerateAsChild(pugi::xml_node& node, const Settings& settings = Settings::Default());
pugi::xml_document GenerateDocument(const Settings& settings = Settings::Default()); pugi::xml_document GenerateDocument(const Settings& settings = Settings::Default());
# endif # endif
} }

View file

@ -115,15 +115,14 @@ namespace Tablegen
doc.save_file("test.html", " ", formatOptions); doc.save_file("test.html", " ", formatOptions);
} }
pugi::xml_document GenerateDocument(const Settings& settings) void GenerateAsChild(pugi::xml_node& node, const Settings& settings)
{ {
pugi::xml_document doc; pugi::xml_node tableRoot = node;
pugi::xml_node tableRoot = doc;
if (settings.FullDocument == Flag::Enable) { if (settings.FullDocument == Flag::Enable) {
doc.append_child(pugi::node_doctype).set_value("html"); node.append_child(pugi::node_doctype).set_value("html");
pugi::xml_node html = doc.append_child("html"); pugi::xml_node html = node.append_child("html");
pugi::xml_node head = html.append_child("head");\ pugi::xml_node head = html.append_child("head");\
head.append_child("title").append_child(pugi::node_pcdata).set_value("Kanji Table"); head.append_child("title").append_child(pugi::node_pcdata).set_value("Kanji Table");
@ -200,7 +199,12 @@ namespace Tablegen
styles.append_child(pugi::node_pcdata).set_value(Styles(settings, indent, tagIndent, styles.append_child(pugi::node_pcdata).set_value(Styles(settings, indent, tagIndent,
staticImg, animatedImg)); staticImg, animatedImg));
script.append_child(pugi::node_pcdata).set_value(Script(indent, tagIndent, buttons)); script.append_child(pugi::node_pcdata).set_value(Script(indent, tagIndent, buttons));
}
pugi::xml_document GenerateDocument(const Settings& settings)
{
pugi::xml_document doc;
GenerateAsChild(doc);
return doc; return doc;
} }
} }