Hi All,
It seems like a very very long pending issue with Confluence.
I found something that sort of works
http://philarcher.org/diary/2011/numbering/
The script works really really well, except the headings start at 3 and everything (even things in the sidebar) get numbered. It will be awesome if someone can figure out how to get this working. I know that there are free plugins, but they clutter up the document and remove the clarity. If we get this working, we can simply put this into <head> and then bingo, everything is right the way it should be.
window.onload = function () { var elements=document.getElementsByTagName( '*' ); var numbers=[ 0 , 0 , 0 , 0 , 0 , 0 , 0 ]; for (var i in elements) { var e=elements[i]; if (!e||!e.tagName||!e.tagName.match(/^H([ 1 - 6 ])$/)){ continue } var eLevel=RegExp.$ 1 ; var txt= '' ; numbers[eLevel]++; for (var l= 1 ;l<= 6 ;l++) { if (l<=eLevel){ txt+=numbers[l]+ '.' } else { numbers[l]= 0 ; } } e.textContent=txt+ ' ' +e.textContent.replace(/^[ 0 - 9 \.\s]+/, '' ); } } |
To try this,
Put the current script in the HTML macro at the end of the page.
I think we need to change this line
var elements=document.getElementsByTagName('*');
The document should be replaced by something that confluence knows as 'page contents'. Please see if you guys can solve this!
Community moderators have prevented the ability to post new answers.
Atlassian didn't implement numbered headings because they're not that useful on web pages, and that's what Confluence is for.
Your code plays tricks with the display, but there's a better option which enables them to work as you'd expect in most areas, not just display - https://marketplace.atlassian.com/plugins/nl.avisi.confluence.plugins.numberedheadings/cloud/overview
I have used the plugin and do agree that it works, but I don't like the fact that one needs to add the content into the macro body. I need a much simple solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have released Auto Numbered Headings plugin https://marketplace.atlassian.com/1219286 which number headings in single click of a button for whole space. Applying or removing numbers is just a click away. It works well for web pages at Confluence as well as when files are exported out of Confluence.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.