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

Change markdown.extension.toc.orderedList for a specific file #1401

Open
AresEkb opened this issue Mar 6, 2024 · 3 comments
Open

Change markdown.extension.toc.orderedList for a specific file #1401

AresEkb opened this issue Mar 6, 2024 · 3 comments
Labels
Area: Configuration Requiring changes in configuration schema. Area: Table of contents Pertaining to table of contents (TOC generation and detection, related heading operations).

Comments

@AresEkb
Copy link

AresEkb commented Mar 6, 2024

Proposal

I need TOC to be numbered for the most of the files. So I set markdown.extension.toc.orderedList to true. But headings in some of the files are already numbered, so I need to disable TOC numbering for that exact file. Is it possible?

I guess there could be different ways to implement it:

  • auto-detect existence of heading numbering and don't add duplicate numbers in a TOC
  • allow users to manually change numbering style in a Markdown file and preserve it on TOC update
  • allow markdown.extension.toc.orderedList to be set for specific files (register it as language override setting, see bellow)
  • allow users to add some settings or comments in a Markdown file changing markdown.extension.toc.orderedList
  • make markdown.extension.toc.orderedList similar to markdown.extension.toc.omittedFromToc so it will support per-file settings

Other information

I can create a multi-root workspace and change settings for each folder, but it's too complicated.

The following doesn't work with the error "This setting cannot be applied because it is not registered as language override setting.":

{
  "markdown.extension.toc.orderedList": true,
  "[doc/development/java-code-style.md]": {
    "markdown.extension.toc.orderedList": false,
  }
}

Probably related issues:

@yzhang-gh
Copy link
Owner

Sorry for the late reply and thanks for your detailed analysis.

The core of this is to have a fine-grained configuration model but it requires some effort. For your case, would it be enough if we make markdown.extension.toc.orderedList allowed in the language config scope? Currently it is not set (i.e. the window scope)

"markdown.extension.toc.orderedList": {
"type": "boolean",
"default": false,
"description": "%config.toc.orderedList.description%"
},

We can set it to language-overridable although I haven't fully understand the more and more complicated VS Code APIs 😂.

image

@yzhang-gh yzhang-gh added Area: Configuration Requiring changes in configuration schema. Area: Table of contents Pertaining to table of contents (TOC generation and detection, related heading operations). labels Mar 23, 2024
@AresEkb
Copy link
Author

AresEkb commented Mar 23, 2024

Thanks for the answer!

It seems I was wrong, it doesn't work:

{
  "markdown.extension.toc.orderedList": true,
  "files.insertFinalNewline": true,
  "[doc/development/java-code-style.md]": {
    "markdown.extension.toc.orderedList": false,
    "files.insertFinalNewline": false
  }
}

Newlines are always inserted, it's impossible to change settings for a specific file. I was pretty sure, that it should work... Here is an open issue microsoft/vscode#35350 - people propose to allow custom settings not only for file extensions, but also for glob patterns. But the issue is still open. Sorry for the misleading.

It seems that the only way to achive it is to add per-file settings to the plugin.

@yzhang-gh
Copy link
Owner

Thanks for the information. That's an old issue 😲. Then I think there isn't a easy solution for now 😔.

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

No branches or pull requests

2 participants