Skip to content

Commit

Permalink
Fix automatic table of contents, fixes #421
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Nov 18, 2016
1 parent e5c7747 commit be6438a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ protected function ensureHeadingHasId(Heading $node)
}

/**
* Make a tree of the list of headings
*
* @param Entry[] $headings
* @return RootEntry
*/
Expand All @@ -125,7 +127,7 @@ public function generate($headings)
$parent = $previous;
do {
$parent = $parent->getParent();
} while ($heading->getLevel() <= $parent->getLevel() || $parent->getLevel() != 0);
} while ($heading->getLevel() <= $parent->getLevel() && $parent->getLevel() != 0);

$parent->addChild($heading);
$previous = $heading;
Expand Down

0 comments on commit be6438a

Please sign in to comment.