Skip to content

Commit ad1b894

Browse files
committed
Merge pull request #61 from thephpleague/spec-0.17
Spec 0.17
2 parents 7195613 + ab8721b commit ad1b894

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
44

55
## [Unreleased][unreleased]
66

7+
## [0.6.1] - 2015-01-25
8+
### Changed
9+
- Bumped spec target version to 0.17
10+
- Updated emphasis parsing for underscores to prevent intra-word emphasis
11+
- Defered closing of fenced code blocks
12+
713
## [0.6.0] - 2015-01-09
814
### Added
915
- Bulk registration of parsers/renderers via extensions (#45)
@@ -122,7 +128,8 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
122128
### Added
123129
- Initial commit (compatible with jgm/stmd:spec.txt @ 0275f34)
124130

125-
[unreleased]: https://github.com/thephpleague/commonmark/compare/0.6.0...HEAD
131+
[unreleased]: https://github.com/thephpleague/commonmark/compare/0.6.1...HEAD
132+
[0.6.1]: https://github.com/thephpleague/commonmark/compare/0.6.0...0.6.1
126133
[0.6.0]: https://github.com/thephpleague/commonmark/compare/0.5.1...0.6.0
127134
[0.5.1]: https://github.com/thephpleague/commonmark/compare/0.5.0...0.5.1
128135
[0.5.0]: https://github.com/thephpleague/commonmark/compare/0.4.0...0.5.0

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,15 @@ The following table shows which versions of league/commonmark are compatible wit
103103
</thead>
104104
<tbody>
105105
<tr>
106-
<td><strong>0.6.0</strong></td>
107-
<td><strong><a href="http://spec.commonmark.org/0.16/">0.16</a></strong><br><a href="http://spec.commonmark.org/0.15/">0.15</a><br><a href="http://spec.commonmark.org/0.14/">0.14</a></td>
108-
<td>current spec (as of Jan 15 '15)</td>
106+
<td><strong>0.6.1</strong></td>
107+
<td><strong><a href="http://spec.commonmark.org/0.17/">0.17</a></strong></td>
108+
<td>current spec (as of Jan 25 '15)</td>
109+
</tr>
110+
<tr>
111+
<td>0.6.0</td>
112+
<td><a href="http://spec.commonmark.org/0.16/">0.16</a><br><a href="http://spec.commonmark.org/0.15/">0.15</a><br><a href="http://spec.commonmark.org/0.14/">0.14</a></td>
113+
<td></td>
114+
</tr>
109115
<tr>
110116
<td>0.5.x<br>0.4.0</td>
111117
<td><a href="http://spec.commonmark.org/0.13/">0.13</a></td>

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"require-dev": {
2424
"erusev/parsedown": "~1.0",
25-
"jgm/CommonMark": "0.16",
25+
"jgm/CommonMark": "0.17",
2626
"michelf/php-markdown": "~1.4",
2727
"phpunit/phpunit": "~4.3"
2828
},
@@ -31,9 +31,9 @@
3131
"type": "package",
3232
"package": {
3333
"name": "jgm/CommonMark",
34-
"version": "0.16",
34+
"version": "0.17",
3535
"dist": {
36-
"url": "http://spec.commonmark.org/0.16/spec.txt",
36+
"url": "http://spec.commonmark.org/0.17/spec.txt",
3737
"type": "file"
3838
}
3939
}

src/Block/Element/FencedCode.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ public function isCode()
164164

165165
public function matchesNextLine(Cursor $cursor)
166166
{
167+
if ($this->length === -1) {
168+
if ($cursor->isBlank()) {
169+
$this->lastLineBlank = true;
170+
}
171+
172+
return false;
173+
}
174+
167175
// Skip optional spaces of fence offset
168176
$cursor->advanceWhileMatches(' ', $this->offset);
169177

@@ -198,7 +206,7 @@ public function handleRemainingContents(ContextInterface $context, Cursor $curso
198206
$match = RegexHelper::matchAll('/^(?:`{3,}|~{3,})(?= *$)/', $cursor->getLine(), $cursor->getFirstNonSpacePosition());
199207
if (strlen($match[0]) >= $container->getLength()) {
200208
// don't add closing fence to container; instead, close it:
201-
$container->finalize($context);
209+
$this->setLength(-1); // -1 means we've passed closer
202210

203211
return;
204212
}

src/Inline/Parser/EmphasisParser.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,22 @@ public function parse(ContextInterface $context, InlineParserContext $inlineCont
5656

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

59-
$canOpen = $numDelims > 0 && !preg_match('/\pZ|\s/u', $charAfter) &&
59+
$leftFlanking = $numDelims > 0 && !preg_match('/\pZ|\s/u', $charAfter) &&
6060
!(preg_match(RegexHelper::REGEX_PUNCTUATION, $charAfter) &&
6161
!preg_match('/\pZ|\s/u', $charBefore) &&
6262
!(preg_match(RegexHelper::REGEX_PUNCTUATION, $charBefore)));
6363

64-
$canClose = $numDelims > 0 && !preg_match('/\pZ|\s/u', $charBefore) &&
64+
$rightFlanking = $numDelims > 0 && !preg_match('/\pZ|\s/u', $charBefore) &&
6565
!(preg_match(RegexHelper::REGEX_PUNCTUATION, $charBefore) &&
6666
!preg_match('/\pZ|\s/u', $charAfter) &&
6767
!(preg_match(RegexHelper::REGEX_PUNCTUATION, $charAfter)));
6868

6969
if ($character === '_') {
70-
$canOpen = $canOpen && !preg_match('/[a-z0-9]/i', $charBefore);
71-
$canClose = $canClose && !preg_match('/[a-z0-9]/i', $charAfter);
70+
$canOpen = $leftFlanking && !$rightFlanking;
71+
$canClose = $rightFlanking && !$leftFlanking;
72+
} else {
73+
$canOpen = $leftFlanking;
74+
$canClose = $rightFlanking;
7275
}
7376

7477
$inlineContext->getInlines()->add(

0 commit comments

Comments
 (0)