badboy / mdbook-toc

A preprocessor for mdbook to add inline Table of Contents support.
Mozilla Public License 2.0
163 stars 20 forks source link

index out of bounds error with empty documents #31

Closed kanedo closed 1 year ago

kanedo commented 1 year ago

When using an empty markdown file, e.g.

# Chapter 1

<!-- toc -->

mdbook build will fail with

2023-01-09 17:20:52 [INFO] (mdbook::book): Book building has started
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/kanedo/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-toc-0.11.0/src/lib.rs:232:24
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2023-01-09 17:20:52 [ERROR] (mdbook::utils): Error: The "toc" preprocessor exited unsuccessfully with exit status: 101 status