From 06f31fb51e50b3f3b7ce34860f19aeac9d430e56 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 24 May 2012 20:57:11 -0500 Subject: [PATCH] Issue #81: Pretty-printing XML/HTML is default. By default, output is now formatted, and there is an option to disable. --- src/QueryPath/DOMQuery.php | 8 ++++++++ src/qp.php | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/QueryPath/DOMQuery.php b/src/QueryPath/DOMQuery.php index 50be483a..b29903d5 100644 --- a/src/QueryPath/DOMQuery.php +++ b/src/QueryPath/DOMQuery.php @@ -173,6 +173,14 @@ public function __construct($document = NULL, $string = NULL, $options = array() $this->setMatches($this->document->documentElement); } + // Globally set the output option. + if (isset($this->options['format_output']) && $this->options['format_output'] == FALSE) { + $this->document->formatOutput = FALSE; + } + else { + $this->document->formatOutput = TRUE; + } + // Do a find if the second param was set. if (isset($string) && strlen($string) > 0) { $this->find($string); diff --git a/src/qp.php b/src/qp.php index af37d53f..db422062 100644 --- a/src/qp.php +++ b/src/qp.php @@ -135,6 +135,10 @@ * - omit_xml_declaration: Boolean. If this is TRUE, then certain output * methods (like {@link QueryPath::xml()}) will omit the XML declaration * from the beginning of a document. + * - format_output: Boolean. If this is set to TRUE, QueryPath will format + * the HTML or XML output to make it more readible. If this is set to + * FALSE, QueryPath will minimize whitespace to keep the document smaller + * but harder to read. * - replace_entities: Boolean. If this is TRUE, then any of the insertion * functions (before(), append(), etc.) will replace named entities with * their decimal equivalent, and will replace un-escaped ampersands with