DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:htmlcomment

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Both sides next revision
plugin:htmlcomment [2013-03-19 08:57]
danny0838 [Discussion]
plugin:htmlcomment [2021-02-24 00:12] (current)
Dr-Yukon
Line 1: Line 1:
-====== HTML Comment ======+====== HTML Comment Plugin ======
  
 ---- plugin ---- ---- plugin ----
-description: Enables HTML comments.+description: Enables HTML comments
 author     : Christopher Arndt author     : Christopher Arndt
 email      : chris@chrisarndt.de email      : chris@chrisarndt.de
 type       : syntax type       : syntax
 lastupdate : 2013-03-19 lastupdate : 2013-03-19
-compatible : 2013-03-062012-10-132012-01-252011-05-25+compatible : RincewindAnguaAdora BelleWeatherwax, Binky, Ponder Stibbons, Greebo, Hogfather
 depends    :  depends    : 
-conflicts +conflicts ckgedit
 similar    : comment, commentsrc similar    : comment, commentsrc
 tags       : annotations, hide tags       : annotations, hide
  
-downloadurl: https://github.com/danny0838/dw-htmlcomment/archive/master.zip+downloadurl: https://github.com/danny0838/dokuwiki-plugin-htmlcomment/archive/master.zip 
 +sourcerepo : https://github.com/danny0838/dokuwiki-plugin-htmlcomment/ 
 +bugtracker : https://github.com/danny0838/dokuwiki-plugin-htmlcomment/issues
 ---- ----
  
-This is a very simple [[plugins|plugin]] that allows HTML style comments to be used in the [[:wikitext]]. They will show up unchanged in the XHTML output. They will not be rendered by the browser, but can be viewed with "View source code" command. The syntax is exactly like in HTML:+This is a very simple plugin that allows HTML style comments to be used in the [[:wikitext]]. They will show up unchanged in the XHTML output. They will not be rendered by the browser, but can be viewed with "View source code" command. The syntax is exactly like in HTML:
  
   <!-- This is a HTML comment -->   <!-- This is a HTML comment -->
Line 28: Line 30:
 ===== Installation ===== ===== Installation =====
  
-Either save the PHP code [[#code|below]] to the file ''lib/plugins/htmlcomment/syntax.php'' or use the [[plugin:plugin]] manager with the following URL: +Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
- +
-Download: [[http://chrisarndt.de/en/software/dokuwiki/htmlcomment-plugin.zip|htmlcomment-plugin.zip]]+
  
 ===== Changes ===== ===== Changes =====
Line 40: Line 40:
   * Incorporated changes made by [[esther@kaffeehaus.ch|Esther Brunner]] (see [[#Discussion]]).   * Incorporated changes made by [[esther@kaffeehaus.ch|Esther Brunner]] (see [[#Discussion]]).
   * Defined constant ''HTMLCOMMENT_SAFE'' to allow to switch back to old behaviour.   * Defined constant ''HTMLCOMMENT_SAFE'' to allow to switch back to old behaviour.
-  * Removed version number from plugin archive, since the [[plugin:plugin]] manager can't handle versioned archives. +  * Removed version number from plugin archive, since the [[plugin:extension]] manager can't handle versioned archives.
- +
-===== Code ===== +
- +
-<file php syntax.php> +
-<?php +
-/** +
- * HTML Comment Plugin: allows HTML comments to be retained in the output +
- * +
- * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) +
- * @author     Christopher Arndt <chris@chrisarndt.de> +
- */ +
- +
-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'); +
- +
-define('HTMLCOMMENT_SAFE', true); +
- +
-/** +
- * All DokuWiki plugins to extend the parser/rendering mechanism +
- * need to inherit from this class +
- */ +
-class syntax_plugin_htmlcomment extends DokuWiki_Syntax_Plugin { +
- +
-    /** +
-     * return some info +
-     */ +
-    function getInfo(){ +
-        return array( +
-            'author' => 'Christopher Arndt', +
-            'email'  => 'chris@chrisarndt.de', +
-            'date'   => '2005-10-08', +
-            'name'   => 'HTML Comment Plugin', +
-            'desc'   => 'allows HTML comments to be retained in the output', +
-            'url'    => 'http://www.dokuwiki.org/plugin:htmlcomment', +
-        ); +
-    } +
- +
-    function getType() { +
-        return 'substition'; +
-    } +
- +
-    function getSort() { +
-        return 325; +
-    } +
- +
-    function connectTo($mode) { +
-        $this->Lexer->addSpecialPattern("<\!--.*?-->", $mode, +
-          'plugin_htmlcomment'); +
-    } +
- +
-    function handle($match, $state, $pos, &$handler) { +
-        if ($state == DOKU_LEXER_SPECIAL) { +
-             // strip <!-- from start and --> from end +
-            $match = substr($match,4,-3); +
-            return array($state, $match); +
-        } +
-        return array(); +
-    } +
- +
-    function render($mode, &$renderer, $data) { +
-        if ($mode == 'xhtml') { +
-            list($state, $match) = $data; +
-            if ($state == DOKU_LEXER_SPECIAL) { +
-                $renderer->doc .= '<!--'; +
-                if (HTMLCOMMENT_SAFE) { +
-                    $renderer->doc .= $renderer->_xmlEntities($match); +
-                } else { +
-                    $renderer->doc .= $match; +
-                } +
-                $renderer->doc .= '-->'; +
-            } +
-            return true; +
-        } +
-        return false; +
-    } +
-+
- +
-?> +
-</file> +
  
 ===== Discussion ===== ===== Discussion =====
Line 139: Line 58:
 > Hi! One short question: Commented text is displayed in search results. Is there a method to prevent this? --- //[[orinoco]] 2011-03-09 9:20// > Hi! One short question: Commented text is displayed in search results. Is there a method to prevent this? --- //[[orinoco]] 2011-03-09 9:20//
  
-It should be no problem to embed the unescaped code into the html comment, so I removed the escape feature. The code is slight changed and is replaced into a git repo. Already informed the original author.  --- [[user>danny0838|danny0838]] //2013/03/19 08:54// +It should be no problem to embed the unescaped code into the html comment, so I removed the escape feature. The code is slight changed and is replaced into a git repo. Already informed the original author.  --- [[user>danny0838|danny0838]] //2013/03/19 08:54//
plugin/htmlcomment.1363679854.txt.gz · Last modified: 2013-03-19 08:57 by danny0838