• Resolved jaiunblog

    (@jaiunblog)


    Hi,

    I’m using code on my blog.
    <div>learn to code</div>

    Without Amp I get <div>learn to code</div>
    With Amp I get “learn to code” ??

    How to fix ?

    • This topic was modified 7 years, 1 month ago by jaiunblog.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter jaiunblog

    (@jaiunblog)

    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 7 years, 1 month ago by jaiunblog.
    Thread Starter jaiunblog

    (@jaiunblog)

    Strange I think this post was named “pre with html code show the html result”.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Hi @jaiunblog

    Can you tell me what the problem and what exactly that you are trying to achieve?

    Thread Starter jaiunblog

    (@jaiunblog)

    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 7 years ago by jaiunblog.
    • This reply was modified 7 years ago by jaiunblog.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘with html code show the html result’ is closed to new replies.