Enclose a text within hashes and it generates a <span class="important" /> around it.
Compatible with DokuWiki
No compatibility info given!
Plugin name contains underscore, will not generate popularity points.
Similar to important_paragraf, wrap
##.##important.## and an optional |.The following:
This is a text with ##an important## part.
Is converted to HTML as:
<p>This is a text with <span class="important">an important</span> part.</p>
The following:
This is a ##marker|marked## word.
is converts to HTML as:
<p>This is a <span class="marker">marked</span> word.</p>
For the look and feel, optionally add the following code to your template's design.css file (if the name of your template is default, then it is in lib/tpl/default/design.css, also copy it to lib/tpl/default/print.css for the printing):
Tip: you can also create a CSS file in lib/plugins/important_text/style.css
.important { background-color: __light__; border: 1px solid __dark__; } div.important { margin: 0.75em 0 1em 0; padding: 0.2em; } div.important div { padding:0; margin: 0; } div.important > div + div { padding:0; margin: 0.5em 0 0 0; } .important > .important { background-color: __dark__; border: 1px solid __black__; } span.marker { border-left: 1em solid yellow; }
The “marker” class in the last section marks a text like marked with a yellow text-marker, if you write:
##marker|This text is like marked with a yellow text-marker.##
To install the functionality, copy the following code into a new file named lib/plugins/important_text/syntax.php:
<?php 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'); /** Important Text - Mark a text with a class. Marks important text: An important text is enclosed by with ##text##. It is marked with <span class="important" /> If you want to mark it as <span class="anything" />, mark your text as: ##anything|This is the Text## License: GPL */ class syntax_plugin_important_text extends DokuWiki_Syntax_Plugin { function getInfo() { return array('author' => 'Marc Wäckerlin', 'email' => 'marc [at] waeckerlin [dot-org]', 'name' => 'Important Text', 'desc' => 'mark: !!!!This is important!!!!', 'url' => 'http://marc.waeckerlin.org'); } function getType() { return 'substition'; } function getSort() { return 1; } function accepts($mode) { if (!count($this->allowedModes)) { global $PARSER_MODES; $this->allowedModes = array_merge($PARSER_MODES['container'], $PARSER_MODES['baseonly'], $PARSER_MODES['formatting'], $PARSER_MODES['substition'], $PARSER_MODES['protected'], $PARSER_MODES['disabled'], $PARSER_MODES['paragraphs']); } return parent::accepts($mode); } function connectTo($mode) { $this->Lexer->addEntryPattern('##[a-z]+\|(?=[^\n]*##)', $mode, 'plugin_important_text'); $this->Lexer->addEntryPattern('##(?=[^\n]*##)', $mode, 'plugin_important_text'); } function postConnect() { $this->Lexer->addExitPattern('##', 'plugin_important_text'); } function handle($match, $state, $pos, &$handler) { return array($match, $state); } function render($format, &$renderer, $data) { list($match, $state) = $data; switch ($state) { case DOKU_LEXER_ENTER: { if (strlen($match)>3) $class=substr($match, 2, strlen($match)-3); else $class='important'; $renderer->doc .= '<span class="'.$class.'">'; } return true; case DOKU_LEXER_EXIT: { for ($i=0; $i<strlen($match)-4; ++$i) $renderer->doc .= $match[$i]; $renderer->doc .= '</span>'; } return true; case DOKU_LEXER_MATCHED: return true; case DOKU_LEXER_UNMATCHED: { $renderer->doc .= htmlspecialchars($match); } return true; } return false; } } ?>
The divalign's justify markup is broken by this plugin (due to formatting between ###...###). – Wonko