DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:french_typography

French Typography plugin

Compatible with DokuWiki

2007-06-26

plugin Respect French typographical rules for non-breaking spaces.

Last updated on
2007-01-27
Provides
Syntax

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Extension name contains underscore, will not generate popularity points.

Tagged with language, typography

Details and Download

Code

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;
    }
}
?>
plugin/french_typography.txt · Last modified: 2023-10-30 22:56 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki