Skip to content

Commit

Permalink
Merge pull request #50 from thephpleague/spec-0.15
Browse files Browse the repository at this point in the history
Spec 0.15
  • Loading branch information
colinodell committed Jan 6, 2015
2 parents 3c0a3bc + f3566b1 commit 2376df8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"require-dev": {
"erusev/parsedown": "~1.0",
"jgm/CommonMark": "0.13",
"jgm/CommonMark": "0.15",
"michelf/php-markdown": "~1.4",
"phpunit/phpunit": "~4.3"
},
Expand All @@ -31,9 +31,9 @@
"type": "package",
"package": {
"name": "jgm/CommonMark",
"version": "0.13",
"version": "0.15",
"dist": {
"url": "http://spec.commonmark.org/0.13/spec.txt",
"url": "http://spec.commonmark.org/0.15/spec.txt",
"type": "file"
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Inline/Parser/EmphasisParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use League\CommonMark\Delimiter\Delimiter;
use League\CommonMark\InlineParserContext;
use League\CommonMark\Inline\Element\Text;
use League\CommonMark\Util\RegexHelper;

class EmphasisParser extends AbstractInlineParser
{
Expand Down Expand Up @@ -55,8 +56,16 @@ public function parse(ContextInterface $context, InlineParserContext $inlineCont

$charAfter = $cursor->getCharacter() ?: "\n";

$canOpen = $numDelims > 0 && !preg_match('/\s/', $charAfter);
$canClose = $numDelims > 0 && !preg_match('/\s/', $charBefore);
$canOpen = $numDelims > 0 && !preg_match('/\pZ|\s/u', $charAfter) &&
!(preg_match(RegexHelper::REGEX_PUNCTUATION, $charAfter) &&
!preg_match('/\pZ|\s/u', $charBefore) &&
!(preg_match(RegexHelper::REGEX_PUNCTUATION, $charBefore)));

$canClose = $numDelims > 0 && !preg_match('/\pZ|\s/u', $charBefore) &&
!(preg_match(RegexHelper::REGEX_PUNCTUATION, $charBefore) &&
!preg_match('/\pZ|\s/u', $charAfter) &&
!(preg_match(RegexHelper::REGEX_PUNCTUATION, $charAfter)));

if ($character === '_') {
$canOpen = $canOpen && !preg_match('/[a-z0-9]/i', $charBefore);
$canClose = $canClose && !preg_match('/[a-z0-9]/i', $charAfter);
Expand Down
1 change: 1 addition & 0 deletions src/Util/RegexHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class RegexHelper

const REGEX_ESCAPABLE = '[!"#$%&\'()*+,.\/:;<=>?@[\\\\\]^_`{|}~-]';
const REGEX_ENTITY = '/&(?:#x[a-f0-9]{1,8}|#[0-9]{1,8}|[a-z][a-z0-9]{1,31});/i';
const REGEX_PUNCTUATION = '/^[\x{2000}-\x{206F}\x{2E00}-\x{2E7F}\\\\\'!"#\$%&\(\)\*\+,\-\.\\/:;<=>\?@\[\]\^_`\{\|\}~]/u';

protected $regex = array();

Expand Down

3 comments on commit 2376df8

@GrahamCampbell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a 0.6 release around the corner then?

@colinodell
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sure is! Just need to decide whether to include two additional enhancements first.

@GrahamCampbell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool.

Please sign in to comment.