I am curious how SO goes about removing HTML tags from posts. I just started using their MarkdownSharp project. By default MarkdownSharp encodes any HTML within code blocks like this:
<span style="color: red;">I am HTML</span>
But if I do the same thing outside of a code block it simply doesn't show up at all:
I am HTML <- tags are removed.
But they have whitelisted certain tags for basic markup, like the header tags:
I can also type HTML entities like
> doesn't get re-encoded, it will actually show up as a >
I'm sure the tags that get removed are being removed BEFORE the content is passed to markdown, as markdown generated HTML tags would likely be removed if this tag removal code was run after markdown handled it.
Does anyone know how SO accomplishes this, and if it is code that is available to use? Alternatives are acceptable also. I'm hoping to find something in C# as my project is C# ASP.NET MVC 3.
Thanks in advance!