<?php ## this tests footnotes ## ## Copyright 2003 John Rankin john.rankin@affinity.co.nz $HTMLHeaderFmt .= "<style type = 'text/css'> hr.footnote { width: 30%; } p.footnote { text-indent: -1em; margin-right: 3em; margin-left: 3em; margin-top: 0em; margin-bottom: 0.5em; font-size: smaller; } </style>"; $IdPattern = "[A-Za-z][-.:_A-Za-z0-9]*"; $DoubleBrackets["/\\[\\^#($IdPattern)\\^\\]/e"] = 'shortcut($text,"$1");'; $DoubleBrackets["/\\[\\^(.*?)\\^\\]/e"] = 'footnote("$1");'; function footnote($foottext) { static $fncount, $fntext; if ($foottext == "#") { $fncount = 0; $r = "<hr class='footnote' />$fntext"; $fntext = ''; } else { $fncount++; $r = "<sup><a href='#fn$fncount'>$fncount</a></sup>"; $foottext = stripslashes($foottext); $fntext .= "<p class='footnote'><a name='fn$fncount'><sup>$fncount</sup></a> $foottext</p>"; } return $r; } function shortcut($text,$anchor) { $text .= "\n"; if (preg_match("/\\[\\[#$anchor\\]\\]\\n?(.*?)\\n/",$text,$match)) { return preg_replace("/^[#*!:]+\s*/","",$match[1]); } else { return "'''$anchor''' not found."; } } ?>