Welcome! » Log In » Create A New Profile

ExtractStyleBlocks doesn't work

Posted by hamdip 
ExtractStyleBlocks doesn't work
May 28, 2018 09:44AM

Hello,

First of all thank you for the tool. Really impressive and complete ;)

My concerne is about extracting or allowing style tags. If I use a standard initialisation (from documentaion) it doesn't work as it is depricated. I searched all over the forum and web and didn't find any solutions.

Here is my example code :


  require_once('HTMLPurifier/HTMLPurifier.auto.php');

  $conf = HTMLPurifier_Config::createDefault();
  $conf->set('Filter.ExtractStyleBlocks', true);  
  
  $purifier = new HTMLPurifier($conf);  
  
  $styles = $purifier->context->get('StyleBlocks');
  echo $styles; 

I get teh error Uncaught Error: Call to a member function get() on null The context has no results and is empty therefor a get() method doesn't apply on it.

Do you have any idea why it doesn't work ?

Re: ExtractStyleBlocks doesn't work
June 09, 2018 10:37PM

You've got to purify first before you can access the context parameter. Otherwise there's nothing that you have extracted.

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: