| @@ 596-619 (lines=24) @@ | ||
| 593 | // another heading. Infinite loops are avoided because the next iteration MUST |
|
| 594 | // hit the heading open case above, which unconditionally increments the |
|
| 595 | // input pointer. |
|
| 596 | } elseif ( $found == 'open' ) { |
|
| 597 | # count opening brace characters |
|
| 598 | $count = strspn( $text, $curChar, $i ); |
|
| 599 | ||
| 600 | # we need to add to stack only if opening brace count is enough for one of the rules |
|
| 601 | if ( $count >= $rule['min'] ) { |
|
| 602 | # Add it to the stack |
|
| 603 | $piece = [ |
|
| 604 | 'open' => $curChar, |
|
| 605 | 'close' => $rule['end'], |
|
| 606 | 'count' => $count, |
|
| 607 | 'lineStart' => ( $i > 0 && $text[$i - 1] == "\n" ), |
|
| 608 | ]; |
|
| 609 | ||
| 610 | $stack->push( $piece ); |
|
| 611 | $accum =& $stack->getAccum(); |
|
| 612 | $flags = $stack->getFlags(); |
|
| 613 | extract( $flags ); |
|
| 614 | } else { |
|
| 615 | # Add literal brace(s) |
|
| 616 | $accum .= htmlspecialchars( str_repeat( $curChar, $count ) ); |
|
| 617 | } |
|
| 618 | $i += $count; |
|
| 619 | } elseif ( $found == 'close' ) { |
|
| 620 | $piece = $stack->top; |
|
| 621 | # lets check if there are enough characters for closing brace |
|
| 622 | $maxCount = $piece->count; |
|
| @@ 539-561 (lines=23) @@ | ||
| 536 | // another heading. Infinite loops are avoided because the next iteration MUST |
|
| 537 | // hit the heading open case above, which unconditionally increments the |
|
| 538 | // input pointer. |
|
| 539 | } elseif ( $found == 'open' ) { |
|
| 540 | # count opening brace characters |
|
| 541 | $count = strspn( $text, $curChar, $i ); |
|
| 542 | ||
| 543 | # we need to add to stack only if opening brace count is enough for one of the rules |
|
| 544 | if ( $count >= $rule['min'] ) { |
|
| 545 | # Add it to the stack |
|
| 546 | $piece = [ |
|
| 547 | 'open' => $curChar, |
|
| 548 | 'close' => $rule['end'], |
|
| 549 | 'count' => $count, |
|
| 550 | 'lineStart' => ( $i > 0 && $text[$i - 1] == "\n" ), |
|
| 551 | ]; |
|
| 552 | ||
| 553 | $stack->push( $piece ); |
|
| 554 | $accum =& $stack->getAccum(); |
|
| 555 | extract( $stack->getFlags() ); |
|
| 556 | } else { |
|
| 557 | # Add literal brace(s) |
|
| 558 | self::addLiteral( $accum, str_repeat( $curChar, $count ) ); |
|
| 559 | } |
|
| 560 | $i += $count; |
|
| 561 | } elseif ( $found == 'close' ) { |
|
| 562 | $piece = $stack->top; |
|
| 563 | # lets check if there are enough characters for closing brace |
|
| 564 | $maxCount = $piece->count; |
|