If you have a website that relies heavily on PRE tags, you know the
important of converting PRE tag content to their HTML entities. Doing
so prevents worlds of possible rendering issues. The following PHP
snippet HTML-Entitizes (?) any code within PRE tags:
function pre_entities($matches) {
return str_replace($matches[1],htmlentities($matches[1]),$matches[0]);
}$content = preg_replace_callback('/<pre.*?>(.*?)<\/pre>/imsu',pre_entities, $content);
I use this for just about every post I write. You could also stick
this in your CMS if you have clients that may have use for PRE tags.