- Makes sense to do it client-side.
- Makes sense that same code and output can be for wiki & WYSIWYG
Please check out the other existing libraries such as the ones list at Maketoc to check which one makes most sense in the long term.
FYI, Tiki 13 is moving to Bootstrap so jquery.tocify.js may be of value:
jquery.tocify.js: A jQuery Table of Contents plugin that can be themed with Twitter Bootstrap or jQueryUI.
And you are warmly welcomed to commit directly to trunk : How to get commit access