I have some set of possible tags for example "<main>", "<text>", "<tag>". Rest of characters I would like to treat with htmlentities (htmlspecialchars)
<main>
<text>
<tag> <> X&Y < <falsetag> <tag attr="123" /> </tag>
</text>
</main>
The result should be
<main>
<text>
<tag> <> X&Y < <falsetag> <tag attr="123" /> </tag>
</text>
</main>
What’s the best way to do it.
You can run htmlentities on the text then use a regular expression to replace the allowed tags
<>Example…