summaryrefslogtreecommitdiff
path: root/inc/parser/handler.php
diff options
context:
space:
mode:
authorchris <chris@jalakai.co.uk>2006-08-05 00:01:00 +0200
committerchris <chris@jalakai.co.uk>2006-08-05 00:01:00 +0200
commit5587e44c45f200479ef9ab3bd8f0264647941483 (patch)
treecc8ace5822717fbbfe4ab27f54c30937fb6f2171 /inc/parser/handler.php
parent03c4aec3c817c51eda2cf5c241f76e3bef585799 (diff)
downloadrpg-5587e44c45f200479ef9ab3bd8f0264647941483.tar.gz
rpg-5587e44c45f200479ef9ab3bd8f0264647941483.tar.bz2
fix for bug #701, lists in footnotes in lists
added Doku_Handler_Nest class & "nest" render instruction These allows render instructions to be nested within the "nest" render instruction, isolating them from the outer list of render instructions. Not being able to do this is a particular problem for the current Doku_Handler_* classes as they process the list of intructions generated during their life without any recognition that some of the instructions may not belong to them being nested within another syntax mode. This also makes it easier for plugins to generate cacheable nested instructions rather than using the expensive p_render() function which has to create a new renderer. darcs-hash:20060804220100-9b6ab-ccd051e287af45afacdb1efecb8d9beb376276cb.gz
Diffstat (limited to 'inc/parser/handler.php')
-rw-r--r--inc/parser/handler.php68
1 files changed, 66 insertions, 2 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 602ef1b6d..612534eea 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -29,7 +29,7 @@ class Doku_Handler {
function _finalize(){
- $this->CallWriter->finalise();
+ $this->CallWriter->finalise();
if ( $this->status['section'] ) {
$last_call = end($this->calls);
@@ -191,7 +191,23 @@ class Doku_Handler {
function footnote($match, $state, $pos) {
- $this->_nestingTag($match, $state, $pos, 'footnote');
+// $this->_nestingTag($match, $state, $pos, 'footnote');
+ switch ( $state ) {
+ case DOKU_LEXER_ENTER:
+ $ReWriter = & new Doku_Handler_Nest($this->CallWriter,'footnote_close');
+ $this->CallWriter = & $ReWriter;
+ $this->_addCall('footnote_open', array($match), $pos);
+ break;
+ case DOKU_LEXER_EXIT:
+ $this->_addCall('footnote_close', array(), $pos);
+ $this->CallWriter->process();
+ $ReWriter = & $this->CallWriter;
+ $this->CallWriter = & $ReWriter->CallWriter;
+ break;
+ case DOKU_LEXER_UNMATCHED:
+ $this->_addCall('cdata', array($match), $pos);
+ break;
+ }
return TRUE;
}
@@ -677,6 +693,54 @@ class Doku_Handler_CallWriter {
}
//------------------------------------------------------------------------
+/**
+ * Generic call writer class to handle nesting of rendering instructions
+ * within a render instruction. Also see nest() method of renderer base class
+ *
+ * @author Chris Smith <chris@jalakai.co.uk>
+ */
+class Doku_Handler_Nest {
+
+ var $CallWriter;
+ var $calls = array();
+
+ var $closingInstruction;
+
+ /**
+ * constructor
+ *
+ * @param object $CallWriter the renderers current call writer
+ * @param string $close closing instruction name, this is required to properly terminate the
+ * syntax mode if the document ends without a closing pattern
+ */
+ function Doku_Handler_Nest(& $CallWriter, $close="nest_close") {
+ $this->CallWriter = & $CallWriter;
+
+ $this->closingInstruction = $close;
+ }
+
+ function writeCall($call) {
+ $this->calls[] = $call;
+ }
+
+ function writeCalls($calls) {
+ $this->calls = array_merge($this->calls, $calls);
+ }
+
+ function finalise() {
+ $last_call = end($this->calls);
+ $this->writeCall(array($this->closingInstruction,array(), $last_call[2]));
+
+ $this->process();
+ $this->CallWriter->finalise();
+ }
+
+ function process() {
+ $first_call = reset($this->calls);
+ $this->CallWriter->writeCall(array("nest", array($this->calls), $first_call[2]));
+ }
+}
+
class Doku_Handler_List {
var $CallWriter;