====== 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, htmlcomment, wrap
tags : annotations, hide, comment
downloadurl: https://trello.com/1/cards/5bc21fba6cae5c27f9810b58/attachments/5bc2205bbf44252d17ada47c/download/commentsrc.zip
bugtracker :
sourcerepo :
donationurl:
screenshot_img:
----
===== Syntax =====
Just put your comment between ''!-'' and ''-!'':
!-I love dokuwiki-!
===== Install =====
Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
===== 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' => 'https://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 -! Disappearing 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. --- 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
--- //[[sgiebels_dokuwiki@pcREM0VEprobleemloos.nl|Sebastiaan Giebels]] 2010-12-10 18:04//
----