naokazuterada / MarkdownTOC

SublimeText3 plugin which generate a table of contents (TOC) in a markdown document.
https://packagecontrol.io/packages/MarkdownTOC
MIT License
301 stars 48 forks source link

'autolink' doesn't work #109

Closed naokazuterada closed 6 years ago

naokazuterada commented 6 years ago
<!-- MarkdownTOC autolink="true" bracket="round" -->

- [variable \](#required\)

<!-- /MarkdownTOC -->

# variable \[required\]

should be

<!-- MarkdownTOC autolink="true" bracket="round" -->

- [variable\[#required\]](#variable-required)

<!-- /MarkdownTOC -->

# variable \[required\]
naokazuterada commented 6 years ago

Problem On GFM, the words between[and] seems to be escaped always, so we should escape it if we want it exists. But this is maybe conflicting Markdown specification.

naokazuterada commented 6 years ago

Idea

ZimbiX commented 6 years ago

Headings containing rendered underscores are also affected by this issue. That is, the anchors when displayed on GitHub do not match.

Test GFM:

<!-- MarkdownTOC depth=0 autolink=true bracket=round -->

<!-- /MarkdownTOC -->

# 1 test_x

# 2 test _x_

# 3 test _x

# 4 test x_

Expected (GitHub anchors):

- [1 test_x](#1-test_x)
- [2 test _x_](#2-test-x)
- [3 test _x](#3-test-_x)
- [4 test x_](#4-test-x_)

Actual:

- [1 test_x](#1-testx)
- [2 test _x_](#2-test-x)
- [3 test _x](#3-test-x)
- [4 test x_](#4-test-x)

Removing _ from id_replacements doesn't fix the issue:

- [1 test_x](#1-test_x)
- [2 test _x_](#2-test-_x_)
- [3 test _x](#3-test-_x)
- [4 test x_](#4-test-x_)
naokazuterada commented 6 years ago

@ZimbiX Thank you for reporting. I will take a look 👀

naokazuterada commented 6 years ago

Fixed in 3.0.0.