Skip to content

Commit

Permalink
fixed issue with syntax tags in the shortcode content: they caused Re…
Browse files Browse the repository at this point in the history
…gularParser to return empty content as if shortcode was self-closed
  • Loading branch information
thunderer committed Apr 25, 2016
1 parent 36f18d1 commit 8f915c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Parser/RegularParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ private function content(array &$names)
$appendContent = function(array $token) use(&$content) { $content .= $token[1]; };

while($this->position < $this->tokensCount) {
while($this->match(array(self::TOKEN_STRING, self::TOKEN_WS), $appendContent)) {
while($this->position < $this->tokensCount && false === $this->lookahead(self::TOKEN_OPEN)) {
$this->match(null, $appendContent);
continue;
}

Expand Down
8 changes: 8 additions & 0 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ public function provideShortcodes()
new ParsedShortcode(new Shortcode('n_am_e', array(), null), '[n_am_e]', 24),
new ParsedShortcode(new Shortcode('_n_', array(), null), '[_n_]', 32),
)),
array($s, '[x]/[/x] [x]"[/x] [x]=[/x] [x]][/x] [x] [/x] [x]x[/x]', array(
new ParsedShortcode(new Shortcode('x', array(), '/'), '[x]/[/x]', 0),
new ParsedShortcode(new Shortcode('x', array(), '"'), '[x]"[/x]', 9),
new ParsedShortcode(new Shortcode('x', array(), '='), '[x]=[/x]', 18),
new ParsedShortcode(new Shortcode('x', array(), ']'), '[x]][/x]', 27),
new ParsedShortcode(new Shortcode('x', array(), ' '), '[x] [/x]', 36),
new ParsedShortcode(new Shortcode('x', array(), 'x'), '[x]x[/x]', 45),
)),
);

/**
Expand Down

0 comments on commit 8f915c0

Please sign in to comment.