mzlogin / vim-markdown-toc

A vim 7.4+ plugin to generate table of contents for Markdown files.
http://www.vim.org/scripts/script.php?script_id=5460
MIT License
609 stars 59 forks source link

Can not navigate to the content when click title #47

Closed bdgong closed 6 years ago

bdgong commented 6 years ago

Use Vundle to manage my vim plugins. Use vim-instant-markdown to preview markdown. Since I know vim-markdown-toc is a good plugin then just have a try, but I can only generate ToC with vim-markdown-toc, click any title, just can not navigate to the content?

bdgong commented 6 years ago

Already have a similar issue, I should close it.

mzlogin commented 6 years ago

Yes, please ref https://github.com/mzlogin/vim-markdown-toc/issues/6#issuecomment-211185759

bdgong commented 6 years ago

I change to iamcco/markdown-preview, now I can navigate between level 2 headers '##', but not lower headers, like '###'.

mzlogin commented 6 years ago

I just test for it, in my environment I can navigate between level 2/3/4/5... headers well. Could you provide a markdown content snippets to reproduce your problem?

ps: iamcco/markdown-preview use https://github.com/markedjs/marked as its Markdown Parser, the support for it has not been tested. I guess the reason is there are some symbols in your header, and different markdown parsers generate different anchor links for a same header.

bdgong commented 6 years ago

https://gitee.com/bdgong/tech-notes/blob/master/book/note__JavaConcurrencyInPractice.md

So, how could I see the anchor the Parser generated? or, I can not

bdgong commented 6 years ago

Anyway, which vim plugin you use to preview markdown?

mzlogin commented 6 years ago

image

Just use Chrome devtools, the id value is anchor.

anchors generated for header 2.4 Guarding State with Locks:

They all different from others. So I give up to find a tool which can preview markdown with toc links are right. I just confirm styles.

ps: If you want to upload markdown to gitee, use command :GenTocGitLab may better.

bdgong commented 6 years ago

OK, thank you very much~

bdgong commented 6 years ago

I am not familiar with vimscript, but I'm wondering whether I could modify your code to achieve my goals. Could just give some tips? Appreciate for your help

mzlogin commented 6 years ago

Sadly you can't generate toc once, work well in all of markdown preview, GitHub, Gitee, or even any two of them.

If you just want to use toc in markdown preview, maybe we can add a command :GenTocMarked for iamcco/markdown-preview, like :GenTocGFM for GitHub, :GenTocGitLab for GitLab. You can ref https://github.com/mzlogin/vim-markdown-toc/blob/a6e227023f405a7c39590a8aaf0d54dde5614a2e/ftplugin/markdown.vim#L126 for how to implement.

bdgong commented 6 years ago

That's what I need, thank you

mzlogin commented 6 years ago

You are welcome. And...welcome to PR for this if you implement it. 😆