diff --git a/CHANGELOG.md b/CHANGELOG.md index bc0ebf47..66e0705d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Yii Framework 2 apidoc extension Change Log - Bug #179: Fixed incorrect output when string type hint is used in method parameters (arogachev) - Bug #199: Fixed processing of nullable return types (arogachev) - Bug #148: Fixed processing of code containing uniform variable syntax (arogachev) +- Bug #128: Fixed extracting of first sentence from the text containing backticks (arogachev) - Enh #209: Added support for todos in properties and methods (arogachev) - Enh #18: Added pretty print for arrays (arogachev) diff --git a/models/BaseDoc.php b/models/BaseDoc.php index 47216ba4..ab8fbd4b 100644 --- a/models/BaseDoc.php +++ b/models/BaseDoc.php @@ -207,7 +207,12 @@ public static function extractFirstSentence($text) $sentence = mb_substr($text, 0, $pos + 1, 'utf-8'); if (mb_strlen($text, 'utf-8') >= $pos + 3) { $abbrev = mb_substr($text, $pos - 1, 4, 'utf-8'); - if ($abbrev === 'e.g.' || $abbrev === 'i.e.') { // do not break sentence after abbreviation + // do not break sentence after abbreviation + if ($abbrev === 'e.g.' || + $abbrev === 'i.e.' || + mb_substr_count($sentence, '`', 'utf-8') % 2 === 1 || + mb_substr_count($text, '`', 'utf-8') % 2 === 1 + ) { $sentence .= static::extractFirstSentence(mb_substr($text, $pos + 1, mb_strlen($text, 'utf-8'), 'utf-8')); } } diff --git a/tests/models/BaseDocTest.php b/tests/models/BaseDocTest.php new file mode 100644 index 00000000..a720edfd --- /dev/null +++ b/tests/models/BaseDocTest.php @@ -0,0 +1,25 @@ +assertEquals($initialText, $firstSentence);; + } +}