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 1
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 Lin
committed
Jan 25, 2011
0 parents
commit 87b54bf
Showing
3 changed files
with
87 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,6 @@ | ||
author Danny Lin | ||
email danny0838[at]pchome[dot]com[dot]tw | ||
date 2011-01-25 | ||
name Poem | ||
desc <poem> tag that embeds a block with linebreaks preserved. | ||
url http://www.dokuwiki.org/plugin:poem |
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,41 @@ | ||
<?php | ||
// must be run within Dokuwiki | ||
if(!defined('DOKU_INC')) die(); | ||
|
||
/** | ||
* All DokuWiki plugins to extend the parser/rendering mechanism | ||
* need to inherit from this class | ||
*/ | ||
class syntax_plugin_poem_block extends DokuWiki_Syntax_Plugin { | ||
|
||
function getType() { return 'container'; } | ||
function getPType() { return 'stack'; } | ||
function getAllowedTypes() { return array('formatting', 'substition', 'disabled', 'poem'); } | ||
function getSort() { return 20; } | ||
|
||
/** | ||
* Connect pattern to lexer | ||
*/ | ||
function connectTo($mode) { | ||
$this->Lexer->addEntryPattern('<poem>\n?',$mode,'plugin_poem_block'); | ||
} | ||
|
||
function postConnect() { | ||
$this->Lexer->addExitPattern('</poem>','plugin_poem_block'); | ||
} | ||
|
||
/** | ||
* Handle the match | ||
*/ | ||
function handle($match, $state, $pos, &$handler){ | ||
if ($state==DOKU_LEXER_UNMATCHED) { | ||
$handler->_addCall('cdata', array($match), $pos); | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Create output | ||
*/ | ||
function render($format, &$renderer, $data) {} | ||
} |
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,40 @@ | ||
<?php | ||
// must be run within Dokuwiki | ||
if(!defined('DOKU_INC')) die(); | ||
|
||
/** | ||
* All DokuWiki plugins to extend the parser/rendering mechanism | ||
* need to inherit from this class | ||
*/ | ||
class syntax_plugin_poem_eol extends DokuWiki_Syntax_Plugin { | ||
|
||
function getType() { return 'poem'; } | ||
function getPType() { return 'normal'; } | ||
function getSort() { return 369; } | ||
|
||
/** | ||
* Connect pattern to lexer | ||
*/ | ||
function connectTo($mode) { | ||
$this->Lexer->addSpecialPattern('(?:^[ \t]*)?\n',$mode,'plugin_poem_eol'); | ||
} | ||
|
||
/** | ||
* Handle the match | ||
*/ | ||
function handle($match, $state, $pos, &$handler){return true;} | ||
|
||
/** | ||
* Create output | ||
*/ | ||
function render($format, &$renderer, $data) { | ||
if($format == 'xhtml'){ | ||
$renderer->doc .= "<br/>\n"; | ||
return true; | ||
} else if ($format == 'metadata') { | ||
$renderer->doc .= "\n"; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |