====== commentsrc plugin ======
---- plugin ----
description: This plugin provides the ability to put comment only visible when you edit the page.
author : iDo
email : iDo@woow-fr.com
type : syntax
lastupdate : 2005-12-14
compatible :
depends :
conflicts :
similar : comment
tags : comment, hidden
----
===== Syntax =====
Just put your comment between !- and -!:
!-I love dokuwiki-!
===== Install =====
You can install it with [[plugin]] manager => http://dokuplugins.idotech.info/commentsrc.zip \\
Or just download the .zip and uncompress it in "lib/plugins"
===== Code =====
lib/plugins/commentsrc/syntax.php :
'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 :
?>
===== Comments =====
There is already another plugin which does just that: [[Comment]]. The only difference is the markup, ''%%/* hidden comment */%%'' as in many programming languages. --- //[[esther@kaffeehaus.ch|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.) --- //[[chrislale@untrammelled.co.uk|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 %%/* */%%.
- Two or more comments can be used in one page. (The released version was able to use only one comment in one page. )
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
+?>
--- //[[ma2shita@ma2shita.jp|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 -! Dissapearing text !- comment again -!
[[comment|Esther's plugin]] is using %%.*?%% which matches "as little as possible". This is (i think) equivalent to Kohei's solution with entrypattern and exitpattern. --- //[[viktro@bigfoot.com|Viktor]] 2006-10-18 13:44//