Welcome! » Log In » Create A New Profile

simple usage, no documentations

Posted by wahyudinata 
wahyudinata
simple usage, no documentations
January 10, 2008 06:21AM

Hi all, This might sound ignorant but here it goes: My web app accepts the following: bla, bold, italics, strikethrough, underline

that's it, and of course it those can be nested. I have browsed htmlpurifier site, I cannot find any documentation to achieve this (or anything) for me to start at all?

Help me point to the right direction?

Re: simple usage, no documentations
January 10, 2008 01:15PM

You want to use the %HTML.Allowed setting.

wahyudinata
Re: simple usage, no documentations
January 10, 2008 05:11PM

Great! now...how do I use it? I read the doc i saw no usage or examples.

Re: simple usage, no documentations
January 10, 2008 05:25PM

The information on how to set configuration options is in the INSTALL documentation. Anyway, for what you describe, you want this:

$config = HTMLPurifier_Config::createDefault();
$config->set('HTML', 'Allowed', 'a[href],b,i,s,u,p');
$purifier = new HTMLPurifier($config);

I added the p tag in my own discretion; otherwise users can't make paragraphs!

This is all documented in the INSTALL document.

wahyudinata
Re: simple usage, no documentations
January 10, 2008 05:33PM

wow, All these times I've been searching for documentation in http://htmlpurifier.org/#Docs, but it is in INSTALL. And after scouring the forums it seems that I am the only one having trouble finding it?

But this is more than enough to get me started, thanks for the prompt response Ambush Commander, *salutes*

Re: simple usage, no documentations
January 10, 2008 05:34PM

Ah, that could certainly be a problem! I'll add a link to the INSTALL document on the webpage.

wahyudinata
Re: simple usage, no documentations
January 10, 2008 05:50PM

on a side note, the example above will create a fatal error, at least in my case. use $config = HTMLPurifier_Config::createDefault(); and it works like a charm!

thanks^^

Re: simple usage, no documentations
January 10, 2008 05:52PM

Code updated. My apologies.

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with < and >.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: