*/ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); // we inherit from the XHTML renderer instead directly of the base renderer require_once DOKU_INC.'inc/parser/xhtml.php'; /** * Footnotetypo renderer */ class renderer_plugin_footnotestyle extends Doku_Renderer_xhtml { /** * the format we produce */ function getFormat(){ return 'xhtml'; } /** * This makes it possible to use as the default xhtml renderer */ function canRender($format) { return ($format=='xhtml'); } /** * Callback for footnote end syntax * * All rendered content is moved to the $footnotes array and the old * content is restored from $store again * * @author Andreas Gohr * @author Viktor Söderqvist */ function footnote_close() { // recover footnote into the stack and restore old content $footnote = $this->doc; $this->doc = $this->store; $this->store = ''; $amal = $this->getConf('amalgamate'); if ($amal != 'off') { // check to see if this footnote has been seen before $i = array_search($footnote, $this->footnotes); if ($i === false) { // its a new footnote, add it to the $footnotes array $id = count($this->footnotes)+1; $this->footnotes[count($this->footnotes)] = $footnote; } else { // seen this one before, translate the index to an id and save a placeholder $i++; $id = count($this->footnotes)+1; $this->footnotes[count($this->footnotes)] = "@@FNT".($i); } } else { // don't use amalgamated footnotes. // every note is considered a new footnote. add it to the $footnotes array $id = count($this->footnotes)+1; $this->footnotes[count($this->footnotes)] = $footnote; } // output the footnote reference and link $this->doc .= $this->_format_footnote_link($id); } /** * Some modification to the document_end regarding the footnotes */ function document_end() { if ( count ($this->footnotes) > 0 ) { $this->doc .= '
\s*
#','',$this->doc); } function _format_footnote_link($id) { $style = $this->getConf('style'); // the number of the footnote $link = $id; // formatting around the number if ($style=='square' || $style=='supersquare') $link = '['.$link.']'; elseif ($style=='rightparen') $link .= ')'; // the link itself $link = ''.$link.''; // superscript around the link if ($style=='super' || $style=='rightparen' || $style=='supersquare') $link = ''.$link.''; return $link; } function _format_footnote_bottomlink($id) { $style = $this->getConf('stylebottom'); $link = $id; if ($style=='superrightparen') $link .= ')'; elseif ($style=='square' || $style=='supersquare') $link = '['.$link.']'; $link = ''.$link.''; if ($style=='super' || $style=='superrightparen' || $style=='supersquare'){ $link = ''.$link.''; }else{ $link = ''.$link.''; } return $link; } }