marp-team / marp-core

The core of Marp converter
MIT License
766 stars 129 forks source link

Feature - directive to create TOC #136

Open melck opened 4 years ago

melck commented 4 years ago

I would like to have a directive to show a TOC with page numbers and link to slide.

Ideally with options to customize level of toc or ignore some title.

What do you think about that ?

yhatt commented 4 years ago

Marp Core is hesitant adding any more features without consensus by community. Marp's built-in feature must be based on CommonMark, and we think that built-in features to enhance Markdown would have to be well-known syntax in Markdown and around communities.

TOC is available in over 15 markdown-it plugins, and Marp (Marpit) parser can extend by plugin. You can try to add TOC feature through available plugin by yourself (or can create another TOC plugin optimized for Marp).

// An example of engine.js for Marp CLI's custom engine
const { Marp } = require('@marp-team/marp-core')
const markdownItTableOfContents = require('markdown-it-table-of-contents')

module.exports = opts => new Marp(opts).use(markdownItTableOfContents)

We may consider to add if our community showed TOC plugin is worth to add as built-in feature of Marp.

melck commented 4 years ago

Yes atm i have setup TOC like this, but i think it could be worth to add it as built-in plugin.

yhatt commented 4 years ago

I don't think that. Our core must keep simple and the least features to be continued maintenance. We don't want burning out again by much requests just like an old Marp. It's a reason why adopted pluggable architecture.

Marp would have taken TOC plugin feature as built-in if it was well-known and taken in a lot of Markdown communities, but actually it does not. We are thinking users who want TOC are in the minority so it should provide as a third-party plugin.

melck commented 4 years ago

I understand better. This is mainly for use in vscode and at the moment external plugins are not supported. I will wait for the external engine support by the vscode plugin.

cmi1993 commented 1 year ago

If I use Marp in vscode ,if there has any vscode plugins that can offer TOC feature?any Recommend?

Chiogros commented 1 month ago

A tip to get a clickable TOC: use links to page's anchors.


<!-- _class: toc -->

# Table of content

1. [What is Marp](#what-is-marp)
2. [Why this theme](#why-this-theme)
3. [Available features](#available-features)

---

# What is Marp

---

# Why this theme

---

# Available features