Coder Social home page Coder Social logo

alenfun / markdown-toc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from houbb/markdown-toc

0.0 1.0 0.0 171 KB

🎄Generate toc for github markdown file.(为 markdown 文件生成 toc 目录)

License: Apache License 2.0

Batchfile 3.29% Shell 5.50% Java 91.21%

markdown-toc's Introduction

Table of Contents

markdown-toc

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

Maven Central Build Status Coverage Status

Markdown-toc 可以用来生成 markdown 页面的目录,便于 github 页面展现。

  • 文档

中文说明 | English Readme

备注

对于标题,md 有两种语法 setextatx 模式。

暂时只支持 atx 形式。

变更日志

变更日志

Features

  • Github Markdown 文件一键生成目录

  • 支持 fluent 优雅的写法

  • 支持多次生成

  • 支持重复标题的生成

  • 支持特殊字符的过滤

  • 支持指定不同的文件编码

  • 支持文件夹的文件批量处理(可指定是否包含子文件夹文件)

  • 支持是否写入文件,可返回目录的内容,便于用户自行处理

  • 支持多线程写文件

  • 支持 i18n

环境依赖

JDK

JDK7+, 请确保 JDK 设置正确。

Maven

Jar 使用 Maven 进行统一管理。

快速入门

maven 引入

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

md 文件

本项目支持的 md 文件后缀名称为 .md 或者 .markdown

快速开始

  • 单个文件
AtxMarkdownToc.newInstance().genTocFile(path);

其中 path 为 md 文件的路径

  • 指定文件夹
AtxMarkdownToc.newInstance().genTocFile(path);

其中 path 为 md 文件的父类文件夹

属性配置

  • 代码示例
AtxMarkdownToc.newInstance()
                .charset("UTF-8")
                .write(true)
                .subTree(true);

属性说明

序号 属性 默认值 说明
1 charset UTF-8 文件编码
2 write true 是否将 toc 写入文件(默认写入)
3 subTree true 是否包含子文件夹的文件(默认包含)

返回值说明

genTocFile() 返回 TocGen,genTocDir() 返回 List

  • TocGen 属性说明
序号 属性 类型 说明
1 filePath String 当前 md 的文件路径
2 tocLines List 当前 md 文件对应的目录内容

测试案例

单个文件-目录生成测试案例

文件夹-目录生成测试案例

其他

Issues & Bugs

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.