Code Monkey home page Code Monkey logo

mdbook-chapter-zero's Introduction

mdbook-chapter-zero

A preprocessor for mdBook which allows selected (sub-)chapter numbers to begin at 0 instead of 1.

Sometimes you want to have a comprehensive preface with nested subchapters or introductory subchapters in specific chapters in your book. The prefix chapter from mdbook is just not flexible enough to handle this. This preprocessor allows you to have possibly nested (sub-)chapter 0.

Installation

This preprocessor can be installed with:

cargo install mdbook-chapter-zero

Afterwards, add it to your book.toml:

[preprocessor.chapter-zero]

Finally, run mdbook build as usual.

Configuration

This preprocessor accepts two configuration options, with their defaults shown below:

[preprocessor.chapter-zero]
levels = []
marker = "<!-- ch0 -->\n"

To apply 0 indexing to all (sub-)chapters at a specific level, use the levels option:

  • levels: A list of chapter levels which should start at 0 globally. Defaults to [], which means no global changes to chapter numbering. Here are some examples:
    • If set to [0], then the top level chapters will be 0 indexed.
    • If set to [1], then the first level of subchapters of all chapters will be 0 indexed.
    • If set to [0, 1], then the top level chapters and the first level of subchapters of all chapters will be 0 indexed.

All (sub-)chapters affected by levels will ignore the marker.

To apply 0 indexing only to specific (sub-)chapters, use the marker option:

  • marker: A string which signifies that the direct children of this chapter should be 0 indexed. Defaults to <!-- ch0 -->\n.

To apply 0 indexing to children of a specific (sub-)chapter, add the marker anywhere in the Markdown file of the parent chapter. It is better to have it at the top of the file for clarity though.

You can use any string as the marker, not only HTML comments, since the marker will be removed from the Markdown by the preprocessor.

Usage with numbering preprocessors

When used together with processors like mdbook-numeq or mdbook-numthm, which can number items with section number as prefixes, make sure to ensure this preprocessor runs before the numbering preprocessors by including e.g.

[preprocessor.chapter-zero]
before = ["numeq", "numthm"]

to your book.toml.

mdbook-chapter-zero's People

Contributors

xmiaocat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.