Skip to content

Jeff-Tian/markdown-it-book-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-it-book-plugin


A markdown-it plugin for book or thesis writers.

Features

  • Auto numbered images
  • Auto numbered tables
  • Auto numbered headings
  • Auto numbered images made by mermaid source code

Installation

yarn add markdown-it-book-plugin

Usage

Basic:

const MarkdownIt = require("markdown-it");
const md = new MarkdownIt();

md.use(require('markdown-it-book-plugin'));

Advanced with options

If you want to prepend the chapter number to the heading, you can use the following options:

const MarkdownIt = require("markdown-it");
const md = new MarkdownIt();

md.use(require('markdown-it-book-plugin'), {
    mainCounterTag: 'h3',
    updateMainCounter: true,
});

You can even customize the counter for each heading, for example, skip the first two chapters:

const MarkdownIt = require("markdown-it");
const md = new MarkdownIt();

md.use(require('markdown-it-book-plugin'), {
    mainCounterTag: 'h3',
    updateMainCounter: ['', '', 1, 2, 3, 4],
});

More examples see

Who is using?

Contributing

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'feat: add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request :D

💵 Questions

Feel free to contact me, I'd love to help.

向我咨询