Source for file htmlfilter.php
Documentation is available at htmlfilter.php
Filtering HTML output to remove whitespace and
convert tags / attrs to lower. Note how using
references allows the incoming XML stream to be
# require_once 'XML/SaxFilters.php'; // This is the normal way to do it
# Done to help development
if ( !@include_once 'XML/SaxFilters.php' ) {
define ('XML_SAXFILTERS', '../../');
include_once XML_SAXFILTERS . 'SaxFilters.php';
//----------------------------------------------------------------------------
* Whether we're inside an HTML page
* @var boolean (default = FALSE)
* Whether we're inside an HTML where the contents
* are preformatted e.g. pre or script
* @var boolean (default = FALSE)
function open(& $tag,& $attrs,$empty) {
$this->child->open ($tag,$attrs,$empty);
function close(& $tag,& $empty) {
$this->child->close ($tag,$empty);
$this->child->data ($text);
if ( !$this->inPre && $this->inHtml ) {
// Note here - DOT NOT pass by reference
//----------------------------------------------------------------------------
* Converts tags and attribute names to lower case
function open(& $tag,& $attrs,$empty) {
function close(& $tag,& $empty) {
//----------------------------------------------------------------------------
* Reconstructs the HTML - this filter is chained directly to the parser. By
* chaining the WhitespaceFilter and TagsToLowerFilter filter to this filters,
* it's possible to modify the incoming XML stream before it is handled by
function open(& $tag,& $attrs,$empty) {
$this->child->open ($tag,$attrs,$empty);
foreach ( $attrs as $key => $val ) {
$this->html.= ' '. $key.= '="'. $val. '"';
function close(& $tag,$empty) {
$this->child->close ($tag,$empty);
$this->html.= '</'. $tag. '>';
$this->child->data ($data);
$this->child->escape ($data);
$this->html.= '<!'. $data. '>';
//----------------------------------------------------------------------------
// Capture the HTML with output buffering
// Use the HTMLSax parser - note fourth argument - builds the chain
Documentation generated on Mon, 11 Mar 2019 10:15:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|