Groovy (or Java): How to escape double quotes only within HTML inner text, not in attributes

I am using a HTML rendering engine based on Groovy within a WCM system.
I now have the use case, that the user enters rich text content within a TinyMCE-based form, which looks like this:

<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
    <span style="text-decoration: underline;"
        sed diam nonumy
    </span> eirmod "tempor" invidunt ut labore et...
</p>

Within my Groovy renderer, I now want to feed this HTML snippet into the HTML document’s content to client-side JavaScript processing.

What I need to do is:
Escape double quotes WITHIN content (see “tempor” token above), but not those encapsulating HTML attribute values (see “text-decoration” attribute above).

If I do

myHTML.replace(""", "&quot;")

I will in fact escape EVERY double quote.

Any suggestions how I can only escape the quotes WITHIN the real text?