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

Extension not slugifying anchors properly

Open etoews opened this issue 5 years ago • 5 comments

Thanks for maintaining this extension. It's been great to work with but a couple of issues popped up recently.

With the version and settings at the end of this issue, it's producing the following markdown.

<a id="markdown-On-boarding%20Users" name="On-boarding%20Users"></a>

# On-boarding Users

These instructions cover on-boarding (and off-boarding) tech team users.

<!-- TOC -->

* [Common Access](#markdown-header-common-access)

<!-- /TOC -->

<a id="markdown-Common%20Access" name="Common%20Access"></a>

## Common Access

...

Issues

  1. The TOC link #markdown-header-common-access doesn't match the section anchor id markdown-Common%20Access or name Common%20Access. The anchors need to be slugified properly so the link works.
  2. "markdown-toc.depthFrom": 2 is set but an anchor is still produced for # On-boarding Users

Extension version: 3.0.5

Settings:

    "markdown-toc.anchorMode": "bitbucket.org",
    "markdown-toc.bulletCharacter": "*",
    "markdown-toc.depthFrom": 2,
    "markdown-toc.depthTo": 3,
    "markdown-toc.insertAnchor": true

etoews avatar Apr 15 '20 00:04 etoews

I reverted to version 3.0.1 and the anchors are slugified properly in that version.

etoews avatar Apr 27 '20 22:04 etoews

The reason for this is because I use a new mechanism to generate anchor id and name attributes to address some problems with non-ASCII characters. A special replacement for whitespace added int commit e69a9dfc8dd4a25dd7e7fc97b4dd44ab79024a56

huntertran avatar Jun 15 '20 03:06 huntertran

Live in preview version 3.0.6

huntertran avatar Jun 15 '20 03:06 huntertran

Still, the slugified anchor names do not match the URL fragments generated in the TOC. One is a mixture of lowercase and uppercase characters while the other is all in lowercase.

May I ask why they have to be different in the casing?

ztan avatar Jun 16 '20 02:06 ztan

Still, the slugified anchor names do not match the URL fragments generated in the TOC. One is a mixture of lowercase and uppercase characters while the other is all in lowercase.

May I ask why they have to be different in the casing?

Because they're using 2 different mechanisms for creating slugify. I will look into this when I have more time

huntertran avatar Jun 17 '20 03:06 huntertran