1

Topic: Allowing HTML, HEAD, DOCTYPE ...

I'm trying to use HtmLawed to tidy templates.
All the config I tried didn't allow HTML, HEAD elements and DOCTYPE.

I tried to allow them in the $config parameter, or in the $spec parameter.

Is there a way I could allow them ?

2

Re: Allowing HTML, HEAD, DOCTYPE ...

htmLawed cannot handle elements outside HTML body; it also does not recognize the deprecated noframes, frameset and frame elements.

If you have a complete HTML tree/document, then the best thing would be to feed just the content of the HTML body, perhaps using code like this:

// Identify head and body
preg_match('`(.+?)(<body[^>]*>)(.+?)</body>`i', $input, $m);

// Filter and output
$output = $m[1]. $m[2]. htmLawed($m[3], $config...). '</body></html>';

3

Re: Allowing HTML, HEAD, DOCTYPE ...

Thanks, I'll see what I can do with that.