Giter VIP home page Giter VIP logo

intoc's Introduction

intoc

TOC generator for Markdown.

Feature

  • Python based.
  • No WebAPI use.
  • Multiple output ways.
    • Output to the stdout
    • Direct Update(Insert TOC to the next of <!-- toc --> line directly).
  • Support sections written in Japanese.

How to use

$ git clone https://github.com/stakiran/intoc
$ cd intoc
$ python intoc.py -i (Target-Markdown-File)

Create an alias if needed.

Requirement

  • Python 3 (Tested on Python 3.6 and Windows 7+)

CLI

$ python intoc.py -h
usage: intoc.py [-h] -i INPUT [--indent-depth INDENT_DEPTH]
                [--parse-depth PARSE_DEPTH] [--use-asterisk]
                [--use-plain-enum] [--no-linkformat] [--edit]
                [--edit-target EDIT_TARGET]

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        A input filename. (default: None)
  --indent-depth INDENT_DEPTH
                        The number of spaces per a nest in TOC. (default: 2)
  --parse-depth PARSE_DEPTH
                        The depth of the TOC list nesting. If minus then no
                        limit depth. (default: -1)
  --use-asterisk        Use an asterisk `*` as a list grammer. (default:
                        False)
  --use-plain-enum      Not use Markdown grammer, but use simple plain section
                        name listing. (default: False)
  --no-linkformat       Not use `- [text](#anochor)`, but use `- text`.
                        (default: False)
  --edit                If given then insert TOC to the file from "--input".
                        (default: False)
  --edit-target EDIT_TARGET
                        A insertion destination label when --edit given. NOT
                        CASE-SENSITIVE. (default: <!-- TOC)

Samples

Basic

An option -i is required for your input.

$ python intoc.py -i README.md
- [intoc](#intoc)
  - [Feature](#feature)
  - [Install](#install)
  - [Requirement](#requirement)
  - [CLI](#cli)
  - [Samples](#samples)
    - [Basic](#basic)
    - [Depth control](#depth-control)
    - [Use not hyphen but aasterisk](#use-not-hyphen-but-aasterisk)
    - [Direct update](#direct-update)
    - [Plain enumeration](#plain-enumeration)
    - [No link format but keep list grammer](#no-link-format-but-keep-list-grammer)
  - [License](#license)
  - [Author](#author)

Depth control

--indent-depth and --parse-depth.

$ python intoc.py -i README.md --indent-depth 4 --parse-depth 2
- [intoc](#intoc)
    - [Feature](#feature)
    - [Install](#install)
    - [Requirement](#requirement)
    - [CLI](#cli)
    - [Samples](#samples)
    - [License](#license)
    - [Author](#author)

Use not hyphen but aasterisk

--use-asterisk.

$ python intoc.py -i README.md --use-asterisk
* [intoc](#intoc)
  * [Feature](#feature)
  * [Install](#install)
  * [Requirement](#requirement)
  * [CLI](#cli)
  * [Samples](#samples)
    * [Basic](#basic)
    * [Depth control](#depth-control)
    * [Use not hyphen but aasterisk](#use-not-hyphen-but-aasterisk)
    * [Direct update](#direct-update)
    * [Plain enumeration](#plain-enumeration)
    * [No link format but keep list grammer](#no-link-format-but-keep-list-grammer)
  * [License](#license)
  * [Author](#author)

Direct update

Write <!-- toc --> to your input file and use --edit.

$ python intoc.py -i README.md --edit

$ type README.md
# intoc

TOC generator for Markdown.

<!-- toc -->
- [intoc](#intoc)
  - [Feature](#feature)
  - [Install](#install)
  - [Requirement](#requirement)
  - [CLI](#cli)
  - [Samples](#samples)
    - [Basic](#basic)
    - [Depth control](#depth-control)
    - [Use not hyphen but aasterisk](#use-not-hyphen-but-aasterisk)
    - [Direct update](#direct-update)
    - [Plain enumeration](#plain-enumeration)
    - [No link format but keep list grammer](#no-link-format-but-keep-list-grammer)
  - [License](#license)
  - [Author](#author)

## Feature
...

Plain enumeration

--use-plain-enum.

$ python intoc.py -i README.md --use-plain-enum
intoc
Feature
Install
Requirement
CLI
Samples
Basic
Depth control
Use not hyphen but aasterisk
Direct update
Plain Enumeration
License
Author

No link format but keep list grammer

--no-linkformat.

$ python intoc.py -i README.md --no-linkformat
- intoc
  - Feature
  - Install
  - Requirement
  - CLI
  - Samples
    - Basic
    - Depth control
    - Use not hyphen but aasterisk
    - Direct update
    - Plain enumeration
    - No link format but keep list grammer.
  - License
  - Author

License

MIT License

Author

stakiran

intoc's People

Contributors

stakiran avatar

Watchers

James Cloos avatar  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.