Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
First release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Lin committed Jan 25, 2011
0 parents commit 87b54bf
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugin.info.txt
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
41 changes: 41 additions & 0 deletions syntax/block.php
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) {}
}
40 changes: 40 additions & 0 deletions syntax/eol.php
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;
}
}

0 comments on commit 87b54bf

Please sign in to comment.