From 65dd704aff64854a50f6efd8116f103eac5807af Mon Sep 17 00:00:00 2001 From: speedie Date: Fri, 17 May 2024 13:52:16 +0200 Subject: [PATCH] Implement ELEMENT_EMPTY_NO_FORMAT, which is an empty tag without formatting. --- include/docpp.hpp | 1 + src/docpp.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/docpp.hpp b/include/docpp.hpp index 41591f2..780a73c 100644 --- a/include/docpp.hpp +++ b/include/docpp.hpp @@ -55,6 +55,7 @@ namespace docpp { */ enum Tag { ELEMENT_EMPTY, + ELEMENT_EMPTY_NO_FORMAT, ELEMENT_ABBREVIATION, ELEMENT_ABBR, ELEMENT_ACRONYM, diff --git a/src/docpp.cpp b/src/docpp.cpp index 12c0b3a..4edcde3 100644 --- a/src/docpp.cpp +++ b/src/docpp.cpp @@ -247,6 +247,7 @@ void docpp::HTML::Section::set(const std::string& tag, const Properties& propert std::pair docpp::HTML::resolve_tag(const Tag tag) { const std::unordered_map> tag_map{ {ELEMENT_EMPTY, {"", docpp::HTML::TYPE_TEXT_TAB}}, + {ELEMENT_EMPTY_NO_FORMAT, {"", docpp::HTML::TYPE_TEXT}}, {ELEMENT_ABBREVIATION, {"abbr", docpp::HTML::TYPE_NON_SELF_CLOSING}}, {ELEMENT_ABBR, {"abbr", docpp::HTML::TYPE_NON_SELF_CLOSING}}, {ELEMENT_ACRONYM, {"acronym", docpp::HTML::TYPE_NON_SELF_CLOSING}}, @@ -855,6 +856,12 @@ std::string docpp::CSS::Element::get(const Formatting formatting, const int tabc std::string ret{}; if (this->element.first.compare("")) { + if (formatting == docpp::CSS::FORMATTING_PRETTY) { + for (size_type i{0}; i < tabc; i++) { + ret += "\t"; + } + } + ret += this->element.first + " {"; if (formatting == docpp::CSS::FORMATTING_PRETTY || formatting == docpp::CSS::FORMATTING_NEWLINE) { @@ -878,6 +885,12 @@ std::string docpp::CSS::Element::get(const Formatting formatting, const int tabc } } + if (formatting == docpp::CSS::FORMATTING_PRETTY) { + for (size_type i{0}; i < tabc; i++) { + ret += "\t"; + } + } + ret += "}"; if (formatting == docpp::CSS::FORMATTING_PRETTY || formatting == docpp::CSS::FORMATTING_NEWLINE) {