首页  编辑  

Wiki.js中自动对章节进行编号

Tags: /计算机文档/软件应用技巧/   Date Created:
Wiki.js中,编写章节后,如何自动编号?
在wiki.js的系统设置当中,Theme(主题), Code Injection(代码注入)部分,CSS覆盖:

div.contents .number {
  counter-reset: h1s
}
.number h1 {
  counter-reset: h2s
}
.number h1::before {
  content: counter(h1s) ". ";
  counter-increment: h1s
}
.number h2 {
  counter-reset: h3s
}
.number h2::before {
  content: counter(h1s) "." counter(h2s) ". ";
  counter-increment: h2s
}
.number h3 {
  counter-reset: h4s
}
.number h3::before {
  content: counter(h1s) "." counter(h2s) "." counter(h3s) ". ";
  counter-increment: h3s
}
.number h4 {
  counter-reset: h5s
}
.number h4::before {
  content: counter(h1s) "." counter(h2s) "." counter(h3s) "." counter(h4s);
  counter-increment: h4s
}
.number h5::before {
  content: counter(h1s) "." counter(h2s) "." counter(h3s) "." counter(h4s) "." counter(h5s);
  counter-increment: h5s
}

保存后就可以了。
  • 如需要使用章节自动编号,请在内容开头增加 <div class="number">,末尾增加 </div>