What is the easiest way to apply highlighting to some text, excluding text in OCCASIONAL tags "<...>"?
CLARIFICATION . I want existing tags to be SAVED!
$t =
preg_replace(
"/(markdown)/",
"<strong>$1</strong>",
"This is essentially plain text apart from a few html tags generated with some
simplified markdown rules: <a href=markdown.html>[see here]</a>");
What should be displayed as:
"This is essentially plain text, except for a few html tags generated with some simplified markdown rules : see here "
... BUT DO NOT COMMUNICATE the text inside the anchor tag (i.e. <a href=markdown.html>).
I have heard the arguments of not parsing html with regular expressions, but here we are talking about plain text, with the exception of minimal parsing of some markup code.