mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00:00
83f735ea7e
Fix bug in HTML_Generator that resulted in attribute-less empty elements to have extra spaces in them. Add whitespace designation to MF_Text. git-svn-id: http://htmlpurifier.org/svnroot/html_purifier/trunk@44 48356398-32a2-884e-a903-53898d9a118a
52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
// MF = Markup Fragment
|
|
// all objects here are immutable
|
|
|
|
class MF {}
|
|
|
|
class MF_Tag extends MF
|
|
{
|
|
var $name;
|
|
function MF_Tag($name) {
|
|
$this->name = strtolower($name); // for some reason, the SAX parser
|
|
// uses uppercase. Investigate?
|
|
}
|
|
}
|
|
|
|
class MF_TagWithAttributes extends MF_Tag
|
|
{
|
|
var $attributes = array();
|
|
function MF_TagWithAttributes($name, $attributes = array()) {
|
|
$this->MF_Tag($name);
|
|
$this->attributes = $attributes;
|
|
}
|
|
}
|
|
|
|
class MF_StartTag extends MF_TagWithAttributes {}
|
|
class MF_EmptyTag extends MF_TagWithAttributes {}
|
|
class MF_EndTag extends MF_Tag {}
|
|
|
|
class MF_Text extends MF
|
|
{
|
|
var $name = '#PCDATA';
|
|
var $data;
|
|
var $is_whitespace = false;
|
|
function MF_Text($data) {
|
|
$this->data = $data;
|
|
if (trim($data, " \n\r\t") === '') $this->is_whitespace = true;
|
|
}
|
|
function append($mf_text) {
|
|
return new MF_Text($this->data . $mf_text->data);
|
|
}
|
|
}
|
|
|
|
class MF_Comment extends MF
|
|
{
|
|
var $data;
|
|
function MF_Comment($data) {
|
|
$this->data = $data;
|
|
}
|
|
}
|
|
|
|
?>
|