Table of contents generator in plain JavaScript.