Skip to content

Commit

Permalink
Merge pull request #1 from yangxgkem/master
Browse files Browse the repository at this point in the history
LGTM! THX
  • Loading branch information
KEINOS authored Mar 23, 2018
2 parents 7651672 + 0ecb435 commit 097a0e5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,23 @@ protected function setContentsList($Content)
$text = $this->fetchText($Content['text']);
$link = "[${text}](#${id})";
$level = (integer) trim($Content['level'],'h');

if ($this->firstHeadLevel === 0) {
$this->firstHeadLevel = $level;
}
$cutIndent = $this->firstHeadLevel - 1;
if ($cutIndent > $level) {
$level = 1;
} else {
$level = $level - $cutIndent;
}

$indent = str_repeat(' ', $level);

$this->contentsListString .= "${indent}- ${link}\n";
}
protected $contentsListString = '';
protected $firstHeadLevel = 0;

#
# Header
Expand Down

0 comments on commit 097a0e5

Please sign in to comment.