ly, and have everything "just work". Here are two changes that would get pretty close to ideal for comments on this site:

1. Any HTML that isn't one of the "allowed tags" gets escaped.

WordPress has this default set of allowed tags:

<a href="" title="">
//AN_Xml:<abbr title="">
//AN_Xml:<acronym title="">
//AN_Xml:<b>
//AN_Xml:<blockquote cite="">
//AN_Xml:<cite>
//AN_Xml:<code>
//AN_Xml:<del datetime="">
//AN_Xml:<em>
//AN_Xml:<i>
//AN_Xml:<q cite="">
//AN_Xml:<strike>
//AN_Xml:<strong>

If someone uses these tags in a comment, they will apply to that text and render appropriately. If they use any other tag, it should escape, not be stripped or inappropriately render. So:

I'd also say that if it's a single line of code as in this example (does not contain line breaks) it should wrap the newly escaped code in <code></code> tags.

Also, if the code is already escaped like &lt;span&gt; then leave it alone.

2. Make sure multi-line code is wrapped in <pre> tags

If someone puts out multiple lines of code (either they put it in <code> tags or it's not allowed tags so it auto-escapes and auto-code-wraps it), that multi-line code should be wrapped in <pre></pre> tags.

This should also strip whitespace from the beginning and end of the code block, so no extra spaces get rendered. This:

<pre><code>
//AN_Xml:<ul>
//AN_Xml:  <li>

Should turn into:

<pre><code><ul>
//AN_Xml:  </li><code></pre>

This would be whether the commenter uses the tags themselves or they are auto-generated based on the above rules.

CMS Agnostic

I'm specifically thinking of WordPress here because that's what I always use, but I can imagine this being useful in any commenting environment that allows some-but-not-all HTML tags and is reasonable that the discussion may involve nerds discussing HTML. Hey maybe this should be a WordPress plugin eh? WINK WINK.

How I Think Posting HTML In Comments Should Work is a post from CSS-Tricks

]]> http://css-tricks.com/13695-how-i-think-posting-html-in-comments-should-work/feed/ 37 //AN_Xml: