Welcome! » Log In » Create A New Profile

Single line break

Posted by Pablo 
Pablo
Single line break
June 09, 2012 02:32PM

Hello, html purifier does a great job with the auto paragraph function, however this function only works for double new lines ("\n\n").

When you input something like this:

this is a new: \n
line

it outputs this:

this is a new line

I've tried modifying the injector file for this function and replace the content of the text applying the nl2br() php function to it, but the output of the text comes out html encoded (special characters)

any advise on this ?

cheers

Re: Single line break
June 09, 2012 04:30PM

I think the AutoParagrapher searchers for double newlines, so if you replace the search with a newline it should do it. I suspect, however, that this may not quite be the effect you are going for.

nl2br the entire HTML before purifying is another option.

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: