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

Customize TOC style and template #403

Open
muuvmuuv opened this issue Mar 19, 2019 · 10 comments
Open

Customize TOC style and template #403

muuvmuuv opened this issue Mar 19, 2019 · 10 comments
Labels
Area: Table of contents Pertaining to table of contents (TOC generation and detection, related heading operations). Issue: Feature Something brand new.

Comments

@muuvmuuv
Copy link

Feature request

In my README I prefer to use the TOC-style where the links are listed below each other (like it is now) but in the CHANGELOG I prefer it inline next to each other divided with a middot (·).

Would be nice to have an option here to insert different styles of TOC in a file or have an option in settings.json to create our own templates. 😁

Style1:

- [Headline](#headline)
- [Subhead](#subhead)

Possible Style2:

[Headline](#headline) · [Subhead](#subhead)

How templating could work:

{
    "markdown.extension.toc.marker": "-",
    "markdown.extension.toc.template": "{marker} [{name}](#{link})",
    "markdown.extension.toc.template": "{list} [{name}](#{link})", // for ordered list

    "markdown.extension.toc.marker": "·",
    "markdown.extension.toc.markerSkipLast": true,
    "markdown.extension.toc.template": "[{name}](#{link}) {marker}",
}
@yzhang-gh
Copy link
Owner

Sounds interesting, although technically it is kind of hard to implement. Allowing custom TOC will make the TOC detection much harder.

I would suggest generating TOC with command and then doing some simple editing with VSCode powerful multi-cursor feature (and optionally "join lines" command).

toc

@yzhang-gh yzhang-gh added the Issue: Feature Something brand new. label Mar 19, 2019
@muuvmuuv
Copy link
Author

@yzhang-gh that is how I do it ATM but let a plugin do this job automatically would be awesome!

Why does it make the detection harder? I would take a look and see how far I come. It is really something that would same me some time :)

@yzhang-gh
Copy link
Owner

Thanks. If you have any idea just run it by me.

@muuvmuuv
Copy link
Author

@yzhang-gh pushed my first attempt. Just an idea but what about using prettier in the repo to keep everything clean? I use husky and pretty-clean in most of my projects to keep a minimal beautification automatically and with VSCode even on-save. It is easy to set up and you can customize prettier very easy.

@yzhang-gh
Copy link
Owner

Actually, I am using the vscode built-in formatter. As I notice, the code style mainly changed in two aspects:

  • Indentation. I personally would like to keep the 4 spaces indentation which gives better visual hierarchy.
  • The double quotation in the import clause rather than single. I am fine with it.

Could you please get rid of the style changes in this PR and make a separate one for it?
Because now all the things get mixed up and are hard to review. Many thanks.

@muuvmuuv
Copy link
Author

Yep sure @yzhang-gh. I will add an .editorconfig to prevent this in the future. Everyone has their own style and this would keep yours forced for your project.

@muuvmuuv
Copy link
Author

Okay @yzhang-gh I made the changes. Just have a look in Revert back setting changes in package.json for the changes I made in package.json and in This are the changes made to toc for the changes I made in the toc-file

@Lemmingh Lemmingh added the Area: Table of contents Pertaining to table of contents (TOC generation and detection, related heading operations). label Nov 24, 2020
@Lemmingh Lemmingh changed the title [TOC] different styles Customize TOC style and template Aug 25, 2021
@Lemmingh
Copy link
Collaborator

Lemmingh commented Nov 9, 2021

Well, I actually think this is the job of presentation, rather than editor. You can render a list in any shape with CSS.

@mxstrand
Copy link

Is there an option to simply remove bullets from the TOC? Thank you for your work.

@yzhang-gh
Copy link
Owner

yzhang-gh commented Dec 1, 2022

The TOC is just an HTML list, and its style can be changed with CSS https://developer.mozilla.org/en-US/docs/Web/CSS/list-style

e.g. adding

<style>
    ul { list-style: none; }
</style>

in the Markdown file will remove bullets of all the unordered lists. To apply it only on the TOC, you may apply some CSS selectors depending on your document structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Table of contents Pertaining to table of contents (TOC generation and detection, related heading operations). Issue: Feature Something brand new.
Projects
None yet
Development

No branches or pull requests

4 participants