diff --git a/reference/tidy/book.xml b/reference/tidy/book.xml index b4cf58432d..d4bbf63bb3 100644 --- a/reference/tidy/book.xml +++ b/reference/tidy/book.xml @@ -1,5 +1,5 @@ - + Tidy @@ -18,6 +18,7 @@ &reference.tidy.setup; &reference.tidy.constants; &reference.tidy.examples; + &reference.tidy.tidynode; &reference.tidy.reference; diff --git a/reference/tidy/functions/tidy-node-get-attr.xml b/reference/tidy/functions/tidy-node-get-attr.xml deleted file mode 100644 index f2b5799cc9..0000000000 --- a/reference/tidy/functions/tidy-node-get-attr.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - tidy_node->get_attr - Return the attribute with the provided attribute id - - - &reftitle.description; - - tidy_attrtidy_node->get_attr - intattrib_id - - &warn.undocumented.func; - - - - diff --git a/reference/tidy/functions/tidy-node-get-nodes.xml b/reference/tidy/functions/tidy-node-get-nodes.xml deleted file mode 100644 index f77fc3e404..0000000000 --- a/reference/tidy/functions/tidy-node-get-nodes.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - tidy_node->get_nodes - Return an array of nodes under this node with the specified id - - - &reftitle.description; - - arraytidy_node->get_nodes - intnode_id - - &warn.undocumented.func; - - - - diff --git a/reference/tidy/functions/tidy-node-next.xml b/reference/tidy/functions/tidy-node-next.xml deleted file mode 100644 index 4e91084796..0000000000 --- a/reference/tidy/functions/tidy-node-next.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - tidy_node->next - Returns the next sibling to this node - - - &reftitle.description; - - tidy_nodetidy_node->next - - - &warn.undocumented.func; - - - - diff --git a/reference/tidy/functions/tidy-node-prev.xml b/reference/tidy/functions/tidy-node-prev.xml deleted file mode 100644 index 8741c43da8..0000000000 --- a/reference/tidy/functions/tidy-node-prev.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - tidy_node->prev - Returns the previous sibling to this node - - - &reftitle.description; - - tidy_nodetidy_node->prev - - - &warn.undocumented.func; - - - - diff --git a/reference/tidy/functions/tidyNode-hasChildren.xml b/reference/tidy/functions/tidyNode-hasChildren.xml deleted file mode 100644 index 1b8782ac8e..0000000000 --- a/reference/tidy/functions/tidyNode-hasChildren.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - tidyNode->hasChildren - Returns true if this node has children - - - &reftitle.description; - - booltidyNode->hasChildren - - - - Tells if the current node has children. - - - - - &reftitle.returnvalues; - - Returns &true; if the node has children, &false; otherwise. - - - - - &reftitle.notes; - - - This function was named tidy_node->has_children in - PHP 4/Tidy 1. - - - - - - diff --git a/reference/tidy/functions/tidyNode-hasSiblings.xml b/reference/tidy/functions/tidyNode-hasSiblings.xml deleted file mode 100644 index 23fd6841c7..0000000000 --- a/reference/tidy/functions/tidyNode-hasSiblings.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - tidyNode->hasSiblings - Returns true if this node has siblings - - - &reftitle.description; - - booltidyNode->hasSiblings - - - - Tells if the current node has siblings. - - - - - &reftitle.returnvalues; - - Returns &true; if the node has siblings, &false; otherwise. - - - - - &reftitle.notes; - - - This function was named tidy_node->has_siblings in - PHP 4/Tidy 1. - - - - - - diff --git a/reference/tidy/functions/tidyNode-isAsp.xml b/reference/tidy/functions/tidyNode-isAsp.xml deleted file mode 100755 index cdbc90a37c..0000000000 --- a/reference/tidy/functions/tidyNode-isAsp.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - tidyNode->isAsp - Returns true if this node is ASP - - - &reftitle.description; - - booltidyNode->isAsp - - - - Tells whether the current node is ASP. - - - - - &reftitle.returnvalues; - - Returns &true; if the node is ASP, &false; otherwise. - - - - - &reftitle.notes; - - - This function was named tidy_node->is_asp in - PHP 4/Tidy 1. - - - - - - diff --git a/reference/tidy/functions/tidyNode-isComment.xml b/reference/tidy/functions/tidyNode-isComment.xml deleted file mode 100644 index 83ef3c0d37..0000000000 --- a/reference/tidy/functions/tidyNode-isComment.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - tidyNode->isComment - Returns true if this node represents a comment - - - &reftitle.description; - - booltidyNode->isComment - - - - Tells if the current node is a comment. - - - - - &reftitle.returnvalues; - - Returns &true; if the node is a comment, &false; otherwise. - - - - - &reftitle.notes; - - - This function was named tidy_node->is_comment in - PHP 4/Tidy 1. - - - - - - diff --git a/reference/tidy/functions/tidyNode-isHtml.xml b/reference/tidy/functions/tidyNode-isHtml.xml deleted file mode 100644 index 89028bcaf3..0000000000 --- a/reference/tidy/functions/tidyNode-isHtml.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - tidyNode->isHtml - Returns true if this node is part of a HTML document - - - &reftitle.description; - - booltidyNode->isHtml - - - - Tells if the current node is part of HTML document. - - - - - &reftitle.returnvalues; - - Returns &true; if the node is part of a HTML document, &false; otherwise. - - - - - &reftitle.notes; - - - This function was named tidy_node->is_html in - PHP 4/Tidy 1. - - - - - - diff --git a/reference/tidy/functions/tidyNode-isJste.xml b/reference/tidy/functions/tidyNode-isJste.xml deleted file mode 100644 index 839db4c76c..0000000000 --- a/reference/tidy/functions/tidyNode-isJste.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - tidyNode->isJste - Returns true if this node is JSTE - - - &reftitle.description; - - booltidyNode->isJste - - - - Tells if the current node is JSTE. - - - - - &reftitle.returnvalues; - - Returns &true; if the node is JSTE, &false; otherwise. - - - - - &reftitle.notes; - - - This function was named tidy_node->is_jste in - PHP 4/Tidy 1. - - - - - - diff --git a/reference/tidy/functions/tidyNode-isText.xml b/reference/tidy/functions/tidyNode-isText.xml deleted file mode 100644 index d3a5583d64..0000000000 --- a/reference/tidy/functions/tidyNode-isText.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - tidyNode->isText - Returns true if this node represents text (no markup) - - - &reftitle.description; - - booltidyNode->isText - - - - Tells if the node represents a text (no markup). - - - - - &reftitle.returnvalues; - - Returns &true; if the node represent a text, &false; otherwise. - - - - - &reftitle.notes; - - - This function was named tidy_node->is_text in - PHP 4/Tidy 1. - - - - - - diff --git a/reference/tidy/reference.xml b/reference/tidy/reference.xml index 69db922bfd..4f2cd885c4 100644 --- a/reference/tidy/reference.xml +++ b/reference/tidy/reference.xml @@ -1,92 +1,13 @@ - + Tidy &Functions; - -
- &reftitle.classes; + &reference.tidy.entities.functions; -
- <classname>tidyNode</classname> -
- &reftitle.methods; - - - - Returns the parent of the current node - - - - Returns &true; if the current node has children - - - - Returns &true; if the current node has siblings - - - - Returns &true; if the current node is ASP code - - - - Returns &true; if the current node is a comment - - - - Returns &true; if the current node is HTML - - - - Returns &true; if the current node is JSTE - - - - Returns &true; if the current node is PHP - - - - Returns &true; if the current node is Text (no markup) - - -
- -
- &reftitle.properties; - - - value - the value of the node (e.g. the html text) - - - name - the name of the tag (e.g. html, a, etc..) - - - type - the type of the node (one of the constants above, e.g. TIDY_NODETYPE_PHP) - - - line* - the line where the node starts - - - column* - the column where the node starts - - - proprietary* - &true; if the node refers to a proprietary tag - - - id - the ID of the tag (one of the constants above, e.g. TIDY_TAG_FRAME) - - - attribute - an array with the attributes of the current node, or &null; if there aren't any - - - child - an array with the child tidyNodes, or &null; if there aren't any - - - - - The properties marked with * are just available since PHP 5.1.0. - - -
-
-
-
- - &reference.tidy.entities.functions;
+ + The <classname>TidyNode</classname> class + TidyNode + + + + +
+ &reftitle.intro; + + An HTML node in an HTML file, as detected by tidy. + +
+ + +
+ &reftitle.classsynopsis; + + + + TidyNode + + + + + TidyNode + + + + Properties + + + Methods + + + + + +
+ + +
+ &reftitle.properties; + + + value + + The HTML representation of the node, including the surrounding tags. + + + + name + + The name of the HTML node + + + + type + + The type of the tag (one of the constants above, e.g. TIDY_NODETYPE_PHP) + + + + line + + The line number at which the tags is located in the file + + + + column + + The column number at which the tags is located in the file + + + + proprietary + + Indicates if the node is a proprietary tag + + + + id + + The ID of the tag (one of the constants above, e.g. TIDY_TAG_FRAME) + + + + attribute + + + An array of string, representing + the attributes names (as keys) of the current node. + + + + + child + + + An array of TidyNode, representing + the children of the current node. + + + + + + + + + + + &Version; + &Description; + + + + + 5.1.0 + line, column + and proprietary were added + + + + + + +
+ +
+ + &reference.tidy.entities.tidynode; + +
+ + + diff --git a/reference/tidy/functions/tidynode-getparent.xml b/reference/tidy/tidynode/getparent.xml similarity index 57% rename from reference/tidy/functions/tidynode-getparent.xml rename to reference/tidy/tidynode/getparent.xml index ed61ffea48..903c96261f 100644 --- a/reference/tidy/functions/tidynode-getparent.xml +++ b/reference/tidy/tidynode/getparent.xml @@ -1,9 +1,9 @@ - - + + tidyNode::getParent - returns the parent node of the current node + Returns the parent node of the current node @@ -17,6 +17,50 @@ + + &reftitle.examples; + + + Example with <function>tidyNode::hasChildren</function> + + +title'; ?> +<# + /* JSTE code */ + alert('Hello World'); +#> + + + Hello World + + + +HTML; + + +$tidy = tidy_parse_string($html); +$num = 0; + +$node = $tidy->html()->child[0]->child[0]; + +var_dump($node->getparent()->name); +?> +]]> + + &example.outputs; + + + + + + + &reftitle.returnvalues; diff --git a/reference/tidy/tidynode/haschildren.xml b/reference/tidy/tidynode/haschildren.xml new file mode 100644 index 0000000000..f6a99cef12 --- /dev/null +++ b/reference/tidy/tidynode/haschildren.xml @@ -0,0 +1,115 @@ + + + + + tidyNode::hasChildren + Checks if a node has children + + + &reftitle.description; + + booltidyNode::hasChildren + + + + Tells if the node has children. + + + + + &reftitle.returnvalues; + + Returns &true; if the node has children, &false; otherwise. + + + + + &reftitle.examples; + + + Example with <function>tidyNode::hasChildren</function> + + +title'; ?> +<# + /* JSTE code */ + alert('Hello World'); +#> + + + + + +<% + /* ASP code */ + response.write("Hello World!") +%> + + +Hello World + +Outside HTML +HTML; + + +$tidy = tidy_parse_string($html); +$num = 0; + +// the head tag +var_dump($tidy->html()->child[0]->hasChildren()); + +// the php inside the head tag +var_dump($tidy->html()->child[0]->child[0]->hasChildren()); + +?> +]]> + + &example.outputs; + + + + + + + + + &reftitle.notes; + + + This function was named tidy_node::has_children in + PHP 4/Tidy 1. + + + + + + diff --git a/reference/tidy/tidynode/hassiblings.xml b/reference/tidy/tidynode/hassiblings.xml new file mode 100644 index 0000000000..7382e7f3ed --- /dev/null +++ b/reference/tidy/tidynode/hassiblings.xml @@ -0,0 +1,115 @@ + + + + + tidyNode::hasSiblings + Checks if a node has siblings + + + &reftitle.description; + + booltidyNode::hasSiblings + + + + Tells if the node has siblings. + + + + + &reftitle.returnvalues; + + Returns &true; if the node has siblings, &false; otherwise. + + + + + &reftitle.examples; + + + Example with <function>tidyNode::hasSiblings</function> + + +title'; ?> +<# + /* JSTE code */ + alert('Hello World'); +#> + + + + + +<% + /* ASP code */ + response.write("Hello World!") +%> + + +Hello World + +Outside HTML +HTML; + + +$tidy = tidy_parse_string($html); +$num = 0; + +// the html tag +var_dump($tidy->html()->hasSiblings()); + +// the head tag +var_dump($tidy->html()->child[0]->hasSiblings()); + +?> +]]> + + &example.outputs; + + + + + + + + + &reftitle.notes; + + + This function was named tidy_node::has_siblings in + PHP 4/Tidy 1. + + + + + + diff --git a/reference/tidy/tidynode/isasp.xml b/reference/tidy/tidynode/isasp.xml new file mode 100755 index 0000000000..41bd669f1f --- /dev/null +++ b/reference/tidy/tidynode/isasp.xml @@ -0,0 +1,130 @@ + + + + + tidyNode::isAsp + Checks if this node is ASP + + + &reftitle.description; + + booltidyNode->isAsp + + + + Tells whether the current node is ASP. + + + + + &reftitle.returnvalues; + + Returns &true; if the node is ASP, &false; otherwise. + + + + + &reftitle.examples; + + + Extract ASP code from a mixed HTML document + + +title'; ?> +<# + /* JSTE code */ + alert('Hello World'); +#> + + + + + +<% + /* ASP code */ + response.write("Hello World!") +%> + + +Hello World + +Outside HTML +HTML; + + +$tidy = tidy_parse_string($html); +$num = 0; + +get_nodes($tidy->html(), 'asp'); + +function get_nodes($node, $node_type) { + + // check if the current node is of requested type + if($node->{"is$node_type"}()) { + echo "\n\n# $node_type node #" . ++$GLOBALS['num'] . "\n"; + echo $node->value; + } + + // check if the current node has childrens + if($node->hasChildren()) { + foreach($node->child as $child) { + get_nodes($child, $node_type); + } + } +} + +?> +]]> + + &example.outputs; + + +]]> + + + + + + + &reftitle.notes; + + + This function was named tidy_node::is_asp in + PHP 4/Tidy 1. + + + + + + diff --git a/reference/tidy/tidynode/iscomment.xml b/reference/tidy/tidynode/iscomment.xml new file mode 100644 index 0000000000..96f4833926 --- /dev/null +++ b/reference/tidy/tidynode/iscomment.xml @@ -0,0 +1,135 @@ + + + + + tidyNode::isComment + Checks if a node represents a comment + + + &reftitle.description; + + booltidyNode::isComment + + + + Tells if the node is a comment. + + + + + &reftitle.returnvalues; + + Returns &true; if the node is a comment, &false; otherwise. + + + + + &reftitle.examples; + + + Extract comments from a mixed HTML document + + +title'; ?> +<# + /* JSTE code */ + alert('Hello World'); +#> + + + + + +<% + /* ASP code */ + response.write("Hello World!") +%> + + +Hello World + +Outside HTML +HTML; + + +$tidy = tidy_parse_string($html); +$num = 0; + +get_nodes($tidy->html(), 'comment'); + +function get_nodes($node, $node_type) { + + // check if the current node is of requested type + if($node->{"is$node_type"}()) { + echo "\n\n# $node_type node #" . ++$GLOBALS['num'] . "\n"; + echo $node->value; + } + + // check if the current node has childrens + if($node->hasChildren()) { + foreach($node->child as $child) { + get_nodes($child, $node_type); + } + } +} + +?> +]]> + + &example.outputs; + + + +/* +var_dump($tidy->html()->child[0]->hasChildren()); +var_dump($tidy->html()->child[0]->child[0]->hasChildren()); +*/ +]]> + + + + + + + &reftitle.notes; + + + This function was named tidy_node::is_comment in + PHP 4/Tidy 1. + + + + + + diff --git a/reference/tidy/tidynode/ishtml.xml b/reference/tidy/tidynode/ishtml.xml new file mode 100644 index 0000000000..b03ac344ff --- /dev/null +++ b/reference/tidy/tidynode/ishtml.xml @@ -0,0 +1,202 @@ + + + + + tidyNode->isHtml + Checks if a node is part of a HTML document + + + &reftitle.description; + + booltidyNode::isHtml + + + + Tells if the node is part of HTML document. + + + + + &reftitle.returnvalues; + + Returns &true; if the node is part of a HTML document, &false; otherwise. + + + + + &reftitle.examples; + + + Extract HTML code from a mixed HTML document + + +title'; ?> +<# + /* JSTE code */ + alert('Hello World'); +#> + + + + + +<% + /* ASP code */ + response.write("Hello World!") +%> + + +Hello World + +Outside HTML +HTML; + + +$tidy = tidy_parse_string($html); +$num = 0; + +get_nodes($tidy->html(), 'text'); + +function get_nodes($node, $node_type) { + // check if the current node is of requested type + if($node->{"is$node_type"}()) { + echo "\n\n# $node_type node #" . ++$GLOBALS['num'] . "\n"; + echo $node->value; + } + + // check if the current node has childrens + if($node->hasChildren()) { + foreach($node->child as $child) { + get_nodes($child, $node_type); + } + } +} + +?> +]]> + + &example.outputs; + + + +title'; ?><# + /* JSTE code */ + alert('Hello World'); +#> + + + +<% + /* ASP code */ + response.write("Hello World!") +%> +Hello WorldOutside HTML + + + +# html node #2 + +title'; ?><# + /* JSTE code */ + alert('Hello World'); +#> + + + + +# html node #3 +title'; ?> + +# html node #4 +<# + /* JSTE code */ + alert('Hello World'); +#> + +# html node #5 + + + +# html node #6 + +<% + /* ASP code */ + response.write("Hello World!") +%> +Hello WorldOutside HTML + + + +# html node #7 + + +# html node #8 +<% + /* ASP code */ + response.write("Hello World!") +%> + +# html node #9 + + + +# html node #10 +Hello World + +# html node #11 +Outside HTML +]]> + + + + + + + &reftitle.notes; + + + This function was named tidy_node::is_html in + PHP 4/Tidy 1. + + + + + + diff --git a/reference/tidy/tidynode/isjste.xml b/reference/tidy/tidynode/isjste.xml new file mode 100644 index 0000000000..05da5ce9ee --- /dev/null +++ b/reference/tidy/tidynode/isjste.xml @@ -0,0 +1,134 @@ + + + + + tidyNode->isJste + Checks if this node is JSTE + + + &reftitle.description; + + booltidyNode::isJste + + + + Tells if the node is JSTE. + + + + + &reftitle.returnvalues; + + Returns &true; if the node is JSTE, &false; otherwise. + + + + + &reftitle.examples; + + + Extract JSTE code from a mixed HTML document + + +title'; ?> +<# + /* JSTE code */ + alert('Hello World'); +#> + + + + + +<% + /* ASP code */ + response.write("Hello World!") +%> + + +Hello World + +Outside HTML +HTML; + + +$tidy = tidy_parse_string($html); +$num = 0; + +get_nodes($tidy->html(), 'text'); + +function get_nodes($node, $node_type) { + + // check if the current node is of requested type + if($node->{"is$node_type"}()) { + echo "\n\n# $node_type node #" . ++$GLOBALS['num'] . "\n"; + echo $node->value; + } + + // check if the current node has childrens + if($node->hasChildren()) { + foreach($node->child as $child) { + get_nodes($child, $node_type); + } + } +} + +?> +]]> + + &example.outputs; + + + +/* +var_dump($tidy->html()->child[0]->hasChildren()); +var_dump($tidy->html()->child[0]->child[0]->hasChildren()); +*/ +]]> + + + + + + &reftitle.notes; + + + This function was named tidy_node->is_jste in + PHP 4/Tidy 1. + + + + + + diff --git a/reference/tidy/functions/tidyNode-isPhp.xml b/reference/tidy/tidynode/isphp.xml similarity index 64% rename from reference/tidy/functions/tidyNode-isPhp.xml rename to reference/tidy/tidynode/isphp.xml index 02b6bd614d..70b556e421 100644 --- a/reference/tidy/functions/tidyNode-isPhp.xml +++ b/reference/tidy/tidynode/isphp.xml @@ -1,18 +1,18 @@ - - + + - tidyNode->isPhp - Returns true if this node is PHP + tidyNode::isPhp + Checks if a node is PHP &reftitle.description; - booltidyNode->isPhp + booltidyNode::isPhp - Tells if the current node is PHP. + Tells if the node is PHP. @@ -27,7 +27,7 @@ &reftitle.examples; - get the PHP code from a mixed HTML/PHP document + Extract PHP code from a mixed HTML document title'; ?> +<# + /* JSTE code */ + alert('Hello World'); +#> +<% + /* ASP code */ + response.write("Hello World!") +%> + + +Hello World +Outside HTML HTML; $tidy = tidy_parse_string($html); $num = 0; -get_php($tidy->html()); +get_nodes($tidy->html(), 'php'); +function get_nodes($node, $node_type) { -function get_php($node) { - - // check if the current node is PHP code - if($node->isPhp()) { - echo "\n\n# PHP node #" . ++$GLOBALS['num'] . "\n"; + // check if the current node is of requested type + if($node->{"is$node_type"}()) { + echo "\n\n# $node_type node #" . ++$GLOBALS['num'] . "\n"; echo $node->value; } // check if the current node has childrens if($node->hasChildren()) { foreach($node->child as $child) { - get_php($child); + get_nodes($child, $node_type); } } } @@ -74,24 +86,25 @@ function get_php($node) { &example.outputs; title'; ?> -# PHP node #2 +# php node #2 ]]> - + &reftitle.notes; - This function was named tidy_node->is_php in + This function was named tidy_node::is_php in PHP 4/Tidy 1. diff --git a/reference/tidy/tidynode/istext.xml b/reference/tidy/tidynode/istext.xml new file mode 100644 index 0000000000..f2879d5693 --- /dev/null +++ b/reference/tidy/tidynode/istext.xml @@ -0,0 +1,130 @@ + + + + + tidyNode::isText + Checks if a node represents text (no markup) + + + &reftitle.description; + + booltidyNode::isText + + + + Tells if the node represents a text (without any markup). + + + + + &reftitle.returnvalues; + + Returns &true; if the node represent a text, &false; otherwise. + + + + + &reftitle.examples; + + + Extract text from a mixed HTML document + + +title'; ?> +<# + /* JSTE code */ + alert('Hello World'); +#> + + + + + +<% + /* ASP code */ + response.write("Hello World!") +%> + + +Hello World + +Outside HTML +HTML; + + +$tidy = tidy_parse_string($html); +$num = 0; + +get_nodes($tidy->html(), 'text'); + +function get_nodes($node, $node_type) { + + // check if the current node is of requested type + if($node->{"is$node_type"}()) { + echo "\n\n# $node_type node #" . ++$GLOBALS['num'] . "\n"; + echo $node->value; + } + + // check if the current node has childrens + if($node->hasChildren()) { + foreach($node->child as $child) { + get_nodes($child, $node_type); + } + } +} + +?> +]]> + + &example.outputs; + + + + + + + + + &reftitle.notes; + + + This function was named tidy_node::is_text in + PHP 4/Tidy 1. + + + + + +