It feels like `append_toc` and `finalize_toc` can be smushed down into a single private method `build_toc`. Thoughts?