commentsrc plugin

commentsrc plugin by iDo
This plugin provides the ability to put comment only visible when you edit the page.

Last updated on 2005-12-14. Provides Syntax.
No compatibility info given!

Similar to comment, htmlcomment, wrap.

Tagged with annotations, hide.

    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 :

    <?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 :
    ?>

    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 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.

    1. plugin_commentsrc can use !- -! besides /* */.
    2. 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
    +?>

    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. — Viktor 2006-10-18 13:44

     
    plugin/commentsrc.txt · Last modified: 2009/10/07 14:54 by laynee
     
    Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
    Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
    WikiForumIRCBugsGitXRefTranslate