Fix gen_toc references when the title contains brackets