Permalink
Browse files

Issue #81: Pretty-printing XML/HTML is default.

By default, output is now formatted, and there is an option
to disable.
  • Loading branch information...
1 parent ae4ab24 commit 06f31fb51e50b3f3b7ce34860f19aeac9d430e56 @technosophos committed May 25, 2012
Showing with 12 additions and 0 deletions.
  1. +8 −0 src/QueryPath/DOMQuery.php
  2. +4 −0 src/qp.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);
View
@@ -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

0 comments on commit 06f31fb

Please sign in to comment.