Display HTML code in a Drupal field as plain text I am using Drupal as a blog for posts about programming. Naturally, I have to post code samples.

When I post the code samples, Drupal renders them as actual HTML. How can I stop this from happening? 

Example,

&lt;h1 style="font-style: italic; font-variant: small-caps; font-weight: normal; font-size: 13px; line-height: 150%; font-family:Arial, Helvetica, sans-serif; color: #000;"&gt;Thank You&lt;/h1&gt;


^ This gets displayed as the words "Thank You" with the listed formatting in the inline style. 

 &lt;!--[if gte mso 9]&gt;
    &lt;style type="text/css"&gt;
   .contact {
display:none;
}
    &lt;/style&gt;
&lt;![endif]--&gt;


^ This doesn't get displayed at all. 

Steps I have taken

I have created a new input format and turned off all the filters. 
I wrap the code in both &lt;code&gt; and &lt;pre&gt; tags.

I know Drupal has a filter called " Display any HTML as plain text". If I use this, then it works. But then all my formatting for the test of the post (e.g. paragraphs, links) get displayed as text making the post unreadable.
Looks like you're looking for Code Filter.


  This module provides a simple text format (input filter) that handles &lt;?php ?&gt; and &lt;code&gt;&lt;/code&gt; tags so that users can post code without having to worry about manually escaping &lt; and &gt; characters with &amp;lt; and &amp;gt;.


It is the module used on Drupal.org for escaping markup.