I just received an email with the idea to have a simple syntax to add footnotes similar to MediaWiki and DokuWiki. The idea is to just write [[footnote text]] somewhere in the page content, and let CMSimple_XH turn that into a proper footnote. The following addition to cmsimple/userfuncs.php is supposed to do the trick:
Code: Select all
function convertFootnotes()
{
global $s, $c, $su;
$i = $s > -1 ? $s : 0;
$count = preg_match_all(
'/\[\[(.*)\]\]/U', $c[$i], $matches, PREG_SET_ORDER
);
if ($count) {
$c[$i] .= '<div class="footnotes">';
foreach ($matches as $j => $match) {
$c[$i] = str_replace(
$match[0],
'<sup><a href="#footnote' . ($j + 1)
. '">[' . ($j + 1) . ']</a></sup>',
$c[$i]
);
$c[$i] .= '<div id="footnote' . ($j + 1) . '">'
. ($j + 1) . '. ' . $match[1] . '</div>';
}
$c[$i] .= '</div>';
}
}
if (!(XH_ADM && $edit)) {
convertFootnotes();
}
PS: slightly edited for ungreedy matching, see below for an explanation.
PPS: Enclosed all footnotes in <div class="footnote">; see below.