Numbered Headings
Last modified by Vincent Massol on 2021/01/18 00:06
![]() | Displays numbered headings in the wiki |
Type | XAR |
Developed by | |
Active Installs | 132 |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Insert the following in your page to have the headings automatically numbered:
{{numberedheadings/}}
To extend this to the whole wiki:
- edit objects of page Macros.NumberedHeadingsStylesheetExtensionMacro
- navigate to the XWiki.StyleSheetExtension object
- choose "Use this extension" : "Always" instead of "On demand"
- Then all headings will be numbered without need of adding the {{numberedheadings/}} in each page
Sample result:
Implementation
This macro adds the following CSS to the page where it's used:
#xwikicontent {
counter-reset: mynum-h1 !important;
}
#xwikicontent h1 {
counter-reset: mynum-h2 !important;
}
#xwikicontent h1:before {
content: counter(mynum-h1) " " !important;
counter-increment: mynum-h1 !important;
}
#xwikicontent h2 {
counter-reset: mynum-h3 !important;
}
#xwikicontent h2:before {
content: counter(mynum-h1) "." counter(mynum-h2) " " !important;
counter-increment: mynum-h2 !important;
}
#xwikicontent h3 {
counter-reset: mynum-h4 !important;
}
#xwikicontent h3:before {
content: counter(mynum-h1) "." counter(mynum-h2) "." counter(mynum-h3) " " !important;
counter-increment: mynum-h3 !important;
}
#xwikicontent h4 {
counter-reset: mynum-h5 !important;
}
#xwikicontent h4:before {
content: counter(mynum-h1) "." counter(mynum-h2) "." counter(mynum-h3) "." counter(mynum-h4) " " !important;
counter-increment: mynum-h4 !important;
}
#xwikicontent h5 {
counter-reset: mynum-h6 !important;
}
#xwikicontent h5:before {
content: counter(mynum-h1) "." counter(mynum-h2) "." counter(mynum-h3) "." counter(mynum-h4) "." counter(mynum-h5) " " !important;
counter-increment: mynum-h5 !important;
}
#xwikicontent h6 {
}
#xwikicontent h6:before {
content: counter(mynum-h1) "." counter(mynum-h2) "." counter(mynum-h3) "." counter(mynum-h4) "." counter(mynum-h5) "." counter(mynum-h6) " " !important;
counter-increment: mynum-h6 !important;
}
counter-reset: mynum-h1 !important;
}
#xwikicontent h1 {
counter-reset: mynum-h2 !important;
}
#xwikicontent h1:before {
content: counter(mynum-h1) " " !important;
counter-increment: mynum-h1 !important;
}
#xwikicontent h2 {
counter-reset: mynum-h3 !important;
}
#xwikicontent h2:before {
content: counter(mynum-h1) "." counter(mynum-h2) " " !important;
counter-increment: mynum-h2 !important;
}
#xwikicontent h3 {
counter-reset: mynum-h4 !important;
}
#xwikicontent h3:before {
content: counter(mynum-h1) "." counter(mynum-h2) "." counter(mynum-h3) " " !important;
counter-increment: mynum-h3 !important;
}
#xwikicontent h4 {
counter-reset: mynum-h5 !important;
}
#xwikicontent h4:before {
content: counter(mynum-h1) "." counter(mynum-h2) "." counter(mynum-h3) "." counter(mynum-h4) " " !important;
counter-increment: mynum-h4 !important;
}
#xwikicontent h5 {
counter-reset: mynum-h6 !important;
}
#xwikicontent h5:before {
content: counter(mynum-h1) "." counter(mynum-h2) "." counter(mynum-h3) "." counter(mynum-h4) "." counter(mynum-h5) " " !important;
counter-increment: mynum-h5 !important;
}
#xwikicontent h6 {
}
#xwikicontent h6:before {
content: counter(mynum-h1) "." counter(mynum-h2) "." counter(mynum-h3) "." counter(mynum-h4) "." counter(mynum-h5) "." counter(mynum-h6) " " !important;
counter-increment: mynum-h6 !important;
}
Tested on
This extension has been tested with the following configurations.
Extension Version | XWiki Flavor | Notes |
---|---|---|
1.0 | XWiki Enterprise 3.5 | Not compatible with IE6 / IE7 |
1.1 | XWiki Enterprise 6.0.1 |
Release Notes
v1.1
bugfix : version 1.0 was not working due to badly renamed page ...
v1.0
Initial release