plugin:side_note
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
plugin:side_note [2006-11-13 14:41] – 205.252.23.3 | plugin:side_note [2012-11-20 23:37] – Klap-in | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Definition Side Note ====== | ||
+ | |||
+ | ---- plugin ---- | ||
+ | description: | ||
+ | author | ||
+ | email : stephane.chamberland@ec.gc.ca | ||
+ | type : syntax | ||
+ | lastupdate : 2005-07-04 | ||
+ | compatible : | ||
+ | depends | ||
+ | conflicts | ||
+ | similar | ||
+ | tags : boxes, caption, !experimental | ||
+ | ---- | ||
+ | |||
+ | |||
+ | [[: | ||
+ | |||
+ | ===== Description ===== | ||
+ | |||
+ | With this plugin the [[: | ||
+ | |||
+ | < | ||
+ | <side left> | ||
+ | <side right> | ||
+ | |||
+ | Personally, I use it mainly to add a caption at the bottom of images: | ||
+ | |||
+ | <side left> | ||
+ | |||
+ | |||
+ | example: | ||
+ | |||
+ | <side right> | ||
+ | |||
+ | ===== Style ===== | ||
+ | |||
+ | To make it work you will need also to add some rules into your template' | ||
+ | |||
+ | <code css style.css> | ||
+ | .sideboth, .sideleft, .sideright { | ||
+ | border: 1px solid; | ||
+ | float:left; | ||
+ | clear: both; | ||
+ | text-align: center; | ||
+ | } | ||
+ | |||
+ | .sideboth { | ||
+ | display: block; | ||
+ | width: 100%; | ||
+ | } | ||
+ | |||
+ | .sideright { | ||
+ | float: | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Plugin ===== | ||
+ | |||
+ | Put the following PHP file in ''/ | ||
+ | |||
+ | <code php syntax.php> | ||
+ | <?php | ||
+ | /** | ||
+ | * Add SideNote capability to DokuWiki | ||
+ | * < | ||
+ | * <side left> | ||
+ | * <side right> | ||
+ | * | ||
+ | * @license | ||
+ | * @author | ||
+ | */ | ||
+ | |||
+ | if(!defined(' | ||
+ | if(!defined(' | ||
+ | require_once(DOKU_PLUGIN.' | ||
+ | |||
+ | /** | ||
+ | * All DokuWiki plugins to extend the parser/ | ||
+ | * need to inherit from this class | ||
+ | */ | ||
+ | class syntax_plugin_sidenote extends DokuWiki_Syntax_Plugin { | ||
+ | |||
+ | /** | ||
+ | * return some info | ||
+ | */ | ||
+ | function getInfo(){ | ||
+ | return array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Constructor - adds allowed modes | ||
+ | */ | ||
+ | function syntax_plugin_sidenote(){ | ||
+ | global $PARSER_MODES; | ||
+ | $this-> | ||
+ | $PARSER_MODES[' | ||
+ | $PARSER_MODES[' | ||
+ | $PARSER_MODES[' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * What kind of syntax are we? | ||
+ | */ | ||
+ | function getType(){ | ||
+ | //return ' | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Paragraph Type | ||
+ | * | ||
+ | * Defines how this syntax is handled regarding paragraphs. This is important | ||
+ | * for correct XHTML nesting. Should return one of the following: | ||
+ | * | ||
+ | * ' | ||
+ | * ' | ||
+ | * ' | ||
+ | * | ||
+ | * @see Doku_Handler_Block | ||
+ | */ | ||
+ | function getPType(){ | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Where to sort in? | ||
+ | */ | ||
+ | function getSort(){ | ||
+ | return 155; | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Connect pattern to lexer | ||
+ | */ | ||
+ | function connectTo($mode) { | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | } | ||
+ | function postConnect() { | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Handle the match | ||
+ | */ | ||
+ | function handle($match, | ||
+ | switch ( $state ) { | ||
+ | case DOKU_LEXER_ENTER: | ||
+ | if (preg_match('/ | ||
+ | return array('', | ||
+ | } else if (preg_match('/ | ||
+ | return array('', | ||
+ | } else { | ||
+ | return array('', | ||
+ | } | ||
+ | break; | ||
+ | case DOKU_LEXER_UNMATCHED: | ||
+ | //$matches = preg_split('/>/ | ||
+ | // | ||
+ | // | ||
+ | //return array($matches[1], | ||
+ | return array($match, | ||
+ | break; | ||
+ | } | ||
+ | return array('', | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Create output | ||
+ | */ | ||
+ | function render($mode, | ||
+ | if($mode == ' | ||
+ | if ($data[1] == DOKU_LEXER_ENTER){ | ||
+ | if ($data[2] == ' | ||
+ | $renderer-> | ||
+ | } else if ($data[2] == ' | ||
+ | $renderer-> | ||
+ | } else { | ||
+ | $renderer-> | ||
+ | } | ||
+ | } else if ($data[1] == DOKU_LEXER_UNMATCHED){ | ||
+ | $renderer-> | ||
+ | } else if ($data[1] == DOKU_LEXER_EXIT){ | ||
+ | $renderer-> | ||
+ | } | ||
+ | return true; | ||
+ | } | ||
+ | return false; | ||
+ | |||
+ | if($mode == ' | ||
+ | return true; | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | //Setup VIM: ex: et ts=4 enc=utf-8 : | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Comments ===== | ||
+ | > For efficiency, I would think you can simplify the entry pattern, to a single < | ||
+ | |||
+ | I disagree --- a better pattern would be '' | ||
+ | |||
+ | >> I always knew there was a way, but that it was beyond my regex expertise :-) (\x3c & \x3e changes to < > since parser has been patched to support them) --- // | ||
+ | |||
+ | >This plugin slightly breaks the < | ||
+ | |||
+ | > | ||
+ | > - Type is now back to ' | ||
+ | > - The PType is now ' | ||
+ | > - The entry pattern is the one given in reply to ChrisS' | ||
+ | > - In the functions render() and handle I removed the //if{}else if{}else{}// | ||
+ | > - In the function handle() I replaced: <code php> | ||
+ | if (preg_match('/ | ||
+ | return array('', | ||
+ | } else if (preg_match('/ | ||
+ | return array('', | ||
+ | } else { | ||
+ | return array('', | ||
+ | } | ||
+ | </ | ||
+ | preg_match('/< | ||
+ | return array('', | ||
+ | </ | ||
+ | > | ||
+ | > - Added ' | ||
+ | > - A few cosmetic changes to the CSS so that the background was a solid color and there was a bit of padding & margin. | ||
+ | > --- // [[adam@alphacomplex.org|adam]] 2006-08-16 11:42 // | ||
+ | |||
+ | > I just got an email asking for my changes to this plugin and I figured that if I was going to create a patch I may as well post it here. Feel free to download my [[http:// | ||
+ | > --- // [[adam@alphacomplex.org|adam]] 2006-12-15 09:22 // | ||
+ | |||
+ | > This plugin has helped me out significantly, | ||
+ | > --- // [[sam@samuelmiller.biz|sam]] 2010-12-31 13:03 // |
plugin/side_note.txt · Last modified: 2013-03-06 15:42 by Klap-in