This plugin provides the ability to put comment only visible when you edit the page.
Compatible with DokuWiki
No compatibility info given!
Similar to comment, htmlcomment, wrap
Just put your comment between !- and -!:
!-I love dokuwiki-!
You can install it with plugin manager ⇒ http://dokuplugins.idotech.info/commentsrc.zip
Or just download the .zip and uncompress it in “lib/plugins”
lib/plugins/commentsrc/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'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_commentsrc extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'iDo', 'email' => 'iDo@woow-fr.com', 'date' => '14/12/2005', 'name' => 'commentsrc Plugin', 'desc' => 'Make texte only visible when editing a page', 'url' => 'http://www.dokuwiki.org/plugin:commentsrc', ); } /** * What kind of syntax are we? */ function getType(){ return 'substition'; } /** * Where to sort in? */ function getSort(){ return 51; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern("!-.*-!",$mode,'plugin_commentsrc'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ return true; } /** * Create output */ function render($mode, &$renderer, $data) { return true; } } //Setup VIM: ex: et ts=4 enc=utf-8 : ?>
There is already another plugin which does just that: Comment. The only difference is the markup, /* hidden comment */ as in many programming languages. — Esther Brunner 2005-12-14 16:33
Oups sorry, that's right :) i didn't see it :/
I cannot get this to work in DokuWiki-2005-09-22. The complete comment, plus the surrounding tags, is visible on the page. (I cannot get Hidden Comment to work either.) — Chris Lale 2005-12-15 13:53
You say in the instructions to use != and =! for comments when it should be !- and -!
Hi. I propose the fix of A. This patch has the following effects.
plugin_commentsrc can use !- -! besides /* */.I like this plugin because the light weight.
--- lib/plugins/commentsrc/syntax.php.orig 2005-12-14 14:40:20.000000000 +0900 +++ lib/plugins/commentsrc/syntax.php 2006-08-01 20:31:45.000000000 +0900 @@ -42,9 +42,18 @@ * Connect pattern to lexer */ function connectTo($mode) { - $this->Lexer->addSpecialPattern("!-.*-!",$mode,'plugin_commentsrc'); + $this->Lexer->addEntryPattern("!-", $mode, 'plugin_commentsrc'); + $this->Lexer->addEntryPattern("/\*", $mode, 'plugin_commentsrc'); } - + + /** + * Release pattern to lexer + */ + function postConnect() { + $this->Lexer->addExitPattern("-!", 'plugin_commentsrc'); + $this->Lexer->addExitPattern("\*/", 'plugin_commentsrc'); + } + /** * Handle the match */ @@ -62,4 +71,4 @@ } //Setup VIM: ex: et ts=4 enc=utf-8 : -?> \ No newline at end of file +?>
— Kohei MATSUSHITA 2006-08-01 20:45 JST
Kohei is right. The .* part in the pattern "!-.*-!" would eat as much as possible, thus eating the text between two comments:
!- comment -! Disappearing text !- comment again -!
Esther's plugin is using .*? which matches “as little as possible”. This is (i think) equivalent to Kohei's solution with entrypattern and exitpattern. — 2
I patched it (by hand) with Kohei MATSUSHITA's notes (didn't get Esther 'comment' plugin working), and I used "[^A-Za-z0-9_-]/\*" instead of ”/\*” because I noticed some problems with some texts like: “rm /some/folder/*” where '/*' should not be seen as the start of a piece of hidden text; still got some problems with two lines below eachother having only /* comment */ on them
— Sebastiaan Giebels 2010-12-10 18:04