views:

904

answers:

8

I'm trying to write a blog post which includes a code segment inside a tag. The code segment includes a generic type and uses <> to define that type. This is what the segment looks like:

<pre>
    PrimeCalc calc = new PrimeCalc();
    Func<int, int> del = calc.GetNextPrime;
</pre>

The resulting HTML removes the <> and ends up like this:

PrimeCalc calc = new PrimeCalc();
Func del = calc.GetNextPrime;

How do I escape the <> so they show up in the HTML?

+4  A: 

Use HTML entities:

http://www.w3schools.com/tags/ref_entities.asp

rp
+1  A: 
OwenP
A: 

How about:

&lt; and &gt;

Hope this helps?

toolkit
A: 

&lt; and &gt; respectively

sundae1888
+1  A: 

Use &lt; and &gt; to do < and > inside html.

crashmstr
+1  A: 
Chris Marasti-Georg
+8  A: 
<pre>
    PrimeCalc calc = new PrimeCalc();
    Func&gt;int, int&lt; del = calc.GetNextPrime;
</pre>
John Sheehan
A: 

What rp said, just replace the greater-than(>) and less-than(<) symbols with their html entity equivalent. Here's an example:

<pre>
    PrimeCalc calc = new PrimeCalc();
    Func&lt;int, int&gt; del = calc.GetNextPrime;
</pre>

This should appear as (this time using exactly the same without the prepended spaces for markdown):

    PrimeCalc calc = new PrimeCalc();
    Func<int, int> del = calc.GetNextPrime;
akdom