huntertran / markdown-toc

Auto MarkdownTOC (Table Of Contents) plugin for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=huntertran.auto-markdown-toc
MIT License
39 stars 25 forks source link

Adding a TOC ignore above the TOC removes unique settings #41

Open TrevorSayre opened 4 years ago

TrevorSayre commented 4 years ago

If I have a setup like this:

<!-- prettier-ignore-start -->
<!-- TOC ignore:true -->
## Table of Contents
<!-- prettier-ignore-end -->

<!-- TOC depthFrom:2 depthTo:3 updateOnSave:false -->

- [Resources](#resources)
- [Develop](#develop)
  - [Run Locally](#run-locally)
  - [Add Command](#add-command)
  - [Add Client Event](#add-client-event)
- [Deploy](#deploy)
  - [Deploy Issues](#deploy-issues)
- [ToDo](#todo)
  - [Cleanup Tasks](#cleanup-tasks)
  - [Future Work](#future-work)

<!-- /TOC -->

When I trigger the command to Insert/Update, the unique settings are lost.

That is:

<!-- TOC depthFrom:2 depthTo:3 updateOnSave:false -->

is changed to:

<!-- TOC -->

Removing the TOC ignore line <!-- TOC ignore:true --> prevents this from happening.

However, in my specific setup I would like to prevent the ## Table of Contents section from being added while retaining the unique settings on the TOC.

This can be addressed by adding the unique settings to a VSCode workspace preferences file, but this is not ideal. Other markdown files in the workspace might need different unique settings.

I have confirmed the prettier-ignore lines are not causing the issue, only the <!-- TOC ignore:true --> line. The prettier-ignore is needed to prevent my code formatter from adding a blank line between the <!-- TOC ignore:true --> and the heading I want to ignore (## Table of Contents).

VSCode:

Version: 1.49.3
Commit: 2af051012b66169dde0c4dfae3f5ef48f787ff69
Date: 2020-10-02T17:54:06.165Z (1 wk ago)
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0

markdown-toc

Version: v3.0.12

OS:

Version: macOS Catalina 10.15.7
TrevorSayre commented 4 years ago

I noticed there is a similar comment here: https://github.com/huntertran/markdown-toc/issues/40#issuecomment-691685368

It states that:

the extension cannot differentiate the first <!--TOC orderedlist:true--> with <!-- TOC ignore:true -->

Perhaps a solution could be to change how ignore comments are structured? Instead of <!-- TOC ignore:true --> consider <!-- TOC-ignore --> so that the extension can differentiate these comments.