Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
May 11, 2021

Conversation

zergar
Copy link
Contributor

@zergar zergar commented Jun 1, 2020

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)

…every note

Signed-off-by: Gereon Dusella <git@gereondusella.de>
@zergar
Copy link
Contributor Author

zergar commented Jun 1, 2020

could resolve #368

@Yukaii
Copy link
Member

Yukaii commented Jun 3, 2020

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

…toc depth

Signed-off-by: Gereon Dusella <git@gereondusella.de>
@zergar
Copy link
Contributor Author

zergar commented Jun 3, 2020

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.

Signed-off-by: Gereon Dusella <git@gereondusella.de>
@zergar
Copy link
Contributor Author

zergar commented Jun 3, 2020

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
Signed-off-by: Gereon Dusella <git@gereondusella.de>
Signed-off-by: Gereon Dusella <git@gereondusella.de>
Signed-off-by: Gereon Dusella <git@gereondusella.de>
@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
lib/config/environment.js Outdated Show resolved Hide resolved
@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 <yukaihuangtw@gmail.com>
Signed-off-by: Gereon Dusella <git@gereondusella.de>
@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
Copy link
Contributor Author

zergar commented Sep 23, 2020

@jackycute does this look proper to you?

Copy link
Member

@jackycute jackycute left a comment

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