changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / markup / usemod.php
1 <?php
2
3 /*
4    Emulates UseMode like headlines (but others use this too).
5    == Heading ==      corresponds to !!! Large Heading
6    === Heading ===    corresponds to !! Meadium
7    ==== Heading ====  corresponds to ! Smallest Headline
8    === # anchored headline ===
9
10    And then also allows for:
11    <toc>
12 */
13
14
15 $ewiki_plugins["format_source"][] = "ewiki_format_src_usemod_headings";
16
17
18 function ewiki_format_src_usemod_headings(&$src) {
19
20    global $usemod_toc;
21
22    #-- ===Headlines===
23    $src = preg_replace('/^(={2,4})([^=].*?)==+\s*$/me',
24    '
25         str_repeat("!", $we = (5 - strlen("\\1"))  ) . " "
26       . (($uu=stripslashes(trim("\\2"))) && ($uu[0]=="#")
27            ? ($GLOBALS["usemod_toc"][][$we]=$uu=trim(substr($uu, 1)))
28              . (" #[" . preg_replace("/[^\w]/", "_", $uu) . "]")
29            : ($uu)
30         )
31       . "\n\n"
32    ', $src);
33
34    #-- <toc>
35    if (strpos($src, "&lt;toc&gt;")) {
36       foreach ($usemod_toc as $i=>$d) {
37          foreach ($d as $num=>$str) {
38             $toc_str .= str_repeat("*", 4 - $num) . " [.#$str \"$str\"] \n";
39          }
40       }
41       $src = preg_replace("'&lt;toc&gt;'", $toc_str, $src);
42    }
43 }
44
45
46 ?>