Forces ('suggests') a pagebreak after the line where a <pagebreak> tag is inserted
This plugin inserts a 'suggested' pagebreak when printing a wiki page. Nothing new is visible from a browser. This seemed like a much needed addition to DokuWiki, since the main use of DokuWiki is documentation. This is intended to help in the creation of hard-copies of a wiki, possibly with some sort of pdf/ps/gs printer.
Insert a <pagebreak> tag on a line by itself where you want a pagebreak. Check with print preview.
<?php /** * Plugin Tab: Inserts a pagebreak into the document for every <pagebreak> it encounters. Based on the tab plugin by Tim Skoch <timskoch@hotmail.com> * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Jonathan McBride and Chris Sturm - The University of Texas at Austin * */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_pagebreak extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Jonathan McBride and Chris Sturm', 'email' => 'j.mcbride@mail.utexas.edu', 'date' => '2007-08-08', 'name' => 'Pagebreak Plugin', 'desc' => 'Inserts " <br style="page-break-after:always;"> " into the html of the document for every <pagebreak> it encounters', 'url' => 'NA', ); } /** * What kind of syntax are we? */ function getType(){ return 'substition'; } /** * What kind of syntax do we allow (optional) */ // function getAllowedTypes() { // return array(); // } /** * What about paragraphs? (optional) */ // function getPType(){ // return 'normal'; // } /** * Where to sort in? */ function getSort(){ return 999; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('<pagebreak>',$mode,'plugin_pagebreak'); // $this->Lexer->addEntryPattern('<TEST>',$mode,'plugin_test'); } // function postConnect() { // $this->Lexer->addExitPattern('</TEST>','plugin_test'); // } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ switch ($state) { case DOKU_LEXER_ENTER : break; case DOKU_LEXER_MATCHED : break; case DOKU_LEXER_UNMATCHED : break; case DOKU_LEXER_EXIT : break; case DOKU_LEXER_SPECIAL : break; } return array(); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ $renderer->doc .= "<br style=\"page-break-after:always;\">"; // ptype = 'normal' // $renderer->doc .= "<p>Hello World!</p>"; // ptype = 'block' return true; } return false; } } //Setup VIM: ex: et ts=4 enc=utf-8 :
The above code is included in this zip file, which can be imported via the plugin manager. To install manually, create a new folder “lib/plugins/pagebreak”, and create a file “syntax.php” with the above code as its contents.
This plugin is hugely based on the tab plugin by Tim Skoch. A good 90% of this is probably his untouched code. Many thanks to Tim for giving us a starting point for this plugin.