@$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
+ $html = $dom->getElementsByTagName('html');
+
$head = $dom->getElementsByTagName('head');
+ if(!$head->length){
+ $head = $dom->createElement('head');
+ $html->item(0)->appendChild($head);
+ }
+
$s = $dom->createElement('style');
$e = $dom->createTextNode($this->css_inline);
$s->appendChild($e);
- $head->appendChild($s);
+ $body->item(0)->appendChild($s);
return $dom->saveHTML();
}