====== Mark a Paragraf ====== ---- plugin ---- description: Start a paragraph with two exclamation marks, and it generates a
around it. author : Marc Wäckerlin email : marc@waeckerlin.org type : syntax lastupdate : 2006-01-20 compatible : depends : conflicts : similar : importanttext tags : boxes style ---- ===== Syntax ===== * Starts with ''%%!!%%'' at the begin of a paragraph. * Ends with a single newline. * May be continued, if there are two spaces before the newline. * A class name can optionally be given: * Default class name is ''%%important%%''. * Class name is between the ''%%!!%%'' and an optional ''%%|%%''. * Class name must be all lower case ASCII characters. ===== Examples ===== The following:
!!This is the simplest use.
Is converted to HTML as:
This is the simplest use.
The following (spaces are written as ''%%·%%'', because they are not visible otherwise):
!!classname|This is a paragraph, up to the newline··
* This is a list item inside the important··
* Please note the two spaces at the end of these lines··
This is another paragraph inside the same
!!marker|This is a new paragraph outside with class name "marker".
is converted to HTML as:
This is a paragraph, up to the newline
- This is a list item inside the important
- Please note the two spaces at the end of these lines
This is another paragraph inside the same <div class="important" />
This is a new paragraph outside with class name "marker".
===== Installation =====
==== Optional CSS Definition ====
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):
.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__;
}
div.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 paragraph is like marked with a yellow text-marker.
==== The Template's PHP Code ====
To install the functionality, copy the following code into a new file named ''lib/plugins/important_paragraf/syntax.php'':
'Marc Wäckerlin',
'email' => 'marc [at] waeckerlin [dot-org]',
'name' => 'Important Paragraf',
'desc' => 'mark paragrafs as !!importtant',
'url' => 'http://marc.waeckerlin.org');
}
function getType() {
return 'container';
}
function getSort() {
return 2;
}
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']);
unset($this->allowedModes[array_search('preformatted',
$this->allowedModes)]);
}
return parent::accepts($mode);
}
function connectTo($mode) {
$this->Lexer->addEntryPattern('^ *\!\![a-z]+\|', $mode,
'plugin_important_paragraf');
$this->Lexer->addEntryPattern('^ *\!\!', $mode,
'plugin_important_paragraf');
}
function postConnect() {
$this->Lexer->addPattern(' (?= \n)',
'plugin_important_paragraf');
$this->Lexer->addExitPattern('(?3)
$class=substr($match, 2, strlen($match)-3);
else
$class='important';
$renderer->doc .= '';
} return true;
case DOKU_LEXER_EXIT: {
$renderer->doc .= '';
} return true;
case DOKU_LEXER_MATCHED: {
$renderer->doc .= '';
return true;
}
case DOKU_LEXER_UNMATCHED: {
$renderer->doc .= htmlspecialchars($match);
} return true;
}
return false;
}
}
?>
===== Known Bugs =====
==== plugin management error? ====
> 2006-05-14: I think, it doesn't work in the newest DokuWiki - Plugin Management says: //This plugin returned no information, it may be invalid.//
Seems to work for me. -- [[wonko@wonkology.org|Wonko]]
How about an example on this page, so we don't have to download and install it to see what it looks like?
Why don't you offer a package for quick installation? -- Philipp
I might host one on my github or bitbucket account, if it's a feature that is really wanted, and Marc is OK with it... -- xav0989
===== ChangeLog =====
* //2006-01-20 mrw//
* initial release