简体   繁体   中英

How do I prevent code written in my <pre> from rendering?

So I am using the google code prettifier: http://code.google.com/p/google-code-prettify/

It does something similar to what stack overflow does here where when you write a block of code it beautifies it and adds syntax highlighting.

The problem I am haveing is if I write code like this

 <pre class="prettyprint">
   <div class="specialForm">
   ...
 </div>
 </pre>

instead of rendering the text just as stack overflow does, it actually renders the DIV on the page and I have no clue what I am doing wrong

If you look at the source here in stackoverflow, your post is actually:

&lt;pre class="prettyprint"&gt;
   &lt;div class="specialForm"&gt;
   ...
 &lt;/div&gt;
 &lt;/pre&gt;

This prevents the browser from treating them as html syntax and it prints literal < , > etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM