diff options
author | Alex Shpak <alex-shpak@users.noreply.github.com> | 2020-04-21 23:25:36 +0200 |
---|---|---|
committer | Alex Shpak <alex-shpak@users.noreply.github.com> | 2020-04-21 23:25:36 +0200 |
commit | 357de9eb39328cc338df2c7bc125653ab0f62616 (patch) | |
tree | 0571f275bc2de8da2218d7a7e1837eced876a157 | |
parent | 66968582ef45a1c3c38f47477096e9417a774ce9 (diff) |
#196, #201 Refactor numbered plugin. multilevel numbers in ToC
-rw-r--r-- | assets/plugins/_numbered.scss | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/assets/plugins/_numbered.scss b/assets/plugins/_numbered.scss index a1e89d8..6209100 100644 --- a/assets/plugins/_numbered.scss +++ b/assets/plugins/_numbered.scss @@ -1,23 +1,36 @@ -.book-page { - .markdown { - @for $h from 1 through 6 { - > h#{$h} { - counter-increment: h#{$h}; - counter-reset: h#{$h + 1}; +$startLevel: 1; +$endLevel: 6; - $content: ""; - @for $n from 1 through $h { - $content: $content + 'counter(h#{$n})"."'; - } +.book-page .markdown { + @for $currentLevel from $startLevel through $endLevel { + > h#{$currentLevel} { + counter-increment: h#{$currentLevel}; + counter-reset: h#{$currentLevel + 1}; - &::before { - content: unquote($content) " "; - } + $content: ""; + @for $n from $startLevel through $currentLevel { + $content: $content + 'counter(h#{$n})"."'; + } + + &::before { + content: unquote($content) " "; } } } +} + +.book-toc nav ul { + li { + counter-increment: item; - + .book-toc nav ul { - list-style: decimal; + &:first-child { + counter-reset: item; + } + + &:before { + content: counters(item, ".") ". "; + float: left; + margin-right: $padding-4; + } } } |