JSFiddle - React, Tailwind, and code Playground

HTML

<span class="marker-start"></span>
<div>
<span class="marker-end"></span>

    <div>This HTML here is excluded</div>
</div>
<span class="marker-start"></span>
    <div>This HTML is included</div>

<span class="marker-end"></span>

JavaScript

function walkDOM(node, func) {
    func(node);
    node = node.firstChild;
    while (node) {
        walkDOM(node, func);
        node = node.nextSibling;
    }
};

var inMarker = false;

walkDOM(document.body, function (node) {
    var $node = $(node);
    if ($node.is('span')) {
        if ($node.hasClass('marker-end')) {
            inMarker = false;
            console.log("end marker");
        } else if ($node.hasClass("marker-start")) {
            inMarker = true;
            console.log("start marker");
        }
    }
    if (node.nodeType == 3)
    {
        if (!inMarker)
        {
            node.textContent = "";
        }
    }
});