3 个不稳定版本

使用旧的 Rust 2015

0.2.0 2020年8月10日
0.1.1 2018年9月27日
0.1.0 2018年7月29日

#664 in 文本处理


用于 michie

MIT 许可证

17KB
222

markdown-toc

circleci crate.io License: MIT

目录生成器(toc),用 Rust 编写。受 sebdah/markdown-toc 启发。

目录

  1. 目录
  2. 安装
    1. 在 Docker 中运行
    2. 使用 cargo 安装
    3. 自己构建
  3. 使用方法
    1. 生成基本的目录
    2. 自定义列表符号
    3. 限制标题的深度
    4. 排除链接
    5. 自定义目录标题
      1. 排除标题

安装

在 Docker 中运行

docker run -v $PWD:/app -w /app --rm -it pbzweihander/markdown-toc README.md

使用 cargo 安装

cargo install markdown-toc
md-toc README.md

自己构建

git clone https://github.com/pbzweihander/markdown-toc.git
cd markdown-toc
cargo build --release
cargo install --path .
md-toc README.md

使用方法

$ md-toc -h
    Usage: md-toc FILE [options]

      FILE        The Markdown file to parse for table of contents,
                  or "-" to read from stdin

    Options:
        -h, --help          print this help message
            --bullet {str}  Custom bullet of the ToC list. (default: "1.")
            --indent {int}  Indentation of the ToC list. (default: 4)
            --max-depth {int}
                            Max depth of headers to include.
            --min-depth {int}
                            Min depth of headers to include. (default: 0)
            --header {str}  Custom header of the ToC. (default: "## Table of
                            Contents")
            --no-link       Exclude links in ToC
            --no-header     Exclude the header of ToC

生成基本的目录

md-toc README.md

输出

## Table of Contents

1. [markdown-toc](#markdown-toc)
    1. [Table of Contents](#table-of-contents)
    1. [Installation](#installation)
        1. [Run in Docker](#run-in-docker)
        1. [Install with cargo](#install-with-cargo)
        1. [Build yourself](#build-yourself)
    1. [Usage](#usage)
        1. [Generating basic ToC](#generating-basic-toc)
        1. [Customizing bullets](#customizing-bullets)
        1. [Limiting the depth of headers](#limiting-the-depth-of-headers)
        1. [Excluding links](#excluding-links)
        1. [Customizing header of ToC](#customizing-header-of-toc)
            1. [Excluding header](#excluding-header)

自定义列表符号

md-toc README.md --bullet "-" --indent 2

输出

## Table of Contents

- [markdown-toc](#markdown-toc)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
    - [Run in Docker](#run-in-docker)
    - [Install with cargo](#install-with-cargo)
    - [Build yourself](#build-yourself)
- [Usage](#usage)
    - [Generating basic ToC](#generating-basic-toc)
    - [Customizing bullets](#customizing-bullets)
    - [Limiting the depth of headers](#limiting-the-depth-of-headers)
    - [Excluding links](#excluding-links)
    - [Customizing header of ToC](#customizing-header-of-toc)
    - [Excluding header](#excluding-header)

限制标题的深度

md-toc README.md --min-depth 1 --max-depth 2

输出

## Table of Contents

1. [Table of Contents](#table-of-contents)
1. [Installation](#installation)
    1. [Run in Docker](#run-in-docker)
    1. [Install with cargo](#install-with-cargo)
    1. [Build yourself](#build-yourself)
1. [Usage](#usage)
    1. [Generating basic ToC](#generating-basic-toc)
    1. [Customizing bullets](#customizing-bullets)
    1. [Limiting the depth of headers](#limiting-the-depth-of-headers)
    1. [Excluding links](#excluding-links)
    1. [Customizing header of ToC](#customizing-header-of-toc)
md-toc README.md --no-link

输出

## Table of Contents

1. markdown-toc
    1. Table of Contents
    1. Installation
        1. Run in Docker
        1. Install with cargo
        1. Build yourself
    1. Usage
        1. Generating basic ToC
        1. Customizing bullets
        1. Limiting the depth of headers
        1. Excluding links
        1. Customizing header of ToC
            1. Excluding header

自定义目录标题

md-toc README.md --header "# ToC"

输出

# ToC

1. [markdown-toc](#markdown-toc)
    1. [Table of Contents](#table-of-contents)
    1. [Installation](#installation)
        1. [Run in Docker](#run-in-docker)
        1. [Install with cargo](#install-with-cargo)
        1. [Build yourself](#build-yourself)
    1. [Usage](#usage)
        1. [Generating basic ToC](#generating-basic-toc)
        1. [Customizing bullets](#customizing-bullets)
        1. [Limiting the depth of headers](#limiting-the-depth-of-headers)
        1. [Excluding links](#excluding-links)
        1. [Customizing header of ToC](#customizing-header-of-toc)
            1. [Excluding header](#excluding-header)

排除标题

md-toc README.md --no-header

输出

1. [markdown-toc](#markdown-toc)
    1. [Table of Contents](#table-of-contents)
    1. [Installation](#installation)
        1. [Run in Docker](#run-in-docker)
        1. [Install with cargo](#install-with-cargo)
        1. [Build yourself](#build-yourself)
    1. [Usage](#usage)
        1. [Generating basic ToC](#generating-basic-toc)
        1. [Customizing bullets](#customizing-bullets)
        1. [Limiting the depth of headers](#limiting-the-depth-of-headers)
        1. [Excluding links](#excluding-links)
        1. [Customizing header of ToC](#customizing-header-of-toc)
            1. [Excluding header](#excluding-header)

依赖项

~455KB