From 0e7cd49d390160603563c17c76dea82eba1824b9 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 27 May 2013 17:38:02 -0400 Subject: Seperated the Traverser from the Output generation. The Traverser now simply walks through a document. The OutputRules convert the nodes into output html. The rules is a configurable options. By default OutputRules will generate html close to the html5 that was parsed. Alternate rule implementation (e.g., minify rules, pretty spacing rules) can be set as the default or on an individual case. --- src/HTML5/Serializer/Serializer.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/HTML5/Serializer/Serializer.php') diff --git a/src/HTML5/Serializer/Serializer.php b/src/HTML5/Serializer/Serializer.php index 3f9187f..7053df5 100644 --- a/src/HTML5/Serializer/Serializer.php +++ b/src/HTML5/Serializer/Serializer.php @@ -15,8 +15,7 @@ namespace HTML5\Serializer; */ class Serializer { protected $dom; - protected $pretty = TRUE; - protected $encode = FALSE; + protected $options = array(); /** * Create a serializer. @@ -36,14 +35,7 @@ class Serializer { */ public function __construct($dom, $options = array()) { $this->dom = $dom; - - if (isset($options['format']) && is_bool($options['format'])) { - $this->pretty = $options['format']; - } - - if (isset($options['encode']) && is_bool($options['encode'])) { - $this->encode = $options['encode']; - } + $this->options = $options; } /** @@ -63,9 +55,7 @@ class Serializer { else { $file = fopen($filename, 'w'); } - $trav = new Traverser($this->dom, $file); - $trav->formatOutput($this->pretty); - $trav->encodeOutput($this->encode); + $trav = new Traverser($this->dom, $file, $this->options); $trav->walk(); -- cgit v1.2.3