summaryrefslogtreecommitdiff
path: root/inc/parser/handler.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/parser/handler.php')
-rw-r--r--inc/parser/handler.php35
1 files changed, 30 insertions, 5 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index a1040d12e..b8e2de82a 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -21,6 +21,9 @@ class Doku_Handler {
$this->CallWriter = new Doku_Handler_CallWriter($this);
}
+ /**
+ * @param string $handler
+ */
function _addCall($handler, $args, $pos) {
$call = array($handler,$args, $pos);
$this->CallWriter->writeCall($call);
@@ -71,6 +74,7 @@ class Doku_Handler {
*/
function plugin($match, $state, $pos, $pluginname){
$data = array($match);
+ /** @var DokuWiki_Syntax_Plugin $plugin */
$plugin = plugin_load('syntax',$pluginname);
if($plugin != null){
$data = $plugin->handle($match, $state, $pos, $this);
@@ -132,6 +136,9 @@ class Doku_Handler {
return true;
}
+ /**
+ * @param string $name
+ */
function _nestingTag($match, $state, $pos, $name) {
switch ( $state ) {
case DOKU_LEXER_ENTER:
@@ -525,6 +532,7 @@ class Doku_Handler {
$p['author'] = (preg_match('/\b(by|author)/',$params));
$p['date'] = (preg_match('/\b(date)/',$params));
$p['details'] = (preg_match('/\b(desc|detail)/',$params));
+ $p['nosort'] = (preg_match('/\b(nosort)\b/',$params));
if (preg_match('/\b(\d+)([dhm])\b/',$params,$match)) {
$period = array('d' => 86400, 'h' => 3600, 'm' => 60);
@@ -711,6 +719,9 @@ class Doku_Handler_CallWriter {
var $Handler;
+ /**
+ * @param Doku_Handler $Handler
+ */
function Doku_Handler_CallWriter(& $Handler) {
$this->Handler = & $Handler;
}
@@ -747,7 +758,7 @@ class Doku_Handler_Nest {
/**
* constructor
*
- * @param object $CallWriter the renderers current call writer
+ * @param Doku_Handler_CallWriter $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
*/
@@ -805,6 +816,8 @@ class Doku_Handler_List {
var $listCalls = array();
var $listStack = array();
+ const NODE = 1;
+
function Doku_Handler_List(& $CallWriter) {
$this->CallWriter = & $CallWriter;
}
@@ -856,7 +869,8 @@ class Doku_Handler_List {
$depth = $this->interpretSyntax($call[1][0], $listType);
$this->initialDepth = $depth;
- $this->listStack[] = array($listType, $depth);
+ // array(list type, current depth, index of current listitem_open)
+ $this->listStack[] = array($listType, $depth, 1);
$this->listCalls[] = array('list'.$listType.'_open',array(),$call[2]);
$this->listCalls[] = array('listitem_open',array(1),$call[2]);
@@ -881,6 +895,7 @@ class Doku_Handler_List {
function listOpen($call) {
$depth = $this->interpretSyntax($call[1][0], $listType);
$end = end($this->listStack);
+ $key = key($this->listStack);
// Not allowed to be shallower than initialDepth
if ( $depth < $this->initialDepth ) {
@@ -897,6 +912,9 @@ class Doku_Handler_List {
$this->listCalls[] = array('listitem_open',array($depth-1),$call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
+ // new list item, update list stack's index into current listitem_open
+ $this->listStack[$key][2] = count($this->listCalls) - 2;
+
// Switched list type...
} else {
@@ -908,7 +926,7 @@ class Doku_Handler_List {
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
array_pop($this->listStack);
- $this->listStack[] = array($listType, $depth);
+ $this->listStack[] = array($listType, $depth, count($this->listCalls) - 2);
}
//------------------------------------------------------------------------
@@ -920,7 +938,10 @@ class Doku_Handler_List {
$this->listCalls[] = array('listitem_open', array($depth-1), $call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
- $this->listStack[] = array($listType, $depth);
+ // set the node/leaf state of this item's parent listitem_open to NODE
+ $this->listCalls[$this->listStack[$key][2]][1][1] = self::NODE;
+
+ $this->listStack[] = array($listType, $depth, count($this->listCalls) - 2);
//------------------------------------------------------------------------
// Getting shallower ( $depth < $end[1] )
@@ -934,6 +955,7 @@ class Doku_Handler_List {
while (1) {
$end = end($this->listStack);
+ $key = key($this->listStack);
if ( $end[1] <= $depth ) {
@@ -946,6 +968,9 @@ class Doku_Handler_List {
$this->listCalls[] = array('listitem_open',array($depth-1),$call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
+ // new list item, update list stack's index into current listitem_open
+ $this->listStack[$key][2] = count($this->listCalls) - 2;
+
} else {
// Switching list type...
$this->listCalls[] = array('list'.$end[0].'_close', array(), $call[2]);
@@ -954,7 +979,7 @@ class Doku_Handler_List {
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
array_pop($this->listStack);
- $this->listStack[] = array($listType, $depth);
+ $this->listStack[] = array($listType, $depth, count($this->listCalls) - 2);
}
break;