Table of Contents

July 31, 2019 · View on GitHub

markdown-toc

  _ __ ___   __ _ _ __| | ____| | _____      ___ __       | |_ ___   ___ 
 | '_ ` _ \ / _` | '__| |/ / _` |/ _ \ \ /\ / / '_ \ _____| __/ _ \ / __|
 | | | | | | (_| | |  |   < (_| | (_) \ V  V /| | | |_____| || (_) | (__ 
 |_| |_| |_|\__,_|_|  |_|\_\__,_|\___/ \_/\_/ |_| |_|      \__\___/ \___|
 

Maven Central Build Status Coverage Status

Markdown-to-toc can be used to generate a directory of the Markdown page for github page rendering.

  • README

中文说明 | English Readme

note

For the title, there are two kinds of md grammar [setext] (http://docutils.sourceforge.net/mirror/setext.html) And [atx] (http://www.aaronsw.com/2002/atx/) mode.

atx form is only supported temporarily.

The Features

  • Github Markdown file one click to generate the directory

  • fluent and elegant writing is supported

  • support multiple generation

  • support the generation of duplicate titles

  • supports filtering of special characters

  • supports specifying different file codes

  • supports batch processing of files in folders (you can specify whether subfolder files are included)

  • supports writing to files, returns contents of the directory, and allows users to process by themselves

  • support multi-threads for directory files.

  • support i18n

  • support gen toc number

environmental dependence

the JDK

JDK8+, make sure the JDK is set up correctly.

Note: If you are use jdk7,download this code and compile by yourself.

Maven

Jars are managed uniformly using Maven.

Change log

change log

quick start

maven introduced

<dependency>
    <groupId>com.github.houbb</groupId>
    <artifactId>markdown-toc</artifactId>
    <version>${maven-version}</version>
</dependency>

md file

The project for the support of md file name suffix .md or .markdown

quick start

  • single file
AtxMarkdownToc.newInstance().genTocFile(path);

Where path is the path of md file

  • specified folder
AtxMarkdownToc.newInstance().genTocFile(path);

Where path is the parent class folder of the md file

attribute configuration

  • code examples
AtxMarkdownToc.newInstance()
                .charset("UTF-8")
                .write(true)
                .subTree(true);

attribute description

序号属性默认值说明
1charsetUTF-8file charset
2writetruewill toc written to the file (default write)
3subTreetruedoes it include subfolders(default includes)
3orderfalsedoes it gen toc order num(default false, since 1.0.5)

return value description

genTocFile() returns TocGen, genTocDir() returns List

  • TocGen attribute description
序号属性类型说明
1filePathStringcurrent md filePath
2tocLinesListcurrent md file toc content

test cases

a single file - directory to generate test cases

folder - directory to generate test cases

other

[Issues & Bugs] (https://github.com/houbb/markdown-toc/issues)