Loading src/html.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -593,10 +593,26 @@ void libhtmlpp::HtmlString::_buildTree() { const char* p = base; while (p < end) { const char* wsStart = p; while (p < end && is_ws(static_cast<unsigned char>(*p))) ++p; if (p >= end) break; if (*p == HTMLTAG_OPEN) { // '<' // A whitespace-only run directly between two tags (e.g. // "</span> <a>", "</a> <a>") still separates whatever inline // content sits on either side of it -- collapse it to a single // space instead of silently discarding it, or adjacent inline // elements lose the space that keeps their rendered text apart. // Leading whitespace before the very first tag in the document // is not meaningful the same way, so it's still dropped. if (p > wsStart && firstEl) { add_element_node(&lastEl); auto ws = std::make_unique<TextElement>(); static_cast<TextElement*>(ws.get())->_Text.push_back(' '); lastEl->element = std::move(ws); lastEl->terminator = false; } const char* const remain_end = end; const size_t remain = static_cast<size_t>(remain_end - p); Loading Loading
src/html.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -593,10 +593,26 @@ void libhtmlpp::HtmlString::_buildTree() { const char* p = base; while (p < end) { const char* wsStart = p; while (p < end && is_ws(static_cast<unsigned char>(*p))) ++p; if (p >= end) break; if (*p == HTMLTAG_OPEN) { // '<' // A whitespace-only run directly between two tags (e.g. // "</span> <a>", "</a> <a>") still separates whatever inline // content sits on either side of it -- collapse it to a single // space instead of silently discarding it, or adjacent inline // elements lose the space that keeps their rendered text apart. // Leading whitespace before the very first tag in the document // is not meaningful the same way, so it's still dropped. if (p > wsStart && firstEl) { add_element_node(&lastEl); auto ws = std::make_unique<TextElement>(); static_cast<TextElement*>(ws.get())->_Text.push_back(' '); lastEl->element = std::move(ws); lastEl->terminator = false; } const char* const remain_end = end; const size_t remain = static_cast<size_t>(remain_end - p); Loading