This repository has been archived by the owner on Aug 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Danny
committed
Mar 19, 2013
0 parents
commit 864a78f
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?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://wiki.splitbrain.org/plugin:html_comment', | ||
); | ||
} | ||
|
||
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; | ||
} | ||
} | ||
|
||
?> |