Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Compatible with DokuWiki
No compatibility info given!
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.
This is a simple plugin to add a class to a content. It prevents to use
<html></p><div class="myStyleClass"><p></html> This is my content. <html></p></div><p></html>
Just use this syntax and change “myStyleClass” by your class.
<class myStyleClass>This is my content.</class>
Put the following PHP file in /lib/plugins/class/syntax.php
<?php /** * Plugin class : add a class to a content * * Syntax: <class myStyleClass>content</class> * * @author Janusz <janusz@ledruide.net> * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) */ 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_class extends DokuWiki_Syntax_Plugin { /** * Get an associative array with plugin info. */ function getInfo(){ return array( 'author' => 'Janusz', 'email' => 'janusz@ledruide.net', 'date' => '2008-12-15', 'name' => 'class Plugin', 'desc' => 'Simple plugin to add a class to a content', 'url' => 'http://www.dokuwiki.org/plugin:class', ); } function getType(){ return 'container'; } function getPType(){ return 'normal'; } function getAllowedTypes() { return array('container','substition','protected','disabled','formatting','paragraphs'); } // must return a number lower than returned by native 'code' mode (200) function getSort(){ return 158; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addEntryPattern('<class.*?>(?=.*?</class>)',$mode,'plugin_class'); } function postConnect() { $this->Lexer->addExitPattern('</class>','plugin_class'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ switch ($state) { case DOKU_LEXER_ENTER: $data = strtolower(trim(substr($match,6,-1))); return array($state, $data); case DOKU_LEXER_UNMATCHED : return array($state, $match); case DOKU_LEXER_EXIT : return array($state, ''); } return false; } /** * output */ function render($mode, &$renderer, $indata) { if($mode == 'xhtml'){ list($state, $match) = $indata; switch ($state) { case DOKU_LEXER_ENTER : $renderer->doc .= '</p><div class="'.htmlspecialchars($match).'"><p>'; break; case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($match); break; case DOKU_LEXER_EXIT : $renderer->doc .= "</p></div><p>"; break; } return true; } return false; } } //Setup VIM: ex: et ts=4 enc=utf-8 : ?>
$match to htmlspecialchars($match) to prevent some malicious code.How can I define font and other attributes of my class? Can it work in another pages?
It is not boxes? I cannot use <class class1><class class2>Something</class>Something</class>