Don't interpret shell comments inside fenced code blocks as MD headers

refs #3200
This commit is contained in:
Alexander A. Klimov 2017-12-13 13:27:15 +01:00
parent 208e49a616
commit b3535481ff
1 changed files with 10 additions and 1 deletions

View File

@ -161,10 +161,19 @@ class DocParser
$lastLine = null;
$stack = new SplStack();
$cachingIterator = new CachingIterator($file, CachingIterator::TOSTRING_USE_CURRENT);
$insideFencedCodeBlock = false;
for ($cachingIterator->rewind(); $line = $cachingIterator->valid(); $cachingIterator->next()) {
$fileIterator = $cachingIterator->getInnerIterator();
$line = $cachingIterator->current();
$header = $this->extractHeader($line, $fileIterator->valid() ? $fileIterator->current() : null);
$header = null;
if (substr($line, 0, 3) === '```') {
$insideFencedCodeBlock = ! $insideFencedCodeBlock;
} elseif (! $insideFencedCodeBlock) {
$header = $this->extractHeader($line, $fileIterator->valid() ? $fileIterator->current() : null);
}
if ($header !== null) {
list($title, $id, $level, $headerStyle) = $header;
while (! $stack->isEmpty() && $stack->top()->getLevel() >= $level) {