Commit b5ffb36c authored by jan.koester's avatar jan.koester
Browse files

test

parent 4027f72d
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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);