3 // This function looks for text including markup and
4 // applies tidy's repair function to it.
5 // Tidy is a HTML clean and
6 // repair utility, which is currently available for PHP 4.3.x and PHP 5 as a
7 // PECL extension from http://pecl.php.net/package/tidy, in PHP 5 you need only
8 // to compile using the --with-tidy option.
9 // If you don't have the tidy extension installed or don't know, you can enable
10 // or disable this filter, it just won't have any effect.
11 // If you want to know what you can set in $tidyoptions and what their default
12 // values are, see http://php.net/manual/en/function.tidy-get-config.php.
15 * @author Hannes Gassert <hannes at mediagonal dot ch>
16 * @param int course id
17 * @param string text to be filtered
19 function tidy_filter($courseid, $text) {
21 /// Configuration for tidy. Feel free to tune for your needs, e.g. to allow
22 /// proprietary markup.
24 'output-xhtml' => true,
25 'show-body-only' => true,
27 'drop-proprietary-attributes' => true,
28 'drop-font-tags' => true,
29 'drop-empty-paras' => true,
34 /// Do a quick check using strpos to avoid unnecessary work
35 if (strpos($text, '<') === false) {
40 /// If enabled: run tidy over the entire string
41 if (function_exists('tidy_repair_string')){
42 $text = tidy_repair_string($text, $tidyoptions, 'utf8');