Welcome! » Log In » Create A New Profile

Filter code out of <pre>

Posted by butterbrei 
Filter code out of <pre>
February 27, 2011 01:11PM

Hi,

I was looking for a way to filter code from a

-object to pass it to another library for syntax-highlighting.

Thanks for any help :)
Re: Filter code out of <pre>
March 07, 2011 01:34PM

Hmm, that's a little tricky, because you ostensibly want the unescaped code, and the syntax highlighter will generate its own HTML which you'll want to paste in. Maybe make an injector that inserts placeholders, and then substitute in the highlighted text after HTML Purifier is done?

Re: Filter code out of <pre>
March 07, 2011 05:13PM

Hi,

well I did it a little different: I passed everything through the purifier and parsed all &lt;pre&gt;-tags and decoded the inner code for the other parser.

The output gets cached... so ... should be it.

Thanks :)

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with &lt; and &gt;.

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: