Skip to content

Commit

Permalink
Merge pull request #272 from ntzm/fix-271
Browse files Browse the repository at this point in the history
Allow inline parsers matching regex delimiter to be created
  • Loading branch information
colinodell authored Dec 19, 2016
2 parents dc281a4 + 1a6571c commit 4592fff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ private function buildInlineParserCharacterRegex()
$this->inlineParserCharacterRegex = '/^.+$/u';
} else {
// Match any character which inline parsers are not interested in
$this->inlineParserCharacterRegex = '/^[^' . preg_quote(implode('', $chars)) . ']+/u';
$this->inlineParserCharacterRegex = '/^[^' . preg_quote(implode('', $chars), '/') . ']+/u';
}
}

Expand Down
15 changes: 15 additions & 0 deletions tests/unit/EnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,21 @@ public function testAddInlineParserAndGetter()
$this->assertContains($parser, $environment->getInlineParsers());
}

public function testInlineParserCanMatchRegexDelimiter()
{
$environment = new Environment();

$parser = $this->getMock('League\CommonMark\Inline\Parser\InlineParserInterface');
$parser->expects($this->any())
->method('getCharacters')
->will($this->returnValue(['/']));

$environment->addInlineParser($parser);
$environment->getInlineParsers();

$this->assertEquals(1, preg_match($environment->getInlineParserCharacterRegex(), 'foo/bar'));
}

/**
* @expectedException \RuntimeException
*/
Expand Down

0 comments on commit 4592fff

Please sign in to comment.