markdown-toc icon indicating copy to clipboard operation
markdown-toc copied to clipboard

Add option for unordered list style of TOC

Open nicpitsch opened this issue 6 years ago • 4 comments

Issue

The created TOC uses dash (-) as symbol for the generated unordered list items. If the document contains another symbol for the list items, like asterix (*), markdownlint mentions MD004 - Unordered list style telling the unordered list style should be consistent within the document.

Example:

# Test1

<!-- TOC -->

- [heading 1](#heading-1)
- [Next heading](#next-heading)

<!-- /TOC -->

## heading 1

This is an unordered list, using asterix symbol:

* one
* two

## Next heading

Suggestion

Add an option for unorderd list symbol style, allowing the user to select the preferred symbol, means dash, asterix or plus.

Code

Extension.js

...
this.options = {
  DEPTH_FROM: 1,
  DEPTH_TO: 6,
  INSERT_ANCHOR: false,
  WITH_LINKS: true,
  ORDERED_LIST: false,
  UNORDERED_LIST_SYMBOL: '-',
  UPDATE_ON_SAVE: true,
  ANCHOR_MODE: ANCHOR_MODE_LIST[0]
};
...
// about line 282:
_this.options.ORDERED_LIST ? (++indicesOfDepth[length] + '. ') : '' + _this.options.UNORDERED_LIST_SYMBOL + '' + ' ',

nicpitsch avatar Sep 27 '18 03:09 nicpitsch

Thanks for raising issue. I agree with this request. This would a great idea as it would allow combining markdown TOC and markdown-lint.

PhilippeCuvillier avatar Oct 15 '18 13:10 PhilippeCuvillier

Hi @PhilippeCuvillier , is there any target milestone for this feature to be implemented? My .md document contains * for unordered lists and after TOC is created, markdownlint gives ~100+ warning. :blush: I 'll replace them to - as I don't want to give up from TOC.

csonuryilmaz avatar Dec 16 '18 18:12 csonuryilmaz

@nicpitsch @csonuryilmaz : As a workaround, you may add <!-- markdownlint-disable MD004 --> just before the TOC, and <!-- markdownlint-enable MD004 --> just after, to avoid warnings from markdownlint.

arnauldvm avatar Jan 14 '19 09:01 arnauldvm

Where are we on this 1 year later?

rcdailey avatar Mar 23 '20 16:03 rcdailey