DocParser: Use first header in a file as section title

refs #4820
This commit is contained in:
Eric Lippmann 2014-06-03 14:56:44 +02:00
parent 370bfca6e6
commit ed8de18ad5
1 changed files with 8 additions and 3 deletions

View File

@ -72,15 +72,20 @@ class DocParser
throw new DocException('Couldn\'t get the lock'); throw new DocException('Couldn\'t get the lock');
} }
$line = null; $line = null;
$sectionTitle = null;
while (! $fileObject->eof()) { while (! $fileObject->eof()) {
// Save last line for setext-style headers // Save last line for setext-style headers
$lastLine = $line; $lastLine = $line;
$line = $fileObject->fgets(); $line = $fileObject->fgets();
$header = $this->extractHeader($line, $lastLine); $header = $this->extractHeader($line, $lastLine);
if ($header !== null) { if ($header !== null) {
list($header, $level) = $header; list($header, $level) = $header;
$id = $this->extractHeaderId($header); if ($sectionTitle === null) {
$nofollow = false; // The first header is the section's title
$sectionTitle = $header;
}
$id = $this->extractHeaderId($header);
$nofollow = false;
$this->reduceToc($tocStack, $level); $this->reduceToc($tocStack, $level);
if ($id === null) { if ($id === null) {
$path = array(); $path = array();