Skip to content

Commit

Permalink
fix(tooling): partial fix for firefox numbering (filecoin-project#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored Oct 28, 2020
1 parent 1a7c4c7 commit d52fe97
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 44 deletions.
91 changes: 48 additions & 43 deletions assets/plugins/_numbered.scss
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 10 additions & 0 deletions assets/plugins/_toc.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
.book-menu nav ol {
li {
&.active {
&::before {
content: '';
color: var(--cl-blue);
}
}
}
}
.toc {
height: 100%;
> ol {
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ol class="depth-{{ .depth }}{{ if ge .depth 2 }} maybe-hide{{ end }}">
{{ range .children }}
<li>
<a href="#{{ .id }}">{{.text}}</a>
<a href="#{{ .id }}">{{.number}} {{.text}}</a>
{{ if gt (len .children) 0 }}
{{ template "toc-list" (dict "children" .children "depth" (add 1 $depth) ) }}
{{ end }}
Expand Down

0 comments on commit d52fe97

Please sign in to comment.