Skip to content

Set TOC depth freely for every note by using YAML metadata or an option within [toc]#1532

Merged
Yukaii merged 7 commits into
hackmdio:developfrom
freitagsrunde:feature/customTocLevel
May 11, 2021
Merged

Set TOC depth freely for every note by using YAML metadata or an option within [toc]#1532
Yukaii merged 7 commits into
hackmdio:developfrom
freitagsrunde:feature/customTocLevel

Conversation

@zergar

@zergar zergar commented Jun 1, 2020

Copy link
Copy Markdown
Contributor

This commit allows one to set the depth of the table of contents freely by means of YAML metadata or an option directly within the [toc] tag (e.g. [toc maxLevel=4]. The default level can also be set by means of the environment variable CMD_DEFAULT_TOC_DEPTH, this variable defaults to 3. The toc depth of the automatically generated toc can only be set by setting the level in the YAML or below.

The precedence of the toc depth is as follows (highest to lowest): [toc maxLevel=4] > YAML metadata > CMD_DEFAULT_TOC_DEPTH > 3 (default value)

codimd-toc-example-customtoc

Optional Features

  • It might be nice to set a default depth with an environment variable, though I'm unsure how to access them from the frontend (as I found no example)

@zergar

zergar commented Jun 1, 2020

Copy link
Copy Markdown
Contributor Author

could resolve #368

@Yukaii

Yukaii commented Jun 3, 2020

Copy link
Copy Markdown
Member

It might be nice to set a default depth with an environment variable, though I'm unsure how to access them from the frontend (as I found no example)

For now, you can take a look at PR 1306 to see how it pass environment variable config to frontend: #1306

@zergar

zergar commented Jun 3, 2020

Copy link
Copy Markdown
Contributor Author

For now, you can take a look at PR 1306 to see how it pass environment variable config to frontend: #1306

Thank you very much for the tip, I've added the feature accordingly.

@zergar

zergar commented Jun 3, 2020

Copy link
Copy Markdown
Contributor Author

to finish this up, I've added the option to set a custom TOC level within the toc tag, e.g. [toc maxLevel=4]. I've updated the PR description accordingly.

@zergar zergar changed the title Set TOC depth freely for every note by using YAML metadata Set TOC depth freely for every note by using YAML metadata or an option within [toc] Jun 3, 2020
@Yukaii Yukaii added this to the Next milestone Jul 10, 2020
@Yukaii Yukaii temporarily deployed to codimd-feature-customto-dppyxy July 10, 2020 02:35 Inactive
Comment thread lib/config/environment.js Outdated
@Yukaii Yukaii temporarily deployed to codimd-feature-customto-dppyxy July 12, 2020 22:34 Inactive
seems to be set elsewhere

Co-authored-by: Yukai Huang <[email protected]>
Signed-off-by: Gereon Dusella <[email protected]>
@zergar zergar force-pushed the feature/customTocLevel branch from db87701 to 3438c57 Compare July 13, 2020 09:05
@Yukaii Yukaii temporarily deployed to codimd-feature-customto-dppyxy July 13, 2020 09:05 Inactive
@Yukaii Yukaii requested a review from jackycute July 14, 2020 02:27
@zergar

zergar commented Sep 23, 2020

Copy link
Copy Markdown
Contributor Author

@jackycute does this look proper to you?

@jackycute jackycute left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @zergar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants