Loading src/html.cpp +0 −60 Original line number Diff line number Diff line Loading @@ -232,66 +232,6 @@ libhtmlpp::Element &libhtmlpp::HtmlString::parse() { return *rootEl; } void printElement(libhtmlpp::Element* el, int depth, std::ostream& out) { if (!el) { return; } // 1. Print Indentation for (int i = 0; i < depth; ++i) { out << "| "; // Use a pipe and spaces for visual depth } // 2. Print Node Information if (el->isHtmlElement()) { libhtmlpp::HtmlElement* html_el = static_cast<libhtmlpp::HtmlElement*>(el); out << "├── <" << html_el->getTag() << ">"; // Print attributes (optional, but helpful for debugging) const auto& attrs = html_el->getAttributeList(); if (!attrs.empty()) { out << " [Attrs: " << attrs.size() << "]"; } out << std::endl; } else if (el->isTextElement()) { libhtmlpp::TextElement* text_el = static_cast<libhtmlpp::TextElement*>(el); // Print a snippet of text content, trimming whitespace std::string content = text_el->getContent(); // Remove leading/trailing whitespace for clean output size_t first = content.find_first_not_of(" \t\n\r"); size_t last = content.find_last_not_of(" \t\n\r"); if (first != std::string::npos) { content = content.substr(first, (last - first + 1)); } out << "├── #TEXT: \""; if (content.length() > 30) { out << content.substr(0, 27) << "...\""; } else if (!content.empty()) { out << content << "\""; } else { out << "(whitespace only)\""; } out << std::endl; } else { out << "├── Unknown Element Type" << std::endl; } // 3. Recursive Traversal // A. Recurse into the first child if (el->_childElement) { printElement(el->_childElement.get(), depth + 1, out); } // B. Move to the next sibling if (el->_nextElement) { printElement(el->_nextElement.get(), depth, out); } } void libhtmlpp::HtmlString::_buildtreenode(std::unique_ptr<libhtmlpp::DocElements> &firstel,libhtmlpp::DocElements *lastel){ if(!firstel || !lastel){ Loading Loading
src/html.cpp +0 −60 Original line number Diff line number Diff line Loading @@ -232,66 +232,6 @@ libhtmlpp::Element &libhtmlpp::HtmlString::parse() { return *rootEl; } void printElement(libhtmlpp::Element* el, int depth, std::ostream& out) { if (!el) { return; } // 1. Print Indentation for (int i = 0; i < depth; ++i) { out << "| "; // Use a pipe and spaces for visual depth } // 2. Print Node Information if (el->isHtmlElement()) { libhtmlpp::HtmlElement* html_el = static_cast<libhtmlpp::HtmlElement*>(el); out << "├── <" << html_el->getTag() << ">"; // Print attributes (optional, but helpful for debugging) const auto& attrs = html_el->getAttributeList(); if (!attrs.empty()) { out << " [Attrs: " << attrs.size() << "]"; } out << std::endl; } else if (el->isTextElement()) { libhtmlpp::TextElement* text_el = static_cast<libhtmlpp::TextElement*>(el); // Print a snippet of text content, trimming whitespace std::string content = text_el->getContent(); // Remove leading/trailing whitespace for clean output size_t first = content.find_first_not_of(" \t\n\r"); size_t last = content.find_last_not_of(" \t\n\r"); if (first != std::string::npos) { content = content.substr(first, (last - first + 1)); } out << "├── #TEXT: \""; if (content.length() > 30) { out << content.substr(0, 27) << "...\""; } else if (!content.empty()) { out << content << "\""; } else { out << "(whitespace only)\""; } out << std::endl; } else { out << "├── Unknown Element Type" << std::endl; } // 3. Recursive Traversal // A. Recurse into the first child if (el->_childElement) { printElement(el->_childElement.get(), depth + 1, out); } // B. Move to the next sibling if (el->_nextElement) { printElement(el->_nextElement.get(), depth, out); } } void libhtmlpp::HtmlString::_buildtreenode(std::unique_ptr<libhtmlpp::DocElements> &firstel,libhtmlpp::DocElements *lastel){ if(!firstel || !lastel){ Loading