Welcome! » Log In » Create A New Profile

Allow ndash;

Posted by demandred 
Allow ndash;
December 20, 2007 03:21AM

Hello! Great software, really. Been using it for a couple of sites now.

To my question, how do I make the purifier allow – (ndash) character?

I use the following code:

public function purify($text)
    {
        $config = HTMLPurifier_Config::createDefault();
        
        $config->set('Core',  'EscapeInvalidTags', 'true');
        $config->set('Core',  'Encoding', 'ISO-8859-1');
    
        $purifier = new HTMLPurifier( $config ) ;
    
        $html = $text;
       
        $html = $purifier->purify($html) ;
     
        return $html;
    }
Re: Allow ndash;
December 20, 2007 05:18PM

Please see this article on UTF-8. Specifically, %Core.EscapeNonASCIICharacters is what you want.

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: