friendica-github/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Text.php

88 lines
3.4 KiB
PHP
Raw Normal View History

2010-09-09 03:14:17 +00:00
<?php
/**
* XHTML 1.1 Text Module, defines basic text containers. Core Module.
* @note In the normative XML Schema specification, this module
* is further abstracted into the following modules:
* - Block Phrasal (address, blockquote, pre, h1, h2, h3, h4, h5, h6)
* - Block Structural (div, p)
* - Inline Phrasal (abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var)
* - Inline Structural (br, span)
* This module, functionally, does not distinguish between these
* sub-modules, but the code is internally structured to reflect
* these distinctions.
*/
class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
{
2016-02-09 10:06:17 +00:00
/**
* @type string
*/
2010-09-09 03:14:17 +00:00
public $name = 'Text';
2016-02-09 10:06:17 +00:00
/**
* @type array
*/
2010-09-09 03:14:17 +00:00
public $content_sets = array(
'Flow' => 'Heading | Block | Inline'
);
2016-02-09 10:06:17 +00:00
/**
* @param HTMLPurifier_Config $config
*/
public function setup($config)
{
2010-09-09 03:14:17 +00:00
// Inline Phrasal -------------------------------------------------
2016-02-09 10:06:17 +00:00
$this->addElement('abbr', 'Inline', 'Inline', 'Common');
2010-09-09 03:14:17 +00:00
$this->addElement('acronym', 'Inline', 'Inline', 'Common');
2016-02-09 10:06:17 +00:00
$this->addElement('cite', 'Inline', 'Inline', 'Common');
$this->addElement('dfn', 'Inline', 'Inline', 'Common');
$this->addElement('kbd', 'Inline', 'Inline', 'Common');
$this->addElement('q', 'Inline', 'Inline', 'Common', array('cite' => 'URI'));
$this->addElement('samp', 'Inline', 'Inline', 'Common');
$this->addElement('var', 'Inline', 'Inline', 'Common');
2010-09-09 03:14:17 +00:00
2016-02-09 10:06:17 +00:00
$em = $this->addElement('em', 'Inline', 'Inline', 'Common');
2010-09-09 03:14:17 +00:00
$em->formatting = true;
2016-02-09 10:06:17 +00:00
$strong = $this->addElement('strong', 'Inline', 'Inline', 'Common');
2010-09-09 03:14:17 +00:00
$strong->formatting = true;
2016-02-09 10:06:17 +00:00
$code = $this->addElement('code', 'Inline', 'Inline', 'Common');
2010-09-09 03:14:17 +00:00
$code->formatting = true;
// Inline Structural ----------------------------------------------
$this->addElement('span', 'Inline', 'Inline', 'Common');
2016-02-09 10:06:17 +00:00
$this->addElement('br', 'Inline', 'Empty', 'Core');
2010-09-09 03:14:17 +00:00
// Block Phrasal --------------------------------------------------
2016-02-09 10:06:17 +00:00
$this->addElement('address', 'Block', 'Inline', 'Common');
$this->addElement('blockquote', 'Block', 'Optional: Heading | Block | List', 'Common', array('cite' => 'URI'));
2010-09-09 03:14:17 +00:00
$pre = $this->addElement('pre', 'Block', 'Inline', 'Common');
$pre->excludes = $this->makeLookup(
2016-02-09 10:06:17 +00:00
'img',
'big',
'small',
'object',
'applet',
'font',
'basefont'
);
2010-09-09 03:14:17 +00:00
$this->addElement('h1', 'Heading', 'Inline', 'Common');
$this->addElement('h2', 'Heading', 'Inline', 'Common');
$this->addElement('h3', 'Heading', 'Inline', 'Common');
$this->addElement('h4', 'Heading', 'Inline', 'Common');
$this->addElement('h5', 'Heading', 'Inline', 'Common');
$this->addElement('h6', 'Heading', 'Inline', 'Common');
// Block Structural -----------------------------------------------
$p = $this->addElement('p', 'Block', 'Inline', 'Common');
2016-02-09 10:06:17 +00:00
$p->autoclose = array_flip(
array("address", "blockquote", "center", "dir", "div", "dl", "fieldset", "ol", "p", "ul")
);
2010-09-09 03:14:17 +00:00
$this->addElement('div', 'Block', 'Flow', 'Common');
}
}
// vim: et sw=4 sts=4