Doc: Respect last line if it does not end with a line feed too

refs #3572
This commit is contained in:
Eric Lippmann 2018-11-19 10:53:03 +01:00
parent 9f15bda698
commit 3ab32c853a
1 changed files with 4 additions and 4 deletions

View File

@ -158,19 +158,19 @@ class DocParser
$tree = new SimpleTree();
foreach (new RecursiveIteratorIterator($this->docIterator) as $filename) {
$file = new SplFileObject($filename);
$lastLine = null;
$file->setFlags(SplFileObject::READ_AHEAD);
$stack = new SplStack();
$cachingIterator = new CachingIterator($file, CachingIterator::TOSTRING_USE_CURRENT);
$cachingIterator = new CachingIterator($file);
$insideFencedCodeBlock = false;
for ($cachingIterator->rewind(); $line = $cachingIterator->valid(); $cachingIterator->next()) {
$fileIterator = $cachingIterator->getInnerIterator();
for ($cachingIterator->rewind(); $cachingIterator->valid(); $cachingIterator->next()) {
$line = $cachingIterator->current();
$header = null;
if (substr($line, 0, 3) === '```') {
$insideFencedCodeBlock = ! $insideFencedCodeBlock;
} elseif (! $insideFencedCodeBlock) {
$fileIterator = $cachingIterator->getInnerIterator();
$header = $this->extractHeader($line, $fileIterator->valid() ? $fileIterator->current() : null);
}