aboutsummaryrefslogtreecommitdiff
path: root/assets/plugins/_numbered.scss
blob: 56cda5ac5b102a0662bc313e3b3a2c2db2170b63 (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-inline-end: $padding-4;
    }
  }
}