JSFiddle - React, Tailwind, and code Playground
HTML
<div class="parseBlock">
<div>
<h1>Слово1 слово6 слово45<h1>
<p>Слово2</p>
<button>Слово3 Слово4</button>
</div>
</div>
CSS
.parseBlock span{
background-color: rgba(0,255,0,.2);
}
JavaScript
jQuery.fn.justtext = function() {
return $(this).clone().children().remove().end().text();
};
$('.parseBlock *').each(function(){
if($(this).justtext().trim() != ''){
$(this).html($(this).justtext().replace(/([а-яА-ЯёЁa-zA-Z0-9]\S+)/g, '<span>$1</span>'));
}
});