All Projects → remarkjs → Remark Toc

remarkjs / Remark Toc

Licence: mit
plugin to generate a Table of Contents (TOC)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Remark Toc

Github Markdown Toc.go
Easy TOC creation for GitHub README.md (in go)
Stars: ✭ 387 (+134.55%)
Mutual labels:  toc, markdown
Github Markdown Toc
Easy TOC creation for GitHub README.md
Stars: ✭ 2,734 (+1556.97%)
Mutual labels:  toc, markdown
Editor.md
The open source embeddable online markdown editor (component).
Stars: ✭ 11,741 (+7015.76%)
Mutual labels:  toc, markdown
Markdown Preview Enhanced
One of the 'BEST' markdown preview extensions for Atom editor!
Stars: ✭ 3,478 (+2007.88%)
Mutual labels:  toc, markdown
Vim Markdown Toc
A vim 7.4+ plugin to generate table of contents for Markdown files.
Stars: ✭ 427 (+158.79%)
Mutual labels:  toc, markdown
Markdown Toc
Generate a markdown TOC (table of contents) for a README or any markdown files, using remarkable. Used by assemble, verb, and lots of other projects on GitHub. API and CLI.
Stars: ✭ 1,185 (+618.18%)
Mutual labels:  toc, markdown
Markdown Toc
🎄Generate toc for github markdown file.(为 markdown 文件生成 toc 目录)
Stars: ✭ 144 (-12.73%)
Mutual labels:  toc, markdown
Uxdm
🔀 UXDM helps developers migrate data from one system or format to another.
Stars: ✭ 159 (-3.64%)
Mutual labels:  markdown
Awesome Scientific Writing
⌨️ A curated list of awesome tools, demos and resources to go beyond LaTeX
Stars: ✭ 162 (-1.82%)
Mutual labels:  markdown
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-4.24%)
Mutual labels:  markdown
Showdown
A bidirectional Markdown to HTML to Markdown converter written in Javascript
Stars: ✭ 12,137 (+7255.76%)
Mutual labels:  markdown
Java Markdown Generator
Java library to generate markdown
Stars: ✭ 159 (-3.64%)
Mutual labels:  markdown
Roro
The Ruby on Rails Oceania (RORO) Sydney meetup
Stars: ✭ 165 (+0%)
Mutual labels:  markdown
Pervane
Plain text file based note taking and knowledge base building tool, markdown editor, simple browser IDE.
Stars: ✭ 159 (-3.64%)
Mutual labels:  markdown
Hastyscribe
Self-contained markdown compiler generating self-contained HTML documents
Stars: ✭ 166 (+0.61%)
Mutual labels:  markdown
Mkdocs
Project documentation with Markdown.
Stars: ✭ 13,346 (+7988.48%)
Mutual labels:  markdown
Blog
Code for my personal blog built with Gatsby
Stars: ✭ 167 (+1.21%)
Mutual labels:  markdown
Python Markdown Editor
Standalone editor for your markdown files
Stars: ✭ 164 (-0.61%)
Mutual labels:  markdown
Vue Styleguidist
Created from react styleguidist for Vue Components with a living style guide
Stars: ✭ 2,133 (+1192.73%)
Mutual labels:  markdown
Textlint
The pluggable natural language linter for text and markdown.
Stars: ✭ 2,158 (+1207.88%)
Mutual labels:  markdown

remark-toc

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to generate a table of contents.

Install

npm:

npm install remark-toc

Use

Say we have the following file, example.md:

# Alpha

## Table of Contents

## Bravo

### Charlie

## Delta

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var remark = require('remark')
var toc = require('remark-toc')

remark()
  .use(toc)
  .process(vfile.readSync('example.md'), function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

Now, running node example yields:

# Alpha

## Table of Contents

-   [Bravo](#bravo)

    -   [Charlie](#charlie)

-   [Delta](#delta)

## Bravo

### Charlie

## Delta

API

remark().use(toc[, options])

Generate a table of contents.

  • Looks for the first heading containing 'Table of Contents', 'toc', or 'table-of-contents' (case insensitive, supports alt/title attributes for links and images too)
  • Removes all following contents until an equal or higher heading is found
  • Inserts a list representation of the hierarchy of following headings
  • Links from the table of contents to following headings, using the same slugs as GitHub

Note: if you’re later compiling to HTML, you still need to add anchors to headings. Previously that was done by this plugin as well, but now you must .use(slug) to include remark-slug explicitly.

options

All options are passed to mdast-util-toc, with the exception that heading defaults to 'toc|table[ -]of[ -]contents?'.

Security

Use of remark-toc involves user content and changes the tree, so it can open you up for a cross-site scripting (XSS) attack.

Existing nodes are copied into the table of contents. The following example shows how an existing script is copied into the table of contents.

The following Markdown:

# Table of Contents

## Bravo<script>alert(1)</script>

## Charlie

Yields:

# Table of Contents

-   [Bravo<script>alert(1)</script>](#bravoscriptalert1script)
-   [Charlie](#charlie)

## Bravo<script>alert(1)</script>

## Charlie

This may become a problem if the Markdown is later transformed to rehype (hast) or opened in an unsafe Markdown viewer.

Related

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].