I deal with this :
function echapcode($a) {
return "<pre $a[1]>".htmlspecialchars($a[2])."</pre>";
}
$texte = preg_replace_callback('#<pre (.*?)>(.*?)</pre>#ius', 'echapcode', $text);
add_filter('the_content','new_pre_content');
function new_pre_content($content){
if ( function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() ) {
$content = preg_replace_callback('#<pre (.*?)>(.*?)</pre>#ius', 'echapcode', $content);
}
return $content;
}
-
This reply was modified 8 years, 5 months ago by
jaiunblog.
Strange I think this post was named “pre with html code show the html result”.
Hi @jaiunblog
Can you tell me what the problem and what exactly that you are trying to achieve?
The pre tag is not “don’t apply” the code without my trick. So I need to htmlspecialchars before output the code in pre.
-
This reply was modified 8 years, 5 months ago by
jaiunblog.
-
This reply was modified 8 years, 5 months ago by
jaiunblog.