Automatic Table Of Contents

Could be implemented in JavaScript? After-all client side, there is a full HTML DOM which in the current implementation we never have server-side. Being expand/collapsible would be really useful.

Perhaps having a server-side DOM for the page could be useful for other reasons though? The only thing that springs to mind right now is spreadsheet functions.