1

Topic: Preserve html head

hi,

First, fantastic work !
I know that htmlawed is designed to handel body contents of html files only. Is there any chance to preserve extra body contents (doctype declaration and all contents in head)?
I'm using the rewriting utility to prepare an html file (convert relative urls to absolute. and for removring all javascript and object tags) before passing my html to a custom application.

I've tried to set parent directive 'html' with no effect.

ps : to make oo version more pretty i suggest :

1) replace htmLawed::* calls by self::*
1) replace $GLOBALS variable  usage by a static class attributes

Thanks

2

Re: Preserve html head

You are right that htmLawed doesn't handle non-'body' HTML. There is no way to force it to do so.

The only suggestion I have, something you may have considered, is to run htmLawed on only the 'body' portion of the HTML.

// htmLawed config.
$config = array(...);
// htmLawed filter only the 'body'
preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $in, $matches);
$out = $matches[1]. htmLawed($matches[2], $config). $matches[3];

Thank you for the suggestions re: the OOP code. I'll look into them.