Getting heading numbers in Google Docs word processor

Google Docs word processor is great but lacks a few essential features. Heading numbering is one of them... however this is an easy way to overcome it that seems to work GREAT. This Javascript code numbers the headings in the same format of a formal document. Just add it as a shortcut on the bookmark taskbar and job done: javascript:(function(){var doc=window.frames['wys_frame'].document;var elements=doc.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]+/,'')}})(); Each time the numbering needs updating just hit the bookmark. Brilliant.

Comments

Popular posts from this blog

PHP timezones explained

iPhone Internet Tethering settings