nojronatron / markdown-toc

VSCode Extension adds table of contents to an existing markdown file.
https://marketplace.visualstudio.com/items?itemName=jon-rumsey-dev.jr-markdowntoc-vscode
MIT License
1 stars 0 forks source link

Certain characters trigger Invalid Link Fragment rule #11

Closed nojronatron closed 1 year ago

nojronatron commented 1 year ago

Observed

A valid markdown document contains an L2 heading with a colon : character in the heading text. Create Markdown TOC creates the a Link Fragment in the table of contents.

## Primer: How Linux Works returns - [Primer](#primer) which triggers MD051 Rule.

Expected

Create Markdown TOC ignores characters like colon, semicolon, etc, and creates only full bookmark links for all L2 headings.

Actual

Create Markdown TOC ignores remaining characters at and beyond the colon : character and a partial link is created instead.

Severity

Low. It is easy for the user to edit their markdown document to avoid the situation prior to running Create Markdown TOC.

Comments

Will need to create tests for Markdown Rules for Headers to determine minimum required character types/classes for the Link to avoid creating a fragment. Initial testing indicates ignoring any non-alphanumeric characters is good enough to create a valid Link.

Example

## Test ,.;':[]{}!@$%^&*() Header ideally would return something like - [Test Header](#test-header).

nojronatron commented 1 year ago

Confirmed the 'ampersand' character is a culprit.

nojronatron commented 1 year ago

The dash - character causes a transformation problem.

A heading like ## Monday 26-June-2023 results in a TOC entry like - [Monday 26](#monday-26) with an under-squiggle and MD051 (link fragment) message.

Intended result is: - [Monday 26-June-2023](#monday-26-june-2023)

nojronatron commented 1 year ago

See PR #12 for progress on fixing this issue.

nojronatron commented 1 year ago

Closing with merge-in of PR #12