Skip to content

Commit

Permalink
Fix broken parsing of emphasized text ending with a '0' character (#81)
Browse files Browse the repository at this point in the history
The issue was caused by non-strict tests, where a "0" string was considered falsy.
  • Loading branch information
colinodell committed Mar 5, 2015
1 parent 7b428e9 commit 3ba7a45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [Unreleased][unreleased]
### Fixed
- Fixed broken parsing of emphasized text ending with a '0' character (#81)

## [0.7.1] - 2015-03-01
### Added
Expand Down
10 changes: 8 additions & 2 deletions src/Inline/Parser/EmphasisParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,21 @@ public function parse(ContextInterface $context, InlineParserContext $inlineCont
$numDelims = 0;

$cursor = $inlineContext->getCursor();
$charBefore = $cursor->peek(-1) ?: "\n";
$charBefore = $cursor->peek(-1);
if ($charBefore === null) {
$charBefore = "\n";
}

while ($cursor->peek($numDelims) === $character) {
++$numDelims;
}

$cursor->advanceBy($numDelims);

$charAfter = $cursor->getCharacter() ?: "\n";
$charAfter = $cursor->getCharacter();
if ($charAfter === null) {
$charAfter = "\n";
}

$leftFlanking = $numDelims > 0 && !preg_match('/\pZ|\s/u', $charAfter) &&
!(preg_match(RegexHelper::REGEX_PUNCTUATION, $charAfter) &&
Expand Down

0 comments on commit 3ba7a45

Please sign in to comment.