mzlogin / vim-markdown-toc Goto Github PK
View Code? Open in Web Editor NEWA vim 7.4+ plugin to generate table of contents for Markdown files.
Home Page: http://www.vim.org/scripts/script.php?script_id=5460
License: MIT License
A vim 7.4+ plugin to generate table of contents for Markdown files.
Home Page: http://www.vim.org/scripts/script.php?script_id=5460
License: MIT License
the current behaviour breaks 'jumping' to the headline from the TOC when using vimwiki with markdown files
Thanks for this great plugin. I know GFMs way of handling ordered lists is pretty weird, but it still would be nice if this plugin could handle it out of the box.
I want a numbered TOC. I achieved this by following the advice in this issue on vimwiki, setting g:vmt_list_item_char = '1.'
.
This seems to work fine, but GFM is acting very rude, requiring 4 whitespaces of indentation in sublevels. To save some energy, I tried not to be so mad about that.
I inserted the following option in my vimrc as a workaround: g:vmt_list_indent_text = repeat(' ', 4)
. This is good for now, but I think it would be great to support numbered lists in general.
One issue now is, that if I want to change my item char back to e.g. -
, I have to change indent text as well, or live with inconsistent indentation in my document, as my usual shiftwidth is 2 for markdown.
Also, if I use this TOC in other markdown formats, where two whitespaces are permitted, my hardcoded intent text will still be picked up.
So my minor suggestions, with low prio, is to offer a global flag to generate numbered TOC. Use 1.
as a prefix in this case. This global flag could then be checked for in s:GetIndentText
. If it's true AND GFM style is used AND &expandtab
is not set, don't use the &shiftwidth
, but rather 4 whitespaces. Otherwise use tab or shiftwidth.
read gfm and redcarpet source code and docs, make the convert of punctuations to link accurate.
Last PR over 18 months ago.
Last closed issue over a year ago.
No responses to any Issues.
vim-markdown-toc is not working at all for me (installled, but vim will not acknowledge that it is there), but no point in raising an issue.
To confirm Chinese quote “
and ”
generate link in GFM and Redcarpet style.
系统:windows10
vim版本:vim 8.2
错误提示:输入:GenTocGFM后提示 E492:不是编辑器的命令: GentocGFM
_vimrc:
set rtp+=$VIM\vimfiles\bundle\Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-surround'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'zxqfl/tabnine-vim'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'mzlogin/vim-markdown-toc'
Plugin 'iamcco/markdown-preview.vim'
call vundle#end()
When use this plugin to edit a md file, after saving file, the toc is updated, but when I type u
the cursor move to the toc menu, I think the undotree of current file is been updated.
Error detected while processing function <SNR>120_UpdateToc[5]..<SNR>120_DeleteExistingToc:
line 29:
Cannot find toc begin fence
Error detected while processing function <SNR>120_UpdateToc:
line 8:
Cannot find existing toc
It's noted that insert fence followed is neccessay for auto save, but I don't need it and like running :UpdateToc
manually, in which situation the error above occurs. I think it should be coverd.
<!-- vim-markdown-toc GFM -->
toc
<!-- vim-markdown-toc -->
Like
## heading ##
It is legal.
Since you do not support GitLab, my issue is mor a backlog for other users.
Since GitHub keeps hyphens and GitLab deletes them when converting a header to an anchor.
The following code is valid for GitHub but not for GitLab
# Test code
<!-- vim-markdown-toc GFM -->
* [This subsection has an - in it](#this-subsection-has-a---in-it)
<!-- vim-markdown-toc -->
## This subsection has a - in it
To make it work, I had to add the following regex in GetHeadingLinkGFM
(line 123):
let l:headingLink = substitute(l:headingLink, "-\\+", "-", "g") # Converts successive hyphens to only one
Maybe you could easily add support for GitLab too, rules to create header anchors are summarized here.
The file generating anchors for headers in GitHub is to be found here. I'm not proficient in ruby but I don't see anything about deleting successive hyphens.
It seems that vim-markdown-toc
always uses hard tabs to indent subsections within a table of contents, even if expandtab
is turned on in vim (and thus the user prefers spaces). It would more be elegant and fit in better with the users' other preferences if it honored that option.
Thanks for your fine work on this plugin!
我在网上看到你的文字,想请问以下,我通过网上的步骤设置ctag和markdown2ctag后还是无法看到md文档的大纲。请问你知道怎样排错吗?谢谢。
I'm using pandoc to convert my markdown files to HTML format. When using :GenTocRedcarpet
command, generated TOC links looks like:
[Wstępna konfiguracja karty](#wstępna-konfiguracja-karty)
Pandoc creates <h>
tags that looks like:
<h2 id="wstepna-konfiguracja-karty">Wstępna konfiguracja karty</h2>
As you see, there are no letters other than ascii characters inside id
attribute.
Is it possible to to pass link part of TOC through command like iconv -t ascii//TRANSLIT
, so letters like ę
, ą
, ś
will be replaced by e
, a
, s
?
Regards,
Andrzej.
According to GitHub Flavored Markdown Spec 5.1, a quote block can end in a blank line, as illustrated below:
> # Foo
> bar
baz
this is Example 210 of the official document.
However, if the regex pattern of vim-markdown-toc does not accept this.
It would be cool if this style of heading was supported:
A heading
=========
A subheading
--------------
I generally prefer this style for simple documents.
It would be cool if TOC modification done automatically done on save won't be added to undo history, so :w
and u
will undo last change user has done before saving, not TOC modification.
As example, https://github.com/fatih/vim-go plugin correctly does this while reformatting code on save by running external tools like gofmt
or goimports
.
1.1 使用此插件 生成的目录为·[1.1](#1.1)
正确的应该是[1.1](#11)
src:
# hello
<!-- vim-markdown-toc GFM -->
* [heading1](#heading1)
* [](#)
<!-- vim-markdown-toc -->
## heading1
##
It would be cool if there was an option to set to define the minimum and maximum levels in the table of contents.
1. [Introduction](#introduction)
2. [Installation](#installation)
2.1. [Requirements](#requirements)
2.2. [Installing syntastic with Pathogen](#installpathogen)
3. [Recommended settings](#settings)
4. [FAQ](#faq)
will generate:
Does anyone use Vimwiki with VMT? I just upgraded my instance of Vimwiki to 2.5 and now, any generated TOC link caused the following error when jumping to the item it points to:
Error Detected while processing function vimwiki#base#follow_link[69] .. vimwiki#base#open_link[34] .. vimwiki#base#edit_file[32] .. <SNR>46_jump_to_anchor[12] .. <SNR>46_jump_to_segment:
line 23:
E945: Range to large in character class
However, I have no problem jumping from links generated by Vimwiki. Any pointer on how to investigate this error further?
Best,
Yohannes
I'm using vimwiki with markdown syntax.
To generate the html I'm using livedown which itself uses marked.
That works great with using :GenTocRedcarpet
. The only problem is that I have to run :set ft=markdown
so that this plug loads and then run :set ft=vimwiki
to use all the vimwiki features.
Once I've done that I can use :UpdateToc
and it works great. Long story short I'd love to have option that lets me load this plugin for a different filetype than markdown.
Very helpful utility, the missing piece for me to do all my markdown edittng in VIM!!
That said, my team uses multiple editors, and the team has agreed that the TOC guard should be
<!-- TOC -->
Can you make the TOC guard configurable? Thanks!!
vim-markdown-toc/ftplugin/markdown.vim
Line 280 in 8df20be
For example
hello!hello
and
hello?hello1
will result same toc link.
GFM append a -[number]
to distinguish them.
I generated the TOC and its working well .. For now I want to remove it till I finish formatting t he document and then regenerate the TOC .. Is there a command for removing the TOC ?
Thanks in advance
in the latest version of this plugin, the toc is looks like
<!-- vim-markdown-toc GFM -->
* [安装](#安装)
* [更新](#更新)
* [文档](#文档)
* [核心**](#核心**)
* [记忆辅助](#记忆辅助)
* [可视化交互](#可视化交互)
* [一致性](#一致性)
* [社区驱动](#社区驱动)
<!-- vim-markdown-toc -->
but, after use remark to formate markdown file, it looks like:
<!-- vim-markdown-toc GFM -->
- [安装](#安装)
- [更新](#更新)
- [文档](#文档)
- [核心**](#核心**)
- [记忆辅助](#记忆辅助)
- [可视化交互](#可视化交互)
- [一致性](#一致性)
- [社区驱动](#社区驱动)
<!-- vim-markdown-toc -->
I think it looks better, maybe you do not need to change the list item from *
to -
, but an option can be added for it.
for more info see https://github.com/wooorm/remark/tree/master/packages/remark-stringify#optionslistitemindent
and I will try to send a PR for this issue, and the previous issue I have opened.
RT
I made this kind of python syntax highlighting codes in a markdown file.
Then this plugin thinks that the "# mod1.py" is a heading level 1.
Can you skip that kind of syntax highlighting blocks?
# mod1.py
def add(a, b):
return a + b
def sub(a, b):
return a - b
after successful install of plugin, command :GenTocGFM does not exist
If a markdown file contains python code block, and the block has comments lines begin with #
, the comments will add to the TOC, it is not matching expect.
Looks like if TOC is inside folded block then whole block is deleted while auto-updating TOC on save and TOC is added few lines below deleted block. For example (require foldutil plugin), starting from document:
# test
<!-- vim-markdown-toc GitLab -->
* [one](#one)
* [two](#two)
* [subtwo](#subtwo)
* [three](#three)
<!-- vim-markdown-toc -->
## one
## two
### subtwo
## three
Doing :w
makes no change, but after :FoldMatching ^# -1
next :w
will change document to:
## one
<!-- vim-markdown-toc GitLab -->
* [two](#two)
* [subtwo](#subtwo)
* [three](#three)
<!-- vim-markdown-toc -->
## two
### subtwo
## three
bad case:
### 2. ```git status -s```
expect link
#2-git-status--s
but now result is
#2-git-status--s-
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?
I find a numerically ordered toc more useful than an unordered list; the document has an order and sections are usually arranged in order.
Could we have an option to generate an ordered list instead of an unordered one?
eg:
1. Features
2. Installation
3. Usage
1. Generate table of contents
2. Update existing table of contents
First of all, thanks for your good work, it's very convenient to generate toc now. If you add a new feature like updating existing toc when triggering some hotkeys, it would be more useful. Is it right?
I have no vim script programming experience, but I think this is a good idea for some document which contains a long table of contents. If you add a updating-toc feature, we don't have to delete existing toc again. And I think inserting toc before the document is finished is useful too, because it can help us navigate the document.
So I think add a updating-toc feature is very useful. Thanks!
Currently it looks like the plugin ignores all headings above the point where you insert it. This leads to the case that when it is inserted under a # heading and after the toc comes a ## heading, the generated markdown list starts with an indentation, which will not be rendered as part of the list. Therefore the plugin should have an option to also include all the headings that are before its insert point
First of all, thank you for the work invested on this plugin, and for sharing it with us!
The issue
Quickly navigate to a markdown TOC item corresponding section using vim line numbers: 35g
The feature
Provide the hability for the vim-markdown-toc
to add the relative item line number before or after each TOC item.
Providing an option like:
let g:vmt_add_line_number_reference = 1
...that would add the line number and deliver something like this:
<!--- vim-markdown-toc GFM -->
line 5 * Introduction
line 35 ** How To Install
line 45 ** Hello World
<!-- /vim-markdown-toc -->
With a feature like that would be super cool quick and easy to navigate within the markdown file with vim native support.
I appreciate your time on considering that!
由于你的插件自动集成了vim对markdown的支持,我安装后由于插件冲突找了一上午原因,原谅我在这吐槽,你应该在github和文章开头介绍以下,需要注释或者删除
"Plugin 'godlygeek/tabular'"
Plugin 'plasticboy/vim-markdown'
这两个插件,被弄的好蛋疼
可以不用打开Toc(:Toc)直接在markdown文件里面的Toc(:GenTocGFM)跳转到标题处吗?
比如说有一个链接是[title](#header-two)
,比如直接从这上面按回车就能跳转过去。
@mzlogin in spacevim, we use remark to format markdwon file. vim-markdown-toc generate toc like
<!-- vim-markdown-toc GFM -->
* [安装](#安装)
* [更新](#更新)
* [文档](#文档)
* [核心**](#核心**)
* [记忆辅助](#记忆辅助)
* [可视化交互](#可视化交互)
* [一致性](#一致性)
* [社区驱动](#社区驱动)
<!-- vim-markdown-toc -->
but after using remark formatting current buffer, the toc change to
<!-- vim-markdown-toc GFM -->
- [安装](#安装)
- [更新](#更新)
- [文档](#文档)
- [核心**](#核心**)
- [记忆辅助](#记忆辅助)
- [可视化交互](#可视化交互)
- [一致性](#一致性)
- [社区驱动](#社区驱动)
<!-- vim-markdown-toc -->
we need an option to keep the same format. I will try to add this feature.
For example:
# ![Awesome Adb](./assets/title.png)
Now generated toc is:
* [![Awesome Adb](./assets/title.png)](#awesome-adbassetstitlepng)
Result excepted:
* [Awesome Adb](#-num)
Deep thinking:
Image format is ![describe](image-link)
, if describe is null, how to cover it?
For example :
### [vim-airline](https://github.com/vim-airline/vim-airline)
then the generated toc is :
### * [[vim-airline](https://github.com/vim-airline/vim-airline)](#vim-airlinehttpsgithubcomvim-airlinevim-airline)
This will lead to a direct visit to the link. However, I hope it lead to the right position in the current page.
So, what I expected is :
### * [vim-airline](#vim-airline)
I wanted to indent table item with 2 spaces instead of 4 and found an option on script that does that and is missing in the documentation.
Change
let g:vmt_list_indent_text = ''
To
let g:vmt_list_indent_text = ' '
I’m not sure what is going on or the exact repro. The symptom is sometimes the prettier gaurds that were around my toc marks move. A “phychic debugging” is the toc is written a few lines below it’s original line. I’ve tried a few things to isolate this, but haven’t found a consistent repro. I think it’s more likely if I hit save above the TOC, as opposed to below it, but sometimes I get a repro below as well. See video.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.