aboutsummaryrefslogtreecommitdiff
path: root/assets/plugins/_numbered.scss
blob: 62091001cc14539acbbee2a6c7b398b578bc5ff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$startLevel: 1;
$endLevel: 6;

.book-page .markdown {
  @for $currentLevel from $startLevel through $endLevel {
    > h#{$currentLevel} {
      counter-increment: h#{$currentLevel};
      counter-reset: h#{$currentLevel + 1};

      $content: "";
      @for $n from $startLevel through $currentLevel {
        $content: $content + 'counter(h#{$n})"."';
      }

      &::before {
        content: unquote($content) " ";
      }
    }
  }
}

.book-toc nav ul {
  li {
    counter-increment: item;

    &:first-child {
      counter-reset: item;
    }

    &:before {
      content: counters(item, ".") ". ";
      float: left;
      margin-right: $padding-4;
    }
  }
}