#include "structureNode.h" #include #include #include #include using std::string; string DocumentNode::ToHtml() const { std::stringstream ss; ss << "\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tDocument\n\t\t\n\t\n"; for (const auto &child : this->GetChilren()) { ss << *child; } ss << "\n\t\n"; return ss.str(); } HeadingNode::HeadingNode(int size) { if (1 <= size && size <= 6) { this->size = size; return; } throw std::runtime_error("HeadingNode.size must be between 1 and 6."); } string HeadingNode::ToHtml() const { std::stringstream ss; ss << ""; for (const auto &child : this->GetChilren()) { ss << *child; } ss << "\n"; return ss.str(); } string ParagraphNode::ToHtml() const { std::stringstream ss; ss << "

"; for (const auto &child : this->GetChilren()) { ss << *child; } ss << "

\n"; return ss.str(); } string ListNode::ToHtml() const { std::stringstream ss; ss << (this->ordered ? "
    " : "
      ") << "\n"; for (const auto &child : this->GetChilren()) { ss << *child; } ss << (this->ordered ? "
" : "") << "\n"; return ss.str(); } string ListElementNode::ToHtml() const { std::stringstream ss; ss << "
  • "; for (const auto &child : this->GetChilren()) { ss << *child; } ss << "
  • " << "\n"; return ss.str(); } string CodeBlockNode::ToHtml() const { std::stringstream ss; ss << "\n"; for (const auto &child : this->GetChilren()) { ss << *child << "\n"; } ss << "\n"; return ss.str(); } string ImageNode::ToHtml() const { std::stringstream ss; ss << "src << "\" alt=\"" << this->alt << "\" />\n"; return ss.str(); }