3 require_once 'common.php'; // load library
5 require_once 'HTMLPurifier/Printer/HTMLDefinition.php';
6 require_once 'HTMLPurifier/Printer/CSSDefinition.php';
7 require_once 'HTMLPurifier/Printer/ConfigForm.php';
9 $config = HTMLPurifier_Config
::loadArrayFromForm($_GET, 'config', 'HTML');
11 // you can do custom configuration!
12 if (file_exists('printDefinition.settings.php')) {
13 include 'printDefinition.settings.php';
16 $printer_html_definition = new HTMLPurifier_Printer_HTMLDefinition();
17 $printer_css_definition = new HTMLPurifier_Printer_CSSDefinition();
19 $printer_config_form = new HTMLPurifier_Printer_ConfigForm(
21 'http://htmlpurifier.org/live/configdoc/plain.html#%s'
24 echo '<?xml version="1.0" encoding="UTF-8" ?>';
27 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
28 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
29 <html xmlns
="http://www.w3.org/1999/xhtml" lang
="en" xml
:lang
="en">
31 <title
>HTML Purifier Printer Smoketest
</title
>
32 <meta http
-equiv
="Content-Type" content
="text/html; charset=UTF-8" />
33 <style type
="text/css">
34 .hp
-config
{margin
-left
:auto
; margin
-right
:auto
;}
35 .HTMLPurifier_Printer table
{border
-collapse
:collapse
;
36 border
:1px solid
#000; width:600px;
37 margin
:1em auto
;font
-family
:sans
-serif
;font
-size
:75%
;}
38 .HTMLPurifier_Printer td
, .HTMLPurifier_Printer th
{padding
:3px
;
39 border
:1px solid
#000;background:#CCC; vertical-align: baseline;}
40 .HTMLPurifier_Printer th
{text
-align
:left
;background
:#CCF;width:20%;}
41 .HTMLPurifier_Printer caption
{font
-size
:1.5em
; font
-weight
:bold
;
43 .HTMLPurifier_Printer
.heavy
{background
:#99C;text-align:center;}
44 .HTMLPurifier_Printer
.unsafe
{background
:#C99;}
45 dt
{font
-weight
:bold
;}
47 <link rel
="stylesheet" href
="../library/HTMLPurifier/Printer/ConfigForm.css" type
="text/css" />
48 <script defer
="defer" type
="text/javascript" src
="../library/HTMLPurifier/Printer/ConfigForm.js"></script
>
52 <h1
>HTML Purifier Printer Smoketest
</h1
>
54 <p
>HTML Purifier claims to have a robust yet permissive whitelist
: this
55 page will allow you to see precisely what HTML Purifier
's internal
57 also twiddle with the configuration settings to see how a directive
58 influences the internal workings of the definition objects.</p>
60 <h2>Modify configuration</h2>
62 <p>You can specify an array by typing in a comma-separated
63 list of items, HTML Purifier will take care of the rest (including
64 transformation into a real array list or a lookup table).</p>
66 <form method="get" action="" name="hp-configform">
68 echo $printer_config_form->render($config, 'HTML
');
70 <p>* Some configuration directives make a distinction between an empty
71 variable and a null variable. A whitelist, for example, will take an
72 empty array as meaning <em>no</em> allowed elements, while checking
73 Null/Disabled will mean that user whitelisting functionality is disabled.</p>
79 <dt>Parent of Fragment</dt>
80 <dd>HTML that HTML Purifier does not live in a void: when it's
81 output
, it has to be placed in another element by means of
82 something like
<code
><
;element
>
; <
;?php
echo $html
83 ?
>
; <
;/element
>
;</code
>. The parent in this example
84 is
<code
>element
</code
>.</dd
>
86 <dd
>Whether
or not HTML Purifier
's output is Transitional or
87 Strict compliant. Non-strict mode still actually a little strict
88 and converts many deprecated elements.</dd>
90 <dd>Literally <strong>Parsed Character Data</strong>, it is regular
91 text. Tags like <code>ul</code> don't allow text in them
, so
92 #PCDATA is missing.</dd>
93 <dt
>Tag transform
</dt
>
94 <dd
>A tag transform will change one tag to another
. Example
: <code
>font
</code
>
95 turns into a
<code
>span
</code
> tag with appropriate CSS
.</dd
>
96 <dt
>Attr Transform
</dt
>
97 <dd
>An attribute transform changes a group of attributes based on one
98 another
. Currently
, only
<code
>lang
</code
> and <code
>xml
:lang
</code
>
99 use this hook
, to synchronize each other
's values. Pre/Post indicates
100 whether or not the transform is done before/after validation.</dd>
102 <dd>Tags that an element excludes are excluded for all descendants of
103 that element, and not just the children of them.</dd>
104 <dt>Name(Param1, Param2)</dt>
105 <dd>Represents an internal data-structure. You'll have to check out
106 the corresponding classes in HTML Purifier to find out more
.</dd
>
109 <h2
>HTMLDefinition
</h2
>
110 <?php
echo $printer_html_definition->render($config) ?
>
111 <h2
>CSSDefinition
</h2
>
112 <?php
echo $printer_css_definition->render($config) ?
>