no more id cvs markers or closing php tags!
[moodle.git] / mod / wiki / db / migration / wiki / ewiki / plugins / moodle / moodle_rescue_html.php
CommitLineData
d50eb3d4 1<?php
39fcb981 2
3/*
4 Can be used to allow preserving of certain "safe" HTML <tags>
5 (as seen in [sfWiki | http://sfwiki.sf.net/].
6 "Safe" tags include Q, S, PRE, TT, H1-H6, KBD, VAR, XMP, B, I
7 but just see (or change) ewiki_format() for more. They are not
8 accepted if written with mixed lowercase and uppercase letters,
9 and they cannot contain any tag attributes.
10
11 RESCUE_HTML was formerly part of the main rendering function, but
12 has now been extracted into this plugin, so one only needs to
13 include it to get simple html tags working.
14*/
15
16
17$ewiki_plugins["format_source"][] = "ewiki_moodle_rescue_html";
18
19
20function ewiki_moodle_rescue_html(&$wiki_source) {
21 $safe_html = EWIKI_RESCUE_HTML;
22 $safe_html += 1;
23
24 $rescue_html = array(
25 "br", "tt", "b", "i", "strong", "em", "s", "kbd", "var", "xmp", "sup", "sub",
d50eb3d4 26 "pre", "q", "h1", "h2", "h3", "h4", "h5", "h6", "cite", "code", "u",
39fcb981 27 );
28
d50eb3d4
PS
29
30
39fcb981 31 #-- unescape allowed html
32 if ($safe_html) {
33 /*
34 foreach ($rescue_html as $tag) {
35 foreach(array($tag, "/$tag", ($tag=strtoupper($tag)), "/$tag") as $tag) {
36 $wiki_source = str_replace('&lt;'.$tag.'&gt;', "<".$tag.">", $wiki_source);
37 } }
38 */
39 $regexp='#&lt;(/?('.implode("|",$rescue_html).'))( /)?&gt;#i';
40 $wiki_source = preg_replace($regexp, '<$1>', $wiki_source);
41 }
42
43}
44