diff --git a/include/docpp.hpp b/include/docpp.hpp
index 5b34d53..71a513d 100644
--- a/include/docpp.hpp
+++ b/include/docpp.hpp
@@ -205,9 +205,10 @@ namespace docpp {
* @brief Enum for element types.
*/
enum class Type {
- Self_Closing, /* Self-closing element ()*/
- Non_Self_Closing, /* Non-self-closing element () */
+ Self_Closing, /* Self-closing element ()*/
+ Non_Self_Closing, /* Non-self-closing element () */
Non_Closed, /* Non-closed element () */
+ Non_Opened, /* Non-opened element () */
Text_No_Formatting, /* Text element with no formatting (my text here). */
Text, /* Text element with tab characters appropriately prepended (my text here). Note that this does *not* append a newline character. */
};
diff --git a/src/docpp.cpp b/src/docpp.cpp
index 5603531..1ed5c9c 100644
--- a/src/docpp.cpp
+++ b/src/docpp.cpp
@@ -295,7 +295,11 @@ std::string docpp::HTML::Element::get(const Formatting formatting, const int tab
}
}
- ret += "<" + this->tag;
+ if (this->type == docpp::HTML::Type::Non_Opened) {
+ ret += "" + this->tag;
+ } else {
+ ret += "<" + this->tag;
+ }
for (const Property& it : this->properties.get_properties()) {
if (!it.get_key().compare("")) continue;
@@ -304,7 +308,7 @@ std::string docpp::HTML::Element::get(const Formatting formatting, const int tab
ret += " " + it.get_key() + "=\"" + it.get_value() + "\"";
}
- if (this->type != docpp::HTML::Type::Self_Closing) {
+ if (this->type != docpp::HTML::Type::Self_Closing && this->type != docpp::HTML::Type::Non_Opened) {
ret += ">";
}
@@ -312,6 +316,8 @@ std::string docpp::HTML::Element::get(const Formatting formatting, const int tab
ret += this->data + "" + this->tag + ">";
} else if (this->type == docpp::HTML::Type::Self_Closing) {
ret += this->data + "/>";
+ } else if (this->type == docpp::HTML::Type::Non_Opened) {
+ ret += ">";
}
if (formatting == docpp::HTML::Formatting::Pretty || formatting == docpp::HTML::Formatting::Newline) {
diff --git a/tests/test.cpp b/tests/test.cpp
index 9bdcb2f..5cf34bd 100644
--- a/tests/test.cpp
+++ b/tests/test.cpp
@@ -634,6 +634,9 @@ inline namespace HTML {
REQUIRE(element.get(docpp::HTML::Formatting::None) == "data
");
REQUIRE(element.get(docpp::HTML::Formatting::Pretty) == "data
\n");
REQUIRE(element.get(docpp::HTML::Formatting::Newline) == "data
\n");
+
+ element.set_type(docpp::HTML::Type::Non_Opened);
+ REQUIRE(element.get() == "");
};
test_get_and_set();