Compatible with DokuWiki
2006-11-06; 2007-06-26
Plugin name contains underscore, will not generate popularity points.
This source code may not be up to date. This is posted here, just in case the link above will be broken.
File: syntax.php
<?php /** * French typography plugin * Adds non-breaking spaces where needed by French typography rules . * GPL 2 (http://www.gnu.org/licenses/gpl.html) * Philippe Debar */ 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'); class syntax_plugin_frenchtypo extends DokuWiki_Syntax_Plugin { function getInfo(){ return array( 'author' => 'Philippe Debar', 'date' => '2007-01-27', 'name' => 'French Typography', 'desc' => 'Adds non-breaking spaces where needed by French typography rules .', 'url' => 'http://www.notamment.be/dokuwiki/plugin/frenchtypo', ); } // Substitution type - with required back-compatibility typo ;o) function getType(){ return 'substition'; } // No nested modes allowed -> use default getAllowedTypes() {return array();} // Can be used inside paragraphs -> use defautl getPType() {return 'normal';} // When to apply - should experiment with this ? function getSort(){ return 245; } function connectTo($mode) { $this->Lexer->addSpecialPattern(' (?=[!?:;»])',$mode,'plugin_frenchtypo'); $this->Lexer->addSpecialPattern(' (?=»)',$mode,'plugin_frenchtypo'); $this->Lexer->addSpecialPattern('(?<=«) ',$mode,'plugin_frenchtypo'); $this->Lexer->addSpecialPattern('(?<=«) ',$mode,'plugin_frenchtypo'); $this->Lexer->addSpecialPattern('[<]{2} ',$mode,'plugin_frenchtypo'); $this->Lexer->addSpecialPattern(' >>',$mode,'plugin_frenchtypo'); } function handle($match, $state, $pos, &$handler){ if ($state==DOKU_LEXER_SPECIAL){ switch ($match) { case ' ': return ' '; case '<< ': return '« '; case ' >>': return ' »'; } } return $match; } function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ $renderer->doc .= $data; return true; } return false; } } ?>