df08c0c70fcddf22d68851e9f18ae59accba8bae
[atutor.git] / mods / wiki / plugins / markup / definitionlinks.php
1 <?php
2
3 /*
4    Turns definition list titles into anchors and all occourences
5    of the terms into links to there.
6 */
7
8 $ewiki_plugins["format_final"][] = "ewiki_format_final_deflistanchors";
9 function ewiki_format_final_deflistanchors(&$html) {
10    $words = array();
11    $html = preg_replace(
12       '#<dt>([_\w\s]+)</dt>#me',
13       '"<dt><a name=\"" . strtr($words[]="$1", " ", "_") . "\">$1</a></dt>"',
14       $html
15    );
16    if ($words) {
17       $html = preg_replace(
18          '#(?<!>)(' . implode("|", $words) . ')(?![<"])#e',
19          '"<a href=\"#" . strtr("$1", " ", "_") . "\">$1</a>"',
20          $html
21       );
22    }
23 }
24
25 ?>