# HG changeset patch # User Tom Fredrik "BFG" Klaussen # Date 1459107188 -7200 # Node ID e01ce5722f2bc4dd7f6af35154fe5f86c0bd3f5c # Parent 374e3eff07fd2be9027bf1d3c74a734bb313cd83 New change to how we save (X)HTML files. This time we simplify things by using DocumentFragments to load stuff, and preserve CDATA content. diff -r 374e3eff07fd -r e01ce5722f2b InputParser.inc --- a/InputParser.inc Thu Mar 17 22:34:49 2016 +0100 +++ b/InputParser.inc Sun Mar 27 21:33:08 2016 +0200 @@ -93,7 +93,7 @@ { //We may need to set and check the contenttype and replace //saveHTML with saveXML - $retVal = new PageContent($this->master->saveHTML($this->master)); + $retVal = new PageContent($this->master->saveXML()); $retVal->setHeader('Content-Language', $this->options->getLang()); return $retVal; } @@ -212,7 +212,7 @@ $parent->removeChild($param); } - $body = getElementByTagName($doc,"body"); + $body = getElementByTagName($doc,"html"); $files = $body->getElementsByTagName("file"); $toRemove = array(); @@ -264,15 +264,12 @@ $callString .= ");"; eval($callString); } - $ndoc = new DOMDocument(); - - $ndoc->loadXml("${file_content}"); + $ndoc = $doc->createDocumentFragment(); $parent = $file->parentNode; - foreach ($ndoc->firstChild->childNodes as $child) { - $clonedChild = $doc->importNode($child, true); - $parent->insertBefore($clonedChild, $file); - } + + $ndoc->appendXML($file_content); + $parent->insertBefore($ndoc, $file); //We need to iterate in the opposite direction when removing, //so best shifting.