marp-core icon indicating copy to clipboard operation
marp-core copied to clipboard

Feature - directive to create TOC

Open melck opened this issue 5 years ago • 6 comments

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 ?

melck avatar Dec 05 '19 12:12 melck

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.

yhatt avatar Dec 11 '19 05:12 yhatt

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

melck avatar Dec 13 '19 11:12 melck

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.

yhatt avatar Dec 17 '19 09:12 yhatt

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.

melck avatar Dec 17 '19 11:12 melck

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

cmi1993 avatar Mar 22 '23 00:03 cmi1993