<?php if (!defined('PmWiki')) exit(); /** \file footnote.php * \brief handle footnotes in a page * * AWColley 2007-08-05 -- created * Extracted from extendmarkup.php Version 2.0.59 * (see http://www.pmwiki.org/wiki/Cookbook/MarkupExtensions) * * Copyright 2007 A. W. Colley * You may use this file however you see fit. I don't care. * * ExtendedMarkup.php Copyright 2004-2006 John Rankin (john.rankin@affinity.co.nz) * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * THIS SOFTWARE IS PROVIDED AS IS WITHOUT ANY GUARANTEES FOR SUITABLILITY FOR * ANY PURPOSE. THE COPYRIGHT HOLDERS ARE NOT RESPONSIBLE FOR ANY DAMAGES, WHETHER * DIRECT, INDIRECT, OR TOTALLY UNRELATED THAT MAY ACCOMPANY, RESULT FROM, OR FOR * ANY REASON OCCUR AFTER THE USE OF, PERUSAL OF, OR THINKING ABOUT THIS SOFTWARE. * * * If you don't like the thin blue line, change it in the "div.footnote" style * below. */ define( FOOTNOTE_VERSION, '1.0.0' ); $HTMLStylesFmt['extend'] = " div.footnote { width: 160px; border-bottom: 1px solid blue; margin-bottom: 0.5em; } p.footnote { text-indent: -1em; margin-right: 3em; margin-left: 3em; margin-top: 0px; margin-bottom: 0.5em; font-size: smaller; } a.footnote { font-size: smaller; } "; // [^footnote text^] and [^#^] to list footnotes // includes a style to tidy line spacing Markup( "Footnote", '>links', '/\[\^(.*?)\^\]/e', "Footnote('$1')" ); Markup( "FootnoteList", '<Footnote', '/^\[\^#\^\]$/e', "'<:block>'.Footnote('#')" ); Markup( "EndnoteList", '<Footnote', '/^\[\^@\^\]$/e', "'<:block>'.Footnote('@')" ); function Footnote( $foottext ) { static $fngroup, $fncount, $fntext; if ($foottext == "#") { $fncount = 0; $fngroup++; $r = "<div class='footnote'> </div>$fntext"; $fntext = ''; } else if ($foottext == "@") { $fncount = 0; $fngroup++; $r = "$fntext"; $fntext = ''; } else { $fncount++; $fnid = $fngroup+1 . '_' . $fncount; $r = "<sup><a class='footnote' href='#fn$fnid'>$fncount</a></sup>". "<a name='fnr$fnid' id='fnr$fnid'></a>"; $foottext = stripslashes( $foottext ); $fntext .= "<p class='footnote'><a name='fn$fnid' id='fn$fnid'></a>"; $fntext .= "<sup>$fncount</sup> $foottext <a href='#fnr$fnid'>⇑</a></p>"; } return $r; }