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

Having a "-" in the heading breaks the autolink feature: #137

Closed TheBestPessimist closed 5 years ago

TheBestPessimist commented 5 years ago

How can the issue be reproduced

It seems that having a "-" in the heading breaks the autolink feature:

# ID Server - Migration Script

sometext

If the "-" above is deleted, the link works

What was expected

Links work.

What actually occurred

Clicking a link in the toc to go to the heading didn't work

What was the version of the involved component

3.0.4

See example file: a.md.txt

naokazuterada commented 5 years ago

Thanks again for reporting.

MarkdownTOC creates id(#id-server---migration-script) for heading 'ID Server - Migration Script'. And it works on Github.

Please let me know your presentation environment (Gitlab, Marked2, etc.) and also id string you expected(Please check the HTML source code, what is id string of heading?).

naokazuterada commented 5 years ago

Though this is an ugly workaround, you can avoid it with "Manipulation of auto-link ids" feature.

Add into your configuration.

"id_replacements": [
  {
    "pattern": "---",
    "replacement": "-"
  }
]

this changes #id-server---migration-script to #id-server-migration-script

TheBestPessimist commented 5 years ago

Please let me know your presentation environment

I'm sorry, but idk what to show you. Can you give me details/steps?

I just edit my HUGE markdown file, then press ctrlB and a tab is opened into chrome with the contents of my markdown as html.

If i think about it, probs that page is rendered with https://packagecontrol.io/packages/MarkdownPreview, since i also have this plugin installed.

TheBestPessimist commented 5 years ago

Yes, it seems that i have configured Markdown Preview only halfway. As per the docs https://facelessuser.github.io/MarkdownPreview/usage/ after i added

"github_inject_header_ids": true,

Those links work nicely!

As a reference for other people (maybe add this info to readme) here's my MarkdownPreview User settings:

{
    // "parser": "markdown",
    "parser": "github",
    "build_action": "browser",
    "github_oauth_token": "leepic",
    "github_mode": "gfm",
    "github_inject_header_ids": true,
}

Sorry for wasting your time on this :(

naokazuterada commented 5 years ago

@TheBestPessimist Oh, sorry for my bad English. I mean 'What do you use for rendering markdown as HTML?'. So you showed me the right answer I want to know.

MarkdownPreview

And sorry I forgot the link too. Manipulation of auto-link ids

I'm happy to hear that you solved! And thanks for showing me your solution.

BTW, this plugin also has Markdown Preview compatible feature. So please choose from two solutions. (MarkdownTOC's config or Markdown Preview's)

TheBestPessimist commented 5 years ago

BTW, this plugin also has Markdown Preview compatible feature.

Yeah, seems like i missed that (though i did read the whole readme file. 😊 )

jonasbn commented 5 years ago

hi @naokazuterada @TheBestPessimist

Was there something, in need of clarified in the documentation for MarkdownTOC ?

Or are there additions to the compatility matrix?

jonasbn

naokazuterada commented 5 years ago

@jonasbn Thank you for asking! I think it's already enough.