====== In and Out Plugin ====== ---- plugin ---- description: Enables a simple mark-up syntax for showing text edits being inserted or deleted from your wiki pages. author : Timothy Martin email : instanttim@mac.com type : syntax lastupdate : 2006-01-09 compatible : depends : conflicts : similar : tags : typography, highlight ---- ===== Background ===== ''%% ... %%'' is part of standard DokuWiki syntax. There is also a plugin which provides insert syntax. For me, I wanted something better for two reasons: - Because of the frequency which I use these features - Standard HTML tags severely limit the readability of the page when editing, Feel free to play with it on my [[http://design1st.org/wiki/doku.php?id=wiki:playground|playground]] if you'd like.. ===== Installation ===== You can use the plugin-manager to install this plugin. The URL is [[http://design1st.org/files/dokuwiki-plugin_inandout.tgz]]. ===== Syntax ===== You simply put a "-" on both sides of the text you want to appear deleted or a "+" for it to appear inserted. The trick is that there can never be a space between the +/- and the text you are inserting/deleting. Despite this it deals with text that includes spaces and is smart enough to not be fooled by hyphenated words or phone numbers etc. ===== Example ===== Input (Plain Text): Text that you wish to be deleted should be -indicated like this- where as text that is inserted is +indicated like this+. Output (HTML): Text that you wish to be deleted should be indicated like this where as text that is inserted is indicated like this. ===== Plugin ===== Put this code into /inandout/syntax.php 'Timothy Martin', 'email' => 'instanttim@mac.com', 'date' => '2006-01-09', 'name' => 'In and Out Plugin', 'desc' => 'Enables a custom mark-up for inserted and deleted text.', 'url' => 'http://www.dokuwiki.org/plugin:inandout', ); } /** * What kind of syntax are we? */ function getType(){ return 'formatting'; } /** * What kind of syntax do we allow (optional) */ function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); } /** * Where to sort in? */ function getSort(){ return 137; } /** * Connect pattern to lexer */ function connectTo($mode) { // This is the regex i used to use... // // /\B(-)(?!\s)(.*)(?Lexer->addEntryPattern('(?<=\B)-(?!\s)(?=.*\w-\B)',$mode,'plugin_inandout'); $this->Lexer->addEntryPattern('(?<=\B)\+(?!\s)(?=.*\w\+\B)',$mode,'plugin_inandout'); } function postConnect() { $this->Lexer->addExitPattern('(?Lexer->addExitPattern('(?doc .= "<".$match.">"; break; case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($match); break; case DOKU_LEXER_EXIT : $renderer->doc .= ""; break; } return true; } return false; } } ?> ===== Bugs ===== * I have found a bug where the minus sign in quotes will screw it up. ===== Discussion ===== Some notes: * ''%% ... %%'' is part of standard DokuWiki syntax. There is also a plugin which provides '''' insert syntax. It would be handy to indicate that your syntax is an alternative to these other forms. Done! * This really should be done as two plugin components, one for //insert// and another for //delete//. Take a look at either the [[plugin:bbcode]] or [[plugin:code]] plugins for an example of a single plugin with multiple components. Why do you need that? Because each of your entry patterns has a different exit pattern. If you don't have multiple plugin/components a '- ' can cause an exit from //insert// syntax and a '+ ' from //delete//. * You should add a look ahead to ensure there is a matching exit pattern for the entry pattern. \\ e.g. ''%%(?<=\B)-(?>=[^ \r\n].+?[^ \r\n]-[ \r\n])%%''. Done! * If you don't want to allow line breaks within your plugin use ''[^\n\r]'' instead of '.' in your look ahead for an ending pattern. I changed my mind about this... since default DokuWiki ignores linebreaks, I figure I should too. I hope this help some. --- //[[chris@jalakai.co.uk|Christopher Smith]] 2005-11-30 20:52// If you install this plugin, you're going to want to fix your "wiki:syntax" page as a sizable portion of the bottom of this page is striked out. :-( --- //[[garyv@rochester.rr.com|GaryV]] 2006-06-30 08:30// This plugin seems to break my wiki:syntax page completely. All that displays is the "You are here" box at the top of the page. I like this plugin, but I can't use it. --- //[[lenehey]] 2007-12-21 9:48//