docusaurus-numbered-headings
Version:
A Docusaurus plugin that automatically adds numbered headings with support for ISO 2145 and USA Classic numbering conventions
93 lines (76 loc) • 2.11 kB
CSS
/* Docusaurus Numbered Headings Plugin Styles - ISO 2145 Convention */
/* Format: 1, 1.1, 1.1.1, 1.1.1.1 (decimal numbering) */
/* body {
counter-reset: h2counter;
} */
/* Starts on h2 because h1 is reserved for the title of the page in Docusaurus. */
h2 {
counter-increment: h2counter;
counter-reset: h3counter;
}
h2::before {
content: counter(h2counter) ". ";
}
h3 {
counter-increment: h3counter;
counter-reset: h4counter;
}
h3::before {
content: counter(h2counter) "." counter(h3counter) ". ";
}
h4 {
counter-increment: h4counter;
counter-reset: h5counter;
}
h4::before {
content: counter(h2counter) "." counter(h3counter) "." counter(h4counter) ". ";
}
h5 {
counter-increment: h5counter;
}
h5::before {
content: counter(h2counter) "." counter(h3counter) "." counter(h4counter) "."
counter(h5counter) ". ";
}
/* Table of Contents Numbering - ISO 2145 Convention */
ul.table-of-contents > li::before {
content: counter(toc-h2) ". ";
}
ul.table-of-contents > li > ul > li::before {
content: counter(toc-h2) "." counter(toc-h3) ". ";
}
ul.table-of-contents > li > ul > li > ul > li::before {
content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) ". ";
}
ul.table-of-contents > li > ul > li > ul > li > ul > li::before {
content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) "."
counter(toc-h5) ". ";
}
/* Disable ISO 2145 numbering within elements with disable_numbered_headings class */
.disable_numbered_headings h2::before,
.disable_numbered_headings h3::before,
.disable_numbered_headings h4::before,
.disable_numbered_headings h5::before {
content: none ;
}
/* Disable table of contents numbering for ISO 2145 within disable_numbered_headings */
.disable_numbered_headings ul.table-of-contents > li::before,
.disable_numbered_headings ul.table-of-contents > li > ul > li::before,
.disable_numbered_headings
ul.table-of-contents
> li
> ul
> li
> ul
> li::before,
.disable_numbered_headings
ul.table-of-contents
> li
> ul
> li
> ul
> li
> ul
> li::before {
content: none ;
}