changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / markup / bbcode.php
1 <?php
2
3  # this converts the "bulletin board code" to the easier
4  # wiki syntax internally
5
6
7
8  $ewiki_plugins["format_source"][] = "ewiki_format_emulate_bbcode";
9
10
11
12  function ewiki_format_emulate_bbcode(&$source) {
13
14     #-- for super-correct translation, we'll need a regex:
15     $source = preg_replace('/\[(link|url|img|email)[:=]([^\]\s]+)]/', '[$1|', $source);
16
17     #-- else simple string replacements will do:
18     $repl = array(
19        '[link]' => '[',
20        '[/link]' => ']',
21        '[url]' => '[',
22        '[/url]' => ']',
23        '[img]' => '[',
24        '[/img]' => ']',
25        '[email]' => '[',
26        '[/email]' => ']',
27        '[b]' => '__',
28        '[/b]' => '__',
29        '[i]' => "''",
30        '[/i]' => "''",
31        '[u]' => "_",
32        '[/u]' => "_",
33        '[list' => '<!-- [list',
34        '[/list]' => '',
35        '[*]' => '*',
36     );
37
38     foreach ($repl as $from => $to) {
39        $source = str_replace($from, $to, $source);
40     }
41
42  }
43
44
45 ?>