Emphasis Description

Compatible with DokuWiki

No compatibility info given!

plugin Three degrees of text highlighting

Last updated on
2007-02-09
Provides
Syntax

The following security issue was reported for this plugin: XSS vulnerability allows arbitrary JavaScript insertion. Author informed on 2008-03-29.

It is not recommended to use this plugin until this issue was fixed. Plugin authors should read the plugin security guidelines

Similar to highlight, hilited, wrap

Tagged with colors, highlight, marking

This plugin enables three different ways of highlighting. Each one maps to a css class attribute meaning the style can be freely defined in the style sheet. This is similar to hilited and highlight with the difference that it allows three degrees of highlighting. -stefan

Usage

::text::
:::text:::
::::text::::

Installation

Point your Plugin Manager to this URL: emphasis-plugin-2007-02-09.zip. This automatically downloads, unzips and installs the plugin.

To style the three different highlights set up your CSS like this:

span.emphasis1 {font-weight:bold; color:#ff0033}
span.emphasis2 {font-weight:bold; color:#009700}
span.emphasis3 {font-weight:bold; color:#ff1a55}

Source Code

syntax.php

<?php
/**
 * Emphasis Plugin: Enables text highlighting with 
 *                  ::text::, :::text:::, ::::text::::
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Stefan Hechenberger <foss@stefanix.net>
 */
 
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_emphasis extends DokuWiki_Syntax_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'Stefan Hechenberger',
            'email'  => 'foss@stefanix.net',
            'date'   => '2007-02-09',
            'name'   => 'Emphasis Plugin',
            'desc'   => 'Enables different levels of highlighted text',
            'url'    => 'http://www.dokuwiki.org/plugin:emphasis',
        );
    }
 
    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }
 
 
    /**
     * Where to sort in?
     */ 
    function getSort(){
        return 922;
    }
 
 
    /**
     * Connect pattern to lexer
     */
    function connectTo($mode) {
      $this->Lexer->addSpecialPattern(':{2,4}.*?:{2,4}',$mode, substr(get_class($this), 7));
    }
 
 
    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        if((substr($match, 0, 4) == '::::') and (substr($match, -4, 4) == '::::')) {
            $deg = 3;
            $emtext = substr(substr($match, 4), 0, -4);
        } else if((substr($match, 0, 3) == ':::') and (substr($match, -3, 3) == ':::')) {
            $deg = 2;
            $emtext = substr(substr($match, 3), 0, -3);            
        } else if((substr($match, 0, 2) == '::') and (substr($match, -2, 2) == '::')) {
            $deg = 1;
            $emtext = substr(substr($match, 2), 0, -2);            
        } else {
            $emtext = $match;
            $deg =1;   
        }
        return array($emtext, $deg);
    }            
 
 
     /**
     * Create output
     */
    function render($mode, &$renderer, $data) {
        list($emtext, $deg) = $data;
        if($mode == 'xhtml'){
            $renderer->doc .= '<span class="emphasis'.$deg.'">'.$emtext.'</span>';
            return true;
        }
        return false;
    }
 
 
 
}

Issues

  • The standard wiki markups do not work within an emphasized span element. — Kenneth Forsbäck, kenna(at)flonne(dot)org, 2007-04-07 6:09 PM
plugin/emphasis.txt · Last modified: 2011/06/18 16:26 by ach
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate