Skip to content

Commit

Permalink
#1797 fix ptype stack to properly close and reopen <p> elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris--S committed Sep 18, 2010
1 parent 3cf9002 commit f4daa9a
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions inc/parser/handler.php
Expand Up @@ -1543,14 +1543,12 @@ function process($calls) {
// Process blocks which are stack like... (contain linefeeds)
if ( in_array($cname,$this->stackOpen ) && (!$plugin || $plugin_open) ) {

$this->calls[] = $call;

// Hack - footnotes shouldn't immediately contain a p_open
if ( $cname != 'footnote_open' ) {
$this->addToStack();
} else {
$this->addToStack(false);
if ($this->addToStack($cname != 'footnote_open')) {
$this->closeParagraph($call[2]);
}
$this->calls[] = $call;

continue;
}

Expand All @@ -1560,7 +1558,9 @@ function process($calls) {
$this->closeParagraph($call[2]);
}
$this->calls[] = $call;
$this->removeFromStack();
if ($this->removeFromStack()) {
$this->calls[] = array('p_open',array(), $call[2]);
}
continue;
}

Expand Down Expand Up @@ -1676,16 +1676,25 @@ function process($calls) {
return $this->calls;
}

/**
*
* @return bool true when a p_close() is required
*/
function addToStack($newStart = true) {
$ret = $this->inParagraph;
$this->blockStack[] = array($this->atStart, $this->inParagraph);
$this->atStart = $newStart;
$this->inParagraph = false;

return $ret;
}

function removeFromStack() {
$state = array_pop($this->blockStack);
$this->atStart = $state[0];
$this->inParagraph = $state[1];

return $this->inParagraph;
}

function addCall($call) {
Expand Down

0 comments on commit f4daa9a

Please sign in to comment.