Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

feature rquest: nested number of TOC #74

Open
hua03 opened this issue Aug 8, 2022 · 1 comment
Open

feature rquest: nested number of TOC #74

hua03 opened this issue Aug 8, 2022 · 1 comment

Comments

@hua03
Copy link

hua03 commented Aug 8, 2022

The numbers of child is independent, like:

1.
  1.
  2.
2.
  1.

Most of the time, I hope they are related, like:

1
  1.1
  1.2
  1.3
2
  2.1
  2.2

Tips: CSS method counters can be used to solve this problem, it is recommended to add an list style nested number

.dynamic-toc ol {
  counter-reset: tocCounter;
}

.dynamic-toc li {
  counter-increment: tocCounter;
}

.dynamic-toc li::marker {
  content: counters(tocCounter, '.') '  ';
}
@dbarenholz
Copy link

Courtesy of sailKite#4202 in the discord for another option:

/* inside Dynamic ToC */
.dynamic-toc ol {
    list-style-type: none;
}
.dynamic-toc ol {
    counter-reset: decimal;
}
.dynamic-toc ol > li {
    display: block;
}
.dynamic-toc ol > li::before {
    content: counters(decimal, ".")  " ";
    counter-increment: decimal;
    color: var(--text-a) /* put your text var here or hardcode the color */;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants