Are section numbers deprecated for (md) books?

The mdbook tool supports numbers in the TOC, but not in the text itself. All of my printed books are numbered, so I added section numbers manually to the "Rust for C-Programmers" book. The problem is, that this makes it difficult to reorder chapters. From a mdbook issue request, I got the information that with a preprocessor it might be possible to number book sections automatically. But that would be some effort for me to create such a plugin, and it may finally fail. Actually most Rust books seems to be unnumbered. So if this is just the new modern style, I might just remove the numbers from the text (with some RegExp processing). Or are the missing numbers more a consequence from the fact that mdbook does not support them? Because, most books for other programming languages seems to have still numbered sections.

The other mdbook question: Do we have an idea how for the official book the red icon in the code examples has be done? I tried to mark code examples with "rust,should_panic" but did not get such images.

As no one was able to convince me that numbered section headings are deprecated now, I have decided to keep the numbering for now. So I created a plain preprocessor for mdbook, see GitHub - StefanSalewski/mdbook-section-numbers: Preprocessor for mdbook to generate numbers for the section headings

This is just a plain adaption of the original example preprocessor from mdBook/examples/remove-emphasis/mdbook-remove-emphasis/src/main.rs at master · rust-lang/mdBook · GitHub

I do not yet understand all of the original code, and I have done only minimal testing. But it seems to work, and it is at least a start for people desiring to number their books as well.

1 Like