Are there any code libraries that validate/convert blog comments to XHTML strict?

Posted by Matthew James Taylor on Stack Overflow See other posts from Stack Overflow or by Matthew James Taylor
Published on 2009-07-01T04:29:50Z Indexed on 2010/06/13 15:22 UTC
Read the original article Hit count: 468

Filed under:
|
|
|
|

I am working on a website in PHP where people can make comments similar to a blog, and I only want particular tags to be allowed. Are there any pre-built libraries that process comments and produce valid XHTML Strict code? I would need to do this in JavaScript so I can generate a live preview like Stack Overflow, plus in PHP before saving it to a MySQL database.

The allowed HTML tags will be: strong, em, blockquote, and links (rel=nofollow not required)

One way would be to allow people to directly enter the HTML into the comment field but I would prefer to use a simple mark up something like this (can be different - this is an example):

*strong*
_em_
[blockquote]
http://www.link.com

I want line breaks to be converted to <br />.

Are there any code libraries that do the above?

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript