From d52fe97688bcd766c396ca020a0c169f8f94bd1b Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Wed, 28 Oct 2020 12:59:39 +0000 Subject: [PATCH] fix(tooling): partial fix for firefox numbering (#1238) --- assets/plugins/_numbered.scss | 91 ++++++++++++++++++----------------- assets/plugins/_toc.scss | 10 ++++ layouts/partials/toc.html | 2 +- 3 files changed, 59 insertions(+), 44 deletions(-) diff --git a/assets/plugins/_numbered.scss b/assets/plugins/_numbered.scss index 174105c66..e72591ea9 100644 --- a/assets/plugins/_numbered.scss +++ b/assets/plugins/_numbered.scss @@ -1,49 +1,54 @@ -$startLevel: 1; -$endLevel: 6; - .book-page .markdown { counter-reset: h1 h2 h3 h4 h5 h6; } -.book-page .markdown { - @for $currentLevel from $startLevel through $endLevel { - h#{$currentLevel} { - counter-reset: h#{$currentLevel + 1} 0; - counter-increment: h#{$currentLevel}; - } - $content: ''; - @for $n from $startLevel through $currentLevel { - $content: $content + 'counter(h#{$n})"."'; - } - - h#{$currentLevel}::before { - content: unquote($content) ' '; - } - } +.book-page .markdown h1 { + counter-reset: h2 0; + counter-increment: h1; } - -.book-menu nav ol { - li { - counter-increment: item; - - &:first-child { - counter-reset: item; - } - - a:before { - content: counters(item, '.') ' '; - float: left; - margin-inline-end: $padding-4; - color: var(--gray-600); - } - &.active { - &::before { - content: '⨎'; - color: var(--cl-blue); - } - > a::before { - color: var(--cl-blue); - } - } - } +.book-page .markdown h1::before { + content: counter(h1) '. '; + margin-right: 4px; +} +.book-page .markdown h2 { + counter-reset: h3 0; + counter-increment: h2; +} +.book-page .markdown h2::before { + content: counter(h1) '.' counter(h2) '.'; + margin-right: 4px; +} +.book-page .markdown h3 { + counter-reset: h4 0; + counter-increment: h3; +} +.book-page .markdown h3::before { + content: counter(h1) '.' counter(h2) '.' counter(h3) '.' ' '; + margin-right: 4px; +} +.book-page .markdown h4 { + counter-reset: h5 0; + counter-increment: h4; +} +.book-page .markdown h4::before { + content: counter(h1) '.' counter(h2) '.' counter(h3) '.' counter(h4) '.' ' '; + margin-right: 4px; +} +.book-page .markdown h5 { + counter-reset: h6 0; + counter-increment: h5; +} +.book-page .markdown h5::before { + content: counter(h1) '.' counter(h2) '.' counter(h3) '.' counter(h4) '.' + counter(h5) '.' ' '; + margin-right: 4px; +} +.book-page .markdown h6 { + counter-reset: h7 0; + counter-increment: h6; +} +.book-page .markdown h6::before { + content: counter(h1) '.' counter(h2) '.' counter(h3) '.' counter(h4) '.' + counter(h5) '.' counter(h6) '.' ' '; + margin-right: 4px; } diff --git a/assets/plugins/_toc.scss b/assets/plugins/_toc.scss index f25c922b1..9062e1508 100644 --- a/assets/plugins/_toc.scss +++ b/assets/plugins/_toc.scss @@ -1,3 +1,13 @@ +.book-menu nav ol { + li { + &.active { + &::before { + content: '⨎'; + color: var(--cl-blue); + } + } + } +} .toc { height: 100%; > ol { diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html index 2136fca6a..900f50f1a 100644 --- a/layouts/partials/toc.html +++ b/layouts/partials/toc.html @@ -3,7 +3,7 @@
    {{ range .children }}
  1. - {{.text}} + {{.number}} {{.text}} {{ if gt (len .children) 0 }} {{ template "toc-list" (dict "children" .children "depth" (add 1 $depth) ) }} {{ end }}