--- /dev/null
+name: Reviewdog
+on: [pull_request]
+jobs:
+ vint:
+ name: vint
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: vint
+ uses: reviewdog/action-vint@v1
+ with:
+ github_token: ${{ secrets.github_token }}
+ reporter: github-pr-review
--- /dev/null
+name: Vader
+on: [push, pull_request]
+jobs:
+ vader:
+ name: vader
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ vimFlavor: ["vim", "nvim"]
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Enable Universe package repository
+ run: |
+ sudo add-apt-repository universe
+ sudo apt-get update
+ - name: Install ${{ matrix.vimFlavor }}
+ run: |
+ sudo apt-get install ${{ matrix.vimFlavor == 'nvim' && 'neovim' || 'vim' }}
+ - name: Review versions
+ run: |
+ ${{ matrix.vimFlavor }} --version
+ - name: Fetch Vader and other dependencies
+ run: |
+ make build/tabular build/vim-toml build/vim-json build/vader.vim
+ - name: Run test suite
+ run: |
+ cd test
+ ${{ matrix.vimFlavor == 'nvim' && 'nvim --headless' || 'vim -N' }} \
+ -u vimrc "+Vader! *"
--- /dev/null
+name: Vint
+on: [push]
+jobs:
+ vint:
+ name: vint
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ - name: Setup dependencies
+ run: pip install vim-vint
+ - name: Lint Vimscript
+ run: vint .
+++ /dev/null
-language: vim
-
-os:
- - linux
- - osx
-
-env:
- - TEST=package
- - TEST=latest
-
-before_script: |
- if [ "$TEST" = "package" ]; then
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
- sudo apt-get -y update
- sudo apt-get -y install vim
- fi
- else
- cd ..
- git clone --depth 1 https://github.com/vim/vim
- cd vim
- ./configure --with-features=huge
- make
- sudo make install
- export PATH="/usr/local/bin:$PATH"
- cd "$TRAVIS_BUILD_DIR"
- fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
- curl https://bootstrap.pypa.io/get-pip.py | sudo python
- fi
- sudo -H pip install virtualenv
-
-script:
- - make test
- - make doc
--- /dev/null
+cmdargs:
+ severity: style_problem
+ color: true
+ env:
+ neovim: false
## Style
-When choosing between multiple valid Markdown syntaxes, the default behavior must be that specified at: <http://www.cirosantilli.com/markdown-styleguide>
+When choosing between multiple valid Markdown syntaxes, the default behavior must be that specified at: <https://cirosantilli.com/markdown-style-guide>
If you wish to have a behavior that differs from that style guide, add an option to turn it on or off, and leave it off by default.
Issues are tracked within GitHub.
-When reporting issues, your report is more effective if you include a minimal example file that reproduces the problem. Try to trim out as much as possible, until you have the smallest possible file that still reproduces the issue. Paste the example inline into your issue report, quoted using four spaces at the beginning of each line, like this example from issue [#189](https://github.com/plasticboy/vim-markdown/issues/189):
+When reporting issues, your report is more effective if you include a minimal example file that reproduces the problem. Try to trim out as much as possible, until you have the smallest possible file that still reproduces the issue. Paste the example inline into your issue report, quoted using four spaces at the beginning of each line, like this example from issue [#189](https://github.com/preservim/vim-markdown/issues/189):
```
Minimal example:
# Vim Markdown
-[](https://travis-ci.org/plasticboy/vim-markdown)
+[](https://github.com/preservim/vim-markdown/actions?workflow=Vint)
+[](https://github.com/preservim/vim-markdown/actions?workflow=Vader)
Syntax highlighting, matching rules and mappings for [the original Markdown](http://daringfireball.net/projects/markdown/) and extensions.
```vim
Plugin 'godlygeek/tabular'
-Plugin 'plasticboy/vim-markdown'
+Plugin 'preservim/vim-markdown'
```
The `tabular` plugin must come *before* `vim-markdown`.
```sh
cd ~/.vim/bundle
-git clone https://github.com/plasticboy/vim-markdown.git
+git clone https://github.com/preservim/vim-markdown.git
```
To install without Pathogen using the Debian [vim-addon-manager](http://packages.qa.debian.org/v/vim-addon-manager.html), do this:
```sh
-git clone https://github.com/plasticboy/vim-markdown.git
+git clone https://github.com/preservim/vim-markdown.git
cd vim-markdown
sudo make install
vim-addon-manager install markdown
```
-If you are not using any package manager, download the [tarball](https://github.com/plasticboy/vim-markdown/archive/master.tar.gz) and do this:
+If you are using a package manager with semver support (like [lazy.nvim](https://github.com/folke/lazy.nvim)) make sure you are following the master branch (see https://github.com/preservim/vim-markdown/issues/616).
+
+If you are not using any package manager, download the [tarball](https://github.com/preservim/vim-markdown/archive/master.tar.gz) and do this:
```sh
cd ~/.vim
- `zR`: opens all folds
- `zm`: increases fold level throughout the buffer
- `zM`: folds everything all the way
-- `za`: open a fold your cursor is on
-- `zA`: open a fold your cursor is on recursively
+- `za`: toggle a fold your cursor is on
+- `zA`: toggle a fold your cursor is on recursively
+- `zo`: open a fold your cursor is on
+- `zO`: open a fold your cursor is on recursively
- `zc`: close a fold your cursor is on
- `zC`: close a fold your cursor is on recursively
Highlight TOML front matter as used by [Hugo](https://gohugo.io/content/front-matter/).
- TOML syntax highlight requires [vim-toml](https://github.com/cespare/vim-toml).
-
let g:vim_markdown_toml_frontmatter = 1
#### JSON Front Matter
Highlight JSON front matter as used by [Hugo](https://gohugo.io/content/front-matter/).
- JSON syntax highlight requires [vim-json](https://github.com/elzr/vim-json).
-
let g:vim_markdown_json_frontmatter = 1
#### Strikethrough
let g:vim_markdown_edit_url_in = 'tab'
+### Borderless tables
+
+- `g:vim_markdown_borderless_table`
+
+ Add support for borderless tables, such as:
+ ```
+ header 1|header 2
+ --|--
+ data 1|data 2
+ ```
+ if set to `1`:
+
+ let g:vim_markdown_borderless_table = 1
+
+ the table would be formatted as usual:
+ ```
+ | header 1 | header 2 |
+ |----------|----------|
+ | data 1 | data 2 |
+ ```
+
## Mappings
The following work on normal and visual modes:
Known limitation: does not work for links that span multiple lines.
-- `ge`: open the link under the cursor in Vim for editing. Useful for relative markdown links. `<Plug>Markdown_EditUrlUnderCursor`
+- `ge`: open the link under the cursor in Vim for editing. Useful for relative markdown links. Falls back to `gf` with force editing, if not on a markdown link. `<Plug>Markdown_EditUrlUnderCursor`
The rules for the cursor position are the same as the `gx` command.
- `]]`: go to next header. `<Plug>Markdown_MoveToNextHeader`
-- `[[`: go to previous header. Contrast with `]c`. `<Plug>Markdown_MoveToPreviousHeader`
+- `[[`: go to previous header. Contrast with `]h`. `<Plug>Markdown_MoveToPreviousHeader`
- `][`: go to next sibling header if any. `<Plug>Markdown_MoveToNextSiblingHeader`
- `[]`: go to previous sibling header if any. `<Plug>Markdown_MoveToPreviousSiblingHeader`
-- `]c`: go to Current header. `<Plug>Markdown_MoveToCurHeader`
+- `]h`: go to Current header. `<Plug>Markdown_MoveToCurHeader`
- `]u`: go to parent header (Up). `<Plug>Markdown_MoveToParentHeader`
- `:Tocv`: Same as `:Toc` for symmetry with `:Toch` and `:Tocv`.
+- `:InsertToc`: Insert table of contents at the current line.
+
+ An optional argument can be used to specify how many levels of headers to display in the table of content, e.g., to display up to and including `h3`, use `:InsertToc 3`.
+
+- `:InsertNToc`: Same as `:InsertToc`, but the format of `h2` headers in the table of contents is a numbered list, rather than a bulleted list.
+
## Credits
The main contributors of vim-markdown are:
-- **Ben Williams** (A.K.A. **plasticboy**). The original developer of vim-markdown. [Homepage](http://plasticboy.com/).
+- **Ben Williams** (A.K.A. **@plasticboy**). The original developer of vim-markdown. [Homepage](http://plasticboy.com/).
If you feel that your name should be on this list, please make a pull request listing your contributions.
function! s:is_mkdCode(lnum)
let name = synIDattr(synID(a:lnum, 1, 0), 'name')
- return (name =~ '^mkd\%(Code$\|Snippet\)' || name != '' && name !~ '^\%(mkd\|html\)')
+ return (name =~# '^mkd\%(Code$\|Snippet\)' || name !=# '' && name !~? '^\%(mkd\|html\)')
endfunction
-if get(g:, "vim_markdown_folding_style_pythonic", 0)
+if get(g:, 'vim_markdown_folding_style_pythonic', 0)
function! Foldexpr_markdown(lnum)
+ if (a:lnum == 1)
+ let b:fence_str = ''
+ endif
+
let l1 = getline(a:lnum)
"~~~~~ keep track of fenced code blocks ~~~~~
"If we hit a code block fence
- if l1 =~ '````*' || l1 =~ '\~\~\~\~*'
+ if l1 =~# '\v^[[:space:]>]*\v(`{3,}|\~{3,})\s*(\w+)?\s*$'
" toggle the variable that says if we're in a code block
if b:fenced_block == 0
let b:fenced_block = 1
- elseif b:fenced_block == 1
+ let b:fence_str = matchstr(l1, '\v(`{3,}|\~{3,})')
+ elseif b:fenced_block == 1 && matchstr(l1, '\v(`{3,}|\~{3,})') ==# b:fence_str
let b:fenced_block = 0
+ let b:fence_str = ''
endif
" else, if we're caring about front matter
- elseif g:vim_markdown_frontmatter == 1
+ elseif get(g:, 'vim_markdown_frontmatter', 0) == 1
" if we're in front matter and not on line 1
if b:front_matter == 1 && a:lnum > 2
let l0 = getline(a:lnum-1)
" if the previous line fenced front matter
- if l0 == '---'
+ if l0 ==# '---'
" we must not be in front matter
let b:front_matter = 0
endif
" else, if we're on line one
elseif a:lnum == 1
" if we hit a front matter fence
- if l1 == '---'
+ if l1 ==# '---'
" we're in the front matter
let b:front_matter = 1
endif
endif
" if we're in a code block or front matter
- if b:fenced_block == 1 || b:front_matter == 1
- if a:lnum == 1
+ if b:fenced_block ==# 1 || b:front_matter ==# 1
+ if a:lnum ==# 1
" fold any 'preamble'
return '>1'
else
let l2 = getline(a:lnum+1)
" if the next line starts with two or more '='
" and is not code
- if l2 =~ '^==\+\s*' && !s:is_mkdCode(a:lnum+1)
+ if l2 =~# '^==\+\s*' && !s:is_mkdCode(a:lnum+1)
" next line is underlined (level 1)
return '>0'
" else, if the nex line starts with two or more '-'
+ " but is not comment closer (-->)
" and is not code
- elseif l2 =~ '^--\+\s*' && !s:is_mkdCode(a:lnum+1)
+ elseif l2 =~# '^--\+\s*$' && !s:is_mkdCode(a:lnum+1)
" next line is underlined (level 2)
return '>1'
endif
"if we're on a non-code line starting with a pound sign
- if l1 =~ '^#' && !s:is_mkdCode(a:lnum)
+ if l1 =~# '^#' && !s:is_mkdCode(a:lnum)
" set the fold level to the number of hashes -1
" return '>'.(matchend(l1, '^#\+') - 1)
" set the fold level to the number of hashes
function! Foldtext_markdown()
let line = getline(v:foldstart)
let has_numbers = &number || &relativenumber
- let nucolwidth = &fdc + has_numbers * &numberwidth
+ let nucolwidth = &foldcolumn + has_numbers * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 6
let foldedlinecount = v:foldend - v:foldstart
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let line = substitute(line, '\%("""\|''''''\)', '', '')
let fillcharcount = windowwidth - len(line) - len(foldedlinecount) + 1
- return line . ' ' . repeat("-", fillcharcount) . ' ' . foldedlinecount
+ return line . ' ' . repeat('-', fillcharcount) . ' ' . foldedlinecount
endfunction
else " vim_markdown_folding_style_pythonic == 0
function! Foldexpr_markdown(lnum)
if (a:lnum == 1)
let l0 = ''
+ let b:fence_str = ''
else
let l0 = getline(a:lnum-1)
endif
" keep track of fenced code blocks
- if l0 =~ '````*' || l0 =~ '\~\~\~\~*'
+ if l0 =~# '\v^[[:space:]>]*\v(`{3,}|\~{3,})\s*(\w+)?\s*$'
if b:fenced_block == 0
let b:fenced_block = 1
- elseif b:fenced_block == 1
+ let b:fence_str = matchstr(l0, '\v(`{3,}|\~{3,})')
+ elseif b:fenced_block == 1 && matchstr(l0, '\v(`{3,}|\~{3,})') ==# b:fence_str
let b:fenced_block = 0
+ let b:fence_str = ''
endif
- elseif g:vim_markdown_frontmatter == 1
+ elseif get(g:, 'vim_markdown_frontmatter', 0) == 1
if b:front_matter == 1
- if l0 == '---'
+ if l0 ==# '---'
let b:front_matter = 0
endif
elseif a:lnum == 2
- if l0 == '---'
+ if l0 ==# '---'
let b:front_matter = 1
endif
endif
endif
let l2 = getline(a:lnum+1)
- if l2 =~ '^==\+\s*' && !s:is_mkdCode(a:lnum+1)
+ if l2 =~# '^==\+\s*' && !s:is_mkdCode(a:lnum+1)
" next line is underlined (level 1)
return '>1'
- elseif l2 =~ '^--\+\s*' && !s:is_mkdCode(a:lnum+1)
+ elseif l2 =~# '^--\+\s*$' && !s:is_mkdCode(a:lnum+1)
" next line is underlined (level 2)
if s:vim_markdown_folding_level >= 2
return '>1'
endif
let l1 = getline(a:lnum)
- if l1 =~ '^#' && !s:is_mkdCode(a:lnum)
+ if l1 =~# '^#' && !s:is_mkdCode(a:lnum)
" fold level according to option
if s:vim_markdown_folding_level == 1 || matchend(l1, '^#\+') > s:vim_markdown_folding_level
if a:lnum == line('$')
endif
endif
- if l0 =~ '^#' && !s:is_mkdCode(a:lnum-1)
+ if l0 =~# '^#' && !s:is_mkdCode(a:lnum-1)
" previous line starts with hashes
return '>'.matchend(l0, '^#\+')
else
let b:fenced_block = 0
let b:front_matter = 0
-let s:vim_markdown_folding_level = get(g:, "vim_markdown_folding_level", 1)
+let s:vim_markdown_folding_level = get(g:, 'vim_markdown_folding_level', 1)
function! s:MarkdownSetupFolding()
- if !get(g:, "vim_markdown_folding_disabled", 0)
- if get(g:, "vim_markdown_folding_style_pythonic", 0)
- if get(g:, "vim_markdown_override_foldtext", 1)
+ if !get(g:, 'vim_markdown_folding_disabled', 0)
+ if get(g:, 'vim_markdown_folding_style_pythonic', 0)
+ if get(g:, 'vim_markdown_override_foldtext', 1)
setlocal foldtext=Foldtext_markdown()
endif
endif
endfunction
function! s:MarkdownSetupFoldLevel()
- if get(g:, "vim_markdown_folding_style_pythonic", 0)
+ if get(g:, 'vim_markdown_folding_style_pythonic', 0)
" set default foldlevel
- execute "setlocal foldlevel=".s:vim_markdown_folding_level
+ execute 'setlocal foldlevel='.s:vim_markdown_folding_level
endif
endfunction
If you use Vundle [2], add the following lines to your '~/.vimrc':
>
Plugin 'godlygeek/tabular'
- Plugin 'plasticboy/vim-markdown'
+ Plugin 'preservim/vim-markdown'
<
The 'tabular' plugin must come _before_ 'vim-markdown'.
If you use Pathogen [3], do this:
>
cd ~/.vim/bundle
- git clone https://github.com/plasticboy/vim-markdown.git
+ git clone https://github.com/preservim/vim-markdown.git
<
To install without Pathogen using the Debian vim-addon-manager [4], do this:
>
- git clone https://github.com/plasticboy/vim-markdown.git
+ git clone https://github.com/preservim/vim-markdown.git
cd vim-markdown
sudo make install
vim-addon-manager install markdown
*vim-markdown-zM*
- 'zM': folds everything all the way
*vim-markdown-za*
-- 'za': open a fold your cursor is on
+- 'za': toggle a fold your cursor is on
*vim-markdown-zA*
-- 'zA': open a fold your cursor is on recursively
+- 'zA': toggle a fold your cursor is on recursively
+ *vim-markdown-zo*
+- 'zo': open a fold your cursor is on
+ *vim-markdown-zO*
+- 'zO': open a fold your cursor is on recursively
*vim-markdown-zc*
- 'zc': close a fold your cursor is on
*vim-markdown-zC*
>
let g:vim_markdown_edit_url_in = 'tab'
<
+-------------------------------------------------------------------------------
+ *vim-markdown-support-borderless-tables*
+Support borderless tables ~
+
+ *g:vim_markdown_borderless_table*
+- 'g:vim_markdown_borderless_table'
+
+ Add support for borderless tables, such as:
+>
+ header 1|header 2
+ --|--
+ data 1|data 2
+<
+ if set to 1:
+>
+ let g:vim_markdown_borderless_table = 1
+<
+ the table would be formatted as usual:
+>
+ | header 1 | header 2 |
+ |----------|----------|
+ | data 1 | data 2 |
+<
+
===============================================================================
*vim-markdown-mappings*
Mappings ~
- ']]': go to next header. '<Plug>Markdown_MoveToNextHeader'
*vim-markdown-[[*
-- '[[': go to previous header. Contrast with ']c'.
+- '[[': go to previous header. Contrast with ']h'.
'<Plug>Markdown_MoveToPreviousHeader'
*vim-markdown-][*
- '[]': go to previous sibling header if any.
'<Plug>Markdown_MoveToPreviousSiblingHeader'
- *vim-markdown-]c*
-- ']c': go to Current header. '<Plug>Markdown_MoveToCurHeader'
+ *vim-markdown-]h*
+- ']h': go to Current header. '<Plug>Markdown_MoveToCurHeader'
*vim-markdown-]u*
- ']u': go to parent header (Up). '<Plug>Markdown_MoveToParentHeader'
[2] https://github.com/gmarik/vundle
[3] https://github.com/tpope/vim-pathogen
[4] http://packages.qa.debian.org/v/vim-addon-manager.html
-[5] https://github.com/plasticboy/vim-markdown/archive/master.tar.gz
+[5] https://github.com/preservim/vim-markdown/archive/master.tar.gz
[6] https://github.com/klen/python-mode
[7] https://gohugo.io/content/front-matter/
[8] https://github.com/cespare/vim-toml
au! filetypedetect BufRead,BufNewFile *.md
endif
-" markdown filetype file
-au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} setfiletype markdown
-au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} setfiletype markdown
+" vint: -ProhibitAutocmdWithNoGroup
+au BufRead,BufNewFile *.{md,mdx,mdown,mkd,mkdn,markdown,mdwn} setfiletype markdown
+au BufRead,BufNewFile *.{md,mdx,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} setfiletype markdown
"TODO print messages when on visual mode. I only see VISUAL, not the messages.
-" Function interface phylosophy:
+" Function interface philosophy:
"
" - functions take arbitrary line numbers as parameters.
" Current cursor line is only a suitable default parameter.
\ 6: '\v^######[^#]@='
\ }
-" Maches any header level of any type.
+" Matches any header level of any type.
"
" This could be deduced from `s:levelRegexpDict`, but it is more
" efficient to have a single regexp for this.
"
function! s:MoveToCurHeader()
let l:lineNum = s:GetHeaderLineNum()
- if l:lineNum != 0
+ if l:lineNum !=# 0
call cursor(l:lineNum, 1)
else
echo 'outside any header'
let l:line = a:1
endif
let l:linenum = s:GetHeaderLineNum(l:line)
- if l:linenum != 0
+ if l:linenum !=# 0
return s:GetLevelOfHeaderAtLine(l:linenum)
else
return 0
endif
endfunction
+" Return list of headers and their levels.
+"
+function! s:GetHeaderList()
+ let l:bufnr = bufnr('%')
+ let l:fenced_block = 0
+ let l:front_matter = 0
+ let l:header_list = []
+ let l:vim_markdown_frontmatter = get(g:, 'vim_markdown_frontmatter', 0)
+ let l:fence_str = ''
+ for i in range(1, line('$'))
+ let l:lineraw = getline(i)
+ let l:l1 = getline(i+1)
+ let l:line = substitute(l:lineraw, '#', "\\\#", 'g')
+ " exclude lines in fenced code blocks
+ if l:line =~# '\v^[[:space:]>]*(`{3,}|\~{3,})\s*(\w+)?\s*$'
+ if l:fenced_block == 0
+ let l:fenced_block = 1
+ let l:fence_str = matchstr(l:line, '\v(`{3,}|\~{3,})')
+ elseif l:fenced_block == 1 && matchstr(l:line, '\v(`{3,}|\~{3,})') ==# l:fence_str
+ let l:fenced_block = 0
+ let l:fence_str = ''
+ endif
+ " exclude lines in frontmatters
+ elseif l:vim_markdown_frontmatter == 1
+ if l:front_matter == 1
+ if l:line ==# '---'
+ let l:front_matter = 0
+ endif
+ elseif i == 1
+ if l:line ==# '---'
+ let l:front_matter = 1
+ endif
+ endif
+ endif
+ " match line against header regex
+ if join(getline(i, i + 1), "\n") =~# s:headersRegexp && l:line =~# '^\S'
+ let l:is_header = 1
+ else
+ let l:is_header = 0
+ endif
+ if l:is_header ==# 1 && l:fenced_block ==# 0 && l:front_matter ==# 0
+ " remove hashes from atx headers
+ if match(l:line, '^#') > -1
+ let l:line = substitute(l:line, '\v^#*[ ]*', '', '')
+ let l:line = substitute(l:line, '\v[ ]*#*$', '', '')
+ endif
+ " append line to list
+ let l:level = s:GetHeaderLevel(i)
+ let l:item = {'level': l:level, 'text': l:line, 'lnum': i, 'bufnr': bufnr}
+ let l:header_list = l:header_list + [l:item]
+ endif
+ endfor
+ return l:header_list
+endfunction
+
" Returns the level of the header at the given line.
"
" If there is no header at the given line, returns `0`.
function! s:MoveToParentHeader()
let l:linenum = s:GetParentHeaderLineNumber()
if l:linenum != 0
+ call setpos("''", getpos('.'))
call cursor(l:linenum, 1)
else
echo 'no parent header'
endif
- let l:bufnr = bufnr('%')
let l:cursor_line = line('.')
let l:cursor_header = 0
- let l:fenced_block = 0
- let l:front_matter = 0
- let l:header_list = []
+ let l:header_list = s:GetHeaderList()
+ let l:indented_header_list = []
+ if len(l:header_list) == 0
+ echom 'Toc: No headers.'
+ return
+ endif
let l:header_max_len = 0
- let l:vim_markdown_toc_autofit = get(g:, "vim_markdown_toc_autofit", 0)
- let l:vim_markdown_frontmatter = get(g:, "vim_markdown_frontmatter", 0)
- for i in range(1, line('$'))
- let l:lineraw = getline(i)
- let l:l1 = getline(i+1)
- let l:line = substitute(l:lineraw, "#", "\\\#", "g")
- if l:line =~ '````*' || l:line =~ '\~\~\~\~*'
- if l:fenced_block == 0
- let l:fenced_block = 1
- elseif l:fenced_block == 1
- let l:fenced_block = 0
- endif
- elseif l:vim_markdown_frontmatter == 1
- if l:front_matter == 1
- if l:line == '---'
- let l:front_matter = 0
- endif
- elseif i == 1
- if l:line == '---'
- let l:front_matter = 1
- endif
+ let l:vim_markdown_toc_autofit = get(g:, 'vim_markdown_toc_autofit', 0)
+ for h in l:header_list
+ " set header number of the cursor position
+ if l:cursor_header == 0
+ let l:header_line = h.lnum
+ if l:header_line == l:cursor_line
+ let l:cursor_header = index(l:header_list, h) + 1
+ elseif l:header_line > l:cursor_line
+ let l:cursor_header = index(l:header_list, h)
endif
endif
- if l:line =~ '^#\+' || (l:l1 =~ '^=\+\s*$' || l:l1 =~ '^-\+\s*$') && l:line =~ '^\S'
- let l:is_header = 1
- else
- let l:is_header = 0
- endif
- if l:is_header == 1 && l:fenced_block == 0 && l:front_matter == 0
- " append line to location list
- let l:item = {'lnum': i, 'text': l:line, 'valid': 1, 'bufnr': l:bufnr, 'col': 1}
- let l:header_list = l:header_list + [l:item]
- " set header number of the cursor position
- if l:cursor_header == 0
- if i == l:cursor_line
- let l:cursor_header = len(l:header_list)
- elseif i > l:cursor_line
- let l:cursor_header = len(l:header_list) - 1
- endif
- endif
- " keep track of the longest header size (heading level + title)
- let l:total_len = stridx(l:line, ' ') + strdisplaywidth(l:line)
- if l:total_len > l:header_max_len
- let l:header_max_len = l:total_len
- endif
+ " indent header based on level
+ let l:text = repeat(' ', h.level-1) . h.text
+ " keep track of the longest header size (heading level + title)
+ let l:total_len = strdisplaywidth(l:text)
+ if l:total_len > l:header_max_len
+ let l:header_max_len = l:total_len
endif
+ " append indented line to list
+ let l:item = {'lnum': h.lnum, 'text': l:text, 'valid': 1, 'bufnr': h.bufnr, 'col': 1}
+ let l:indented_header_list = l:indented_header_list + [l:item]
endfor
- call setloclist(0, l:header_list)
- if len(l:header_list) == 0
- echom "Toc: No headers."
- return
- endif
+ call setloclist(0, l:indented_header_list)
if l:window_type ==# 'horizontal'
lopen
vertical lopen
" auto-fit toc window when possible to shrink it
if (&columns/2) > l:header_max_len && l:vim_markdown_toc_autofit == 1
- execute 'vertical resize ' . (l:header_max_len + 1)
+ " header_max_len + 1 space for first header + 3 spaces for line numbers
+ execute 'vertical resize ' . (l:header_max_len + 1 + 3)
else
execute 'vertical resize ' . (&columns/2)
endif
for i in range(1, line('$'))
" this is the location-list data for the current item
let d = getloclist(0)[i-1]
- " atx headers
- if match(d.text, "^#") > -1
- let l:level = len(matchstr(d.text, '#*', 'g'))-1
- let d.text = substitute(d.text, '\v^#*[ ]*', '', '')
- let d.text = substitute(d.text, '\v[ ]*#*$', '', '')
- " setex headers
- else
- let l:next_line = getbufline(d.bufnr, d.lnum+1)
- if match(l:next_line, "=") > -1
- let l:level = 0
- elseif match(l:next_line, "-") > -1
- let l:level = 1
- endif
- endif
- call setline(i, repeat(' ', l:level). d.text)
+ call setline(i, d.text)
endfor
setlocal nomodified
setlocal nomodifiable
execute 'normal! ' . l:cursor_header . 'G'
endfunction
+function! s:InsertToc(format, ...)
+ if a:0 > 0
+ if type(a:1) != type(0)
+ echohl WarningMsg
+ echomsg '[vim-markdown] Invalid argument, must be an integer >= 2.'
+ echohl None
+ return
+ endif
+ let l:max_level = a:1
+ if l:max_level < 2
+ echohl WarningMsg
+ echomsg '[vim-markdown] Maximum level cannot be smaller than 2.'
+ echohl None
+ return
+ endif
+ else
+ let l:max_level = 0
+ endif
+
+ let l:toc = []
+ let l:header_list = s:GetHeaderList()
+ if len(l:header_list) == 0
+ echom 'InsertToc: No headers.'
+ return
+ endif
+
+ if a:format ==# 'numbers'
+ let l:h2_count = 0
+ for header in l:header_list
+ if header.level == 2
+ let l:h2_count += 1
+ endif
+ endfor
+ let l:max_h2_number_len = strlen(string(l:h2_count))
+ else
+ let l:max_h2_number_len = 0
+ endif
+
+ let l:h2_count = 0
+ for header in l:header_list
+ let l:level = header.level
+ if l:level == 1
+ " skip level-1 headers
+ continue
+ elseif l:max_level != 0 && l:level > l:max_level
+ " skip unwanted levels
+ continue
+ elseif l:level == 2
+ " list of level-2 headers can be bullets or numbers
+ if a:format ==# 'bullets'
+ let l:indent = ''
+ let l:marker = '* '
+ else
+ let l:h2_count += 1
+ let l:number_len = strlen(string(l:h2_count))
+ let l:indent = repeat(' ', l:max_h2_number_len - l:number_len)
+ let l:marker = l:h2_count . '. '
+ endif
+ else
+ let l:indent = repeat(' ', l:max_h2_number_len + 2 * (l:level - 2))
+ let l:marker = '* '
+ endif
+ let l:text = '[' . header.text . ']'
+ let l:link = '(#' . substitute(tolower(header.text), '\v[ ]+', '-', 'g') . ')'
+ let l:line = l:indent . l:marker . l:text . l:link
+ let l:toc = l:toc + [l:line]
+ endfor
+
+ call append(line('.'), l:toc)
+endfunction
+
" Convert Setex headers in range `line1 .. line2` to Atx.
"
" Return the number of conversions.
function! s:SetexToAtx(line1, line2)
let l:originalNumLines = line('$')
execute 'silent! ' . a:line1 . ',' . a:line2 . 'substitute/\v(.*\S.*)\n\=+$/# \1/'
- execute 'silent! ' . a:line1 . ',' . a:line2 . 'substitute/\v(.*\S.*)\n-+$/## \1/'
+
+ let l:changed = l:originalNumLines - line('$')
+ execute 'silent! ' . a:line1 . ',' . (a:line2 - l:changed) . 'substitute/\v(.*\S.*)\n-+$/## \1'
return l:originalNumLines - line('$')
endfunction
"
function! s:TableFormat()
let l:pos = getpos('.')
+
+ if get(g:, 'vim_markdown_borderless_table', 0)
+ " add `|` to the beginning of the line if it isn't present
+ normal! {
+ call search('|')
+ execute 'silent .,''}s/\v^(\s{0,})\|?([^\|])/\1|\2/e'
+
+ " add `|` to the end of the line if it isn't present
+ normal! {
+ call search('|')
+ execute 'silent .,''}s/\v([^\|])\|?(\s{0,})$/\1|\2/e'
+ endif
+
normal! {
" Search instead of `normal! j` because of the table at beginning of file edge case.
call search('|')
let l:flags = (&gdefault ? '' : 'g')
execute 's/\(:\@<!-:\@!\|[^|:-]\)//e' . l:flags
execute 's/--/-/e' . l:flags
- Tabularize /|
+ Tabularize /\(\\\)\@<!|
" Move colons for alignment to left or right side of the cell.
execute 's/:\( \+\)|/\1:|/e' . l:flags
execute 's/|\( \+\):/|:\1/e' . l:flags
- execute 's/ /-/' . l:flags
+ execute 's/|:\?\zs[ -]\+\ze:\?|/\=repeat("-", len(submatch(0)))/' . l:flags
call setpos('.', l:pos)
endfunction
"
function! s:OpenUrlUnderCursor()
let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.'))
- if l:url != ''
- call s:VersionAwareNetrwBrowseX(l:url)
+ if l:url !=# ''
+ if l:url =~? 'http[s]\?:\/\/[[:alnum:]%\/_#.-]*'
+ "Do nothing
+ else
+ let l:url = expand(expand('%:h').'/'.l:url)
+ endif
+ call s:VersionAwareNetrwBrowseX(l:url)
else
echomsg 'The cursor is not on a link.'
endif
" script while this function is running. We must not replace it.
if !exists('*s:EditUrlUnderCursor')
function s:EditUrlUnderCursor()
+ let l:editmethod = ''
+ " determine how to open the linked file (split, tab, etc)
+ if exists('g:vim_markdown_edit_url_in')
+ if g:vim_markdown_edit_url_in ==# 'tab'
+ let l:editmethod = 'tabnew'
+ elseif g:vim_markdown_edit_url_in ==# 'vsplit'
+ let l:editmethod = 'vsp'
+ elseif g:vim_markdown_edit_url_in ==# 'hsplit'
+ let l:editmethod = 'sp'
+ else
+ let l:editmethod = 'edit'
+ endif
+ else
+ " default to current buffer
+ let l:editmethod = 'edit'
+ endif
let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.'))
- if l:url != ''
+ if l:url !=# ''
if get(g:, 'vim_markdown_autowrite', 0)
write
endif
if len(l:parts) == 2
let [l:url, l:anchor] = parts
let l:anchorexpr = get(g:, 'vim_markdown_anchorexpr', '')
- if l:anchorexpr != ''
+ if l:anchorexpr !=# ''
let l:anchor = eval(substitute(
\ l:anchorexpr, 'v:anchor',
\ escape('"'.l:anchor.'"', '"'), ''))
endif
endif
endif
- if l:url != ''
+ if l:url !=# ''
let l:ext = ''
if get(g:, 'vim_markdown_no_extensions_in_markdown', 0)
" use another file extension if preferred
endif
endif
let l:url = fnameescape(fnamemodify(expand('%:h').'/'.l:url.l:ext, ':.'))
- let l:editmethod = ''
- " determine how to open the linked file (split, tab, etc)
- if exists('g:vim_markdown_edit_url_in')
- if g:vim_markdown_edit_url_in == 'tab'
- let l:editmethod = 'tabnew'
- elseif g:vim_markdown_edit_url_in == 'vsplit'
- let l:editmethod = 'vsp'
- elseif g:vim_markdown_edit_url_in == 'hsplit'
- let l:editmethod = 'sp'
- else
- let l:editmethod = 'edit'
- endif
- else
- " default to current buffer
- let l:editmethod = 'edit'
- endif
execute l:editmethod l:url
endif
- if l:anchor != ''
- silent! execute '/'.l:anchor
+ if l:anchor !=# ''
+ call search(l:anchor, 's')
endif
else
- echomsg 'The cursor is not on a link.'
+ execute l:editmethod . ' <cfile>'
endif
endfunction
endif
call <sid>MapNotHasmapto('][', 'Markdown_MoveToNextSiblingHeader')
call <sid>MapNotHasmapto('[]', 'Markdown_MoveToPreviousSiblingHeader')
call <sid>MapNotHasmapto(']u', 'Markdown_MoveToParentHeader')
- call <sid>MapNotHasmapto(']c', 'Markdown_MoveToCurHeader')
+ call <sid>MapNotHasmapto(']h', 'Markdown_MoveToCurHeader')
call <sid>MapNotHasmapto('gx', 'Markdown_OpenUrlUnderCursor')
call <sid>MapNotHasmapto('ge', 'Markdown_EditUrlUnderCursor')
endif
command! -buffer -range=% HeaderDecrease call s:HeaderDecrease(<line1>, <line2>)
command! -buffer -range=% HeaderIncrease call s:HeaderDecrease(<line1>, <line2>, 1)
command! -buffer -range=% SetexToAtx call s:SetexToAtx(<line1>, <line2>)
-command! -buffer TableFormat call s:TableFormat()
+command! -buffer -range TableFormat call s:TableFormat()
command! -buffer Toc call s:Toc()
command! -buffer Toch call s:Toc('horizontal')
command! -buffer Tocv call s:Toc('vertical')
command! -buffer Toct call s:Toc('tab')
+command! -buffer -nargs=? InsertToc call s:InsertToc('bullets', <args>)
+command! -buffer -nargs=? InsertNToc call s:InsertToc('numbers', <args>)
" Heavily based on vim-notes - http://peterodding.com/code/vim/notes/
if exists('g:vim_markdown_fenced_languages')
let s:filetype_dict = {}
for s:filetype in g:vim_markdown_fenced_languages
- let key = matchstr(s:filetype, "[^=]*")
- let val = matchstr(s:filetype, "[^=]*$")
+ let key = matchstr(s:filetype, '[^=]*')
+ let val = matchstr(s:filetype, '[^=]*$')
let s:filetype_dict[key] = val
endfor
else
" Look for code blocks in the current file
let filetypes = {}
for line in getline(1, '$')
- let ft = matchstr(line, '```\s*\zs[0-9A-Za-z_+-]*')
- if !empty(ft) && ft !~ '^\d*$' | let filetypes[ft] = 1 | endif
+ let ft = matchstr(line, '\(`\{3,}\|\~\{3,}\)\s*\zs[0-9A-Za-z_+-]*\ze.*')
+ if !empty(ft) && ft !~# '^\d*$' | let filetypes[ft] = 1 | endif
endfor
if !exists('b:mkd_known_filetypes')
let b:mkd_known_filetypes = {}
else
let filetype = ft
endif
- let group = 'mkdSnippet' . toupper(substitute(filetype, "[+-]", "_", "g"))
+ let group = 'mkdSnippet' . toupper(substitute(filetype, '[+-]', '_', 'g'))
if !has_key(b:mkd_included_filetypes, filetype)
let include = s:SyntaxInclude(filetype)
let b:mkd_included_filetypes[filetype] = 1
else
let include = '@' . toupper(filetype)
endif
- let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s$" matchgroup=%s end="\s*```$" keepend contains=%s%s'
- execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '')
+ let command_backtick = 'syntax region %s matchgroup=%s start="^\s*`\{3,}\s*%s.*$" matchgroup=%s end="\s*`\{3,}$" keepend contains=%s%s'
+ let command_tilde = 'syntax region %s matchgroup=%s start="^\s*\~\{3,}\s*%s.*$" matchgroup=%s end="\s*\~\{3,}$" keepend contains=%s%s'
+ execute printf(command_backtick, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '')
+ execute printf(command_tilde, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '')
execute printf('syntax cluster mkdNonListItem add=%s', group)
let b:mkd_known_filetypes[ft] = 1
return grouplistname
endfunction
+function! s:IsHighlightSourcesEnabledForBuffer()
+ " Enable for markdown buffers, and for liquid buffers with markdown format
+ return &filetype =~# 'markdown' || get(b:, 'liquid_subtype', '') =~# 'markdown'
+endfunction
function! s:MarkdownRefreshSyntax(force)
- if &filetype =~ 'markdown' && line('$') > 1
+ " Use != to compare &syntax's value to use the same logic run on
+ " $VIMRUNTIME/syntax/synload.vim.
+ "
+ " vint: next-line -ProhibitEqualTildeOperator
+ if s:IsHighlightSourcesEnabledForBuffer() && line('$') > 1 && &syntax != 'OFF'
call s:MarkdownHighlightSources(a:force)
endif
endfunction
function! s:MarkdownClearSyntaxVariables()
- if &filetype =~ 'markdown'
+ if s:IsHighlightSourcesEnabledForBuffer()
unlet! b:mkd_included_filetypes
endif
endfunction
-if exists("b:did_indent") | finish | endif
+if exists('b:did_indent') | finish | endif
let b:did_indent = 1
setlocal indentexpr=GetMarkdownIndent()
" Automatically continue blockquote on line break
setlocal formatoptions+=r
setlocal comments=b:>
-if get(g:, "vim_markdown_auto_insert_bullets", 1)
+if get(g:, 'vim_markdown_auto_insert_bullets', 1)
" Do not automatically insert bullets when auto-wrapping with text-width
setlocal formatoptions-=c
" Accept various markers as bullets
endif
" Only define the function once
-if exists("*GetMarkdownIndent") | finish | endif
+if exists('*GetMarkdownIndent') | finish | endif
function! s:IsMkdCode(lnum)
let name = synIDattr(synID(a:lnum, 1, 0), 'name')
- return (name =~ '^mkd\%(Code$\|Snippet\)' || name != '' && name !~ '^\%(mkd\|html\)')
+ return (name =~# '^mkd\%(Code$\|Snippet\)' || name !=# '' && name !~? '^\%(mkd\|html\)')
endfunction
function! s:IsLiStart(line)
- return a:line !~ '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' &&
- \ a:line =~ '^\s*[*+-] \+'
+ return a:line !~# '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' &&
+ \ a:line =~# '^\s*[*+-] \+'
endfunction
function! s:IsHeaderLine(line)
- return a:line =~ '^\s*#'
+ return a:line =~# '^\s*#'
endfunction
function! s:IsBlankLine(line)
- return a:line =~ '^$'
+ return a:line =~# '^$'
endfunction
function! s:PrevNonBlank(lnum)
if v:lnum > 2 && s:IsBlankLine(getline(v:lnum - 1)) && s:IsBlankLine(getline(v:lnum - 2))
return 0
endif
- let list_ind = get(g:, "vim_markdown_new_list_item_indent", 4)
+ let list_ind = get(g:, 'vim_markdown_new_list_item_indent', 4)
" Find a non-blank line above the current line.
let lnum = s:PrevNonBlank(v:lnum - 1)
" At the start of the file use zero indent.
" Read the HTML syntax to start with
-if version < 600
+if v:version < 600
so <sfile>:p:h/html.vim
else
runtime! syntax/html.vim
endif
endif
-if version < 600
+if v:version < 600
syntax clear
-elseif exists("b:current_syntax")
+elseif exists('b:current_syntax')
finish
endif
" don't use standard HiLink, it will not work with included syntax files
-if version < 508
+if v:version < 508
command! -nargs=+ HtmlHiLink hi link <args>
else
command! -nargs=+ HtmlHiLink hi def link <args>
" Autolink without angle brackets.
" mkd inline links: protocol optional user:pass@ sub/domain .com, .co.uk, etc optional port path/querystring/hash fragment
" ------------ _____________________ ----------------------------- _________________________ ----------------- __
-syn match mkdInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/
+syn match mkdInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?[^] \t]*/
" Autolink with parenthesis.
-syn region mkdInlineURL matchgroup=mkdDelimiter start="(\(https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*)\)\@=" end=")"
+syn region mkdInlineURL matchgroup=mkdDelimiter start="(\(https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?[^] \t]*)\)\@=" end=")"
" Autolink with angle brackets.
syn region mkdInlineURL matchgroup=mkdDelimiter start="\\\@<!<\ze[a-z][a-z0-9,.-]\{1,22}:\/\/[^> ]*>" end=">"
syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained
"HTML headings
-syn region htmlH1 matchgroup=mkdHeading start="^\s*#" end="$" contains=mkdLink,mkdInlineURL,@Spell
-syn region htmlH2 matchgroup=mkdHeading start="^\s*##" end="$" contains=mkdLink,mkdInlineURL,@Spell
-syn region htmlH3 matchgroup=mkdHeading start="^\s*###" end="$" contains=mkdLink,mkdInlineURL,@Spell
-syn region htmlH4 matchgroup=mkdHeading start="^\s*####" end="$" contains=mkdLink,mkdInlineURL,@Spell
-syn region htmlH5 matchgroup=mkdHeading start="^\s*#####" end="$" contains=mkdLink,mkdInlineURL,@Spell
-syn region htmlH6 matchgroup=mkdHeading start="^\s*######" end="$" contains=mkdLink,mkdInlineURL,@Spell
-syn match htmlH1 /^.\+\n=\+$/ contains=mkdLink,mkdInlineURL,@Spell
-syn match htmlH2 /^.\+\n-\+$/ contains=mkdLink,mkdInlineURL,@Spell
+syn region htmlH1 matchgroup=mkdHeading start="^\s*#" end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH2 matchgroup=mkdHeading start="^\s*##" end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH3 matchgroup=mkdHeading start="^\s*###" end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH4 matchgroup=mkdHeading start="^\s*####" end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH5 matchgroup=mkdHeading start="^\s*#####" end="$" contains=@mkdHeadingContent,@Spell
+syn region htmlH6 matchgroup=mkdHeading start="^\s*######" end="$" contains=@mkdHeadingContent,@Spell
+syn match htmlH1 /^.\+\n=\+$/ contains=@mkdHeadingContent,@Spell
+syn match htmlH2 /^.\+\n-\+$/ contains=@mkdHeadingContent,@Spell
"define Markdown groups
syn match mkdLineBreak / \+$/
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(`\{3,}\)[^`]*$/ end=/^\s*\z1`*\s*$/' . s:concealcode
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@<!\~\~/ end=/\(\([^\\]\|^\)\\\)\@<!\~\~/' . s:concealcode
execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(\~\{3,}\)\s*[0-9A-Za-z_+-]*\s*$/ end=/^\s*\z1\~*\s*$/' . s:concealcode
-execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<pre[^>]*\\\@<!>" end="</pre>"' . s:concealcode
-execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<code[^>]*\\\@<!>" end="</code>"' . s:concealcode
+execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<pre\(\|\_s[^>]*\)\\\@<!>" end="</pre>"' . s:concealcode
+execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="<code\(\|\_s[^>]*\)\\\@<!>" end="</code>"' . s:concealcode
syn region mkdFootnote start="\[^" end="\]"
syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/
syn match mkdCode /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/
syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained
-syn match mkdListItem /^\s*\%([-*+]\|\d\+\.\)\ze\s\+/ contained
-syn region mkdListItemLine start="^\s*\%([-*+]\|\d\+\.\)\s\+" end="$" oneline contains=@mkdNonListItem,mkdListItem,@Spell
+syn match mkdListItem /^\s*\%([-*+]\|\d\+\.\)\ze\s\+/ contained nextgroup=mkdListItemCheckbox
+syn match mkdListItemCheckbox /\[[xXoO ]\]\ze\s\+/ contained contains=mkdListItem
+syn region mkdListItemLine start="^\s*\%([-*+]\|\d\+\.\)\s\+" end="$" oneline contains=@mkdNonListItem,mkdListItem,mkdListItemCheckbox,@Spell
syn region mkdNonListItemBlock start="\(\%^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@!\|\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!\)" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell
syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*\(\*\|\s\)*$/
syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-\(-\|\s\)*$/
HtmlHiLink mkdStrike htmlStrike
endif
+syn cluster mkdHeadingContent contains=htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdLink,mkdInlineURL,mkdStrike,mkdCode
syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath,mkdStrike
"highlighting for Markdown groups
-HtmlHiLink mkdString String
-HtmlHiLink mkdCode String
-HtmlHiLink mkdCodeDelimiter String
-HtmlHiLink mkdCodeStart String
-HtmlHiLink mkdCodeEnd String
-HtmlHiLink mkdFootnote Comment
-HtmlHiLink mkdBlockquote Comment
-HtmlHiLink mkdListItem Identifier
-HtmlHiLink mkdRule Identifier
-HtmlHiLink mkdLineBreak Visual
-HtmlHiLink mkdFootnotes htmlLink
-HtmlHiLink mkdLink htmlLink
-HtmlHiLink mkdURL htmlString
-HtmlHiLink mkdInlineURL htmlLink
-HtmlHiLink mkdID Identifier
-HtmlHiLink mkdLinkDef mkdID
-HtmlHiLink mkdLinkDefTarget mkdURL
-HtmlHiLink mkdLinkTitle htmlString
-HtmlHiLink mkdDelimiter Delimiter
-
-let b:current_syntax = "mkd"
+HtmlHiLink mkdString String
+HtmlHiLink mkdCode String
+HtmlHiLink mkdCodeDelimiter String
+HtmlHiLink mkdCodeStart String
+HtmlHiLink mkdCodeEnd String
+HtmlHiLink mkdFootnote Comment
+HtmlHiLink mkdBlockquote Comment
+HtmlHiLink mkdListItem Identifier
+HtmlHiLink mkdListItemCheckbox Identifier
+HtmlHiLink mkdRule Identifier
+HtmlHiLink mkdLineBreak Visual
+HtmlHiLink mkdFootnotes htmlLink
+HtmlHiLink mkdLink htmlLink
+HtmlHiLink mkdURL htmlString
+HtmlHiLink mkdInlineURL htmlLink
+HtmlHiLink mkdID Identifier
+HtmlHiLink mkdLinkDef mkdID
+HtmlHiLink mkdLinkDefTarget mkdURL
+HtmlHiLink mkdLinkTitle htmlString
+HtmlHiLink mkdDelimiter Delimiter
+
+let b:current_syntax = 'mkd'
delcommand HtmlHiLink
" vim: ts=8
Before:
source ../after/ftplugin/markdown.vim
+ setlocal foldtext=foldtext()
After:
setlocal foldexpr=0
let res = getloclist(0)
let elem = res[0]
AssertEqual elem.lnum, 1
- AssertEqual elem.text, '# chap 1'
+ AssertEqual elem.text, 'chap 1'
let elem = res[1]
AssertEqual elem.lnum, 15
- AssertEqual elem.text, '## chap 1.1'
+ AssertEqual elem.text, ' chap 1.1'
let elem = res[2]
AssertEqual elem.lnum, 25
- AssertEqual elem.text, '### chap 1.1.1'
+ AssertEqual elem.text, ' chap 1.1.1'
let elem = res[3]
AssertEqual elem.lnum, 30
- AssertEqual elem.text, '# chap 2'
+ AssertEqual elem.text, 'chap 2'
let elem = res[4]
AssertEqual elem.lnum, 34
- AssertEqual elem.text, '## chap 2.1'
+ AssertEqual elem.text, ' chap 2.1'
let elem = res[5]
AssertEqual elem.lnum, 41
- AssertEqual elem.text, '# chap 3'
+ AssertEqual elem.text, 'chap 3'
let elem = res[6]
AssertEqual elem.lnum, 45
AssertEqual elem.text, 'chap 4'
let elem = res[7]
AssertEqual elem.lnum, 50
- AssertEqual elem.text, 'chap 4.1'
+ AssertEqual elem.text, ' chap 4.1'
Given markdown;
---
AssertEqual len(res), 1
let elem = res[0]
AssertEqual elem.lnum, 8
- AssertEqual elem.text, 'heading'
+ AssertEqual elem.text, ' heading'
unlet g:vim_markdown_frontmatter
--- /dev/null
+Given markdown;
+# a
+
+## b
+
+### c
+
+#### d
+
+##### e
+
+Execute (HeaderIncrease without forbidden level):
+ :HeaderIncrease
+
+Expect (increase level of all headers):
+ ## a
+
+ ### b
+
+ #### c
+
+ ##### d
+
+ ###### e
+
+Given markdown;
+# a
+
+###### b
+
+Execute (HeaderIncrease with forbidden level):
+ :HeaderIncrease
+
+Expect (no changes):
+ # a
+
+ ###### b
+
+Given markdown;
+## a
+
+### b
+
+#### c
+
+##### d
+
+###### e
+
+Execute (HeaderDecrease without forbidden level):
+ :HeaderDecrease
+
+Expect (decrease level of all headers):
+ # a
+
+ ## b
+
+ ### c
+
+ #### d
+
+ ##### e
+
+Given markdown;
+# a
+
+## b
+
+### c
+
+#### d
+
+##### e
+
+###### f
+
+Execute (HeaderDecrease with forbidden level):
+ :HeaderDecrease
+
+Expect (no changes):
+ # a
+
+ ## b
+
+ ### c
+
+ #### d
+
+ ##### e
+
+ ###### f
+
+Given markdown;
+a
+=
+
+b
+-
+
+Execute (HeaderIncrease with setext headers):
+ :HeaderIncrease
+
+Expect (convert to atx headers):
+ ## a
+
+ ### b
+
+Given markdown;
+a
+-
+
+Execute (HeaderDecrease with setext headers):
+ :HeaderDecrease
+
+Expect (convert to atx headers):
+ # a
--- /dev/null
+Given markdown;
+# a
+
+## Foo Level 2
+
+### Foo Level 3
+
+#### Foo Level 4
+
+Bar Level 2
+-----------
+
+### Bar Level 3
+
+Execute (InsertToc format):
+ :2
+ :call append('.', '')
+ :InsertToc
+
+Expect (format):
+ # a
+
+ * [Foo Level 2](#foo-level-2)
+ * [Foo Level 3](#foo-level-3)
+ * [Foo Level 4](#foo-level-4)
+ * [Bar Level 2](#bar-level-2)
+ * [Bar Level 3](#bar-level-3)
+
+ ## Foo Level 2
+
+ ### Foo Level 3
+
+ #### Foo Level 4
+
+ Bar Level 2
+ -----------
+
+ ### Bar Level 3
+
+Given markdown;
+# a
+
+## Foo Level 2
+
+### Foo Level 3
+
+#### Foo Level 4
+
+Bar Level 2
+-----------
+
+### Bar Level 3
+
+Execute (InsertToc only h2 headers):
+ :2
+ :call append('.', '')
+ :InsertToc 2
+
+Expect (only h2 headers):
+ # a
+
+ * [Foo Level 2](#foo-level-2)
+ * [Bar Level 2](#bar-level-2)
+
+ ## Foo Level 2
+
+ ### Foo Level 3
+
+ #### Foo Level 4
+
+ Bar Level 2
+ -----------
+
+ ### Bar Level 3
+
+Given markdown;
+# a
+
+## Foo Level 2
+
+### Foo Level 3
+
+#### Foo Level 4
+
+Bar Level 2
+-----------
+
+## Baz Level 2
+
+## Foobar Level 2
+
+## Foobaz Level 2
+
+## Barfoo Level 2
+
+## Barbaz Level 2
+
+## Bazfoo Level 2
+
+## Bazbar Level 2
+
+## Foobarbaz Level 2
+
+Execute (InsertNToc format, and up to h3 headers):
+ :2
+ :call append('.', '')
+ :InsertNToc 3
+
+Expect (format, and up to h3 headers):
+ # a
+
+ 1. [Foo Level 2](#foo-level-2)
+ * [Foo Level 3](#foo-level-3)
+ 2. [Bar Level 2](#bar-level-2)
+ 3. [Baz Level 2](#baz-level-2)
+ 4. [Foobar Level 2](#foobar-level-2)
+ 5. [Foobaz Level 2](#foobaz-level-2)
+ 6. [Barfoo Level 2](#barfoo-level-2)
+ 7. [Barbaz Level 2](#barbaz-level-2)
+ 8. [Bazfoo Level 2](#bazfoo-level-2)
+ 9. [Bazbar Level 2](#bazbar-level-2)
+ 10. [Foobarbaz Level 2](#foobarbaz-level-2)
+
+ ## Foo Level 2
+
+ ### Foo Level 3
+
+ #### Foo Level 4
+
+ Bar Level 2
+ -----------
+
+ ## Baz Level 2
+
+ ## Foobar Level 2
+
+ ## Foobaz Level 2
+
+ ## Barfoo Level 2
+
+ ## Barbaz Level 2
+
+ ## Bazfoo Level 2
+
+ ## Bazbar Level 2
+
+ ## Foobarbaz Level 2
b
-Execute (]c):
+Execute (]h):
normal! 3G
AssertEqual line('.'), 3
- normal ]c
+ normal ]h
AssertEqual line('.'), 1
--- /dev/null
+Given markdown;
+# a
+
+a
+=
+
+## b
+
+b
+-
+
+Execute (SetexToAtx):
+ :SetexToAtx
+
+Expect (convert setex-style headings to atx):
+ # a
+
+ # a
+
+ ## b
+
+ ## b
+
+Given markdown;
+a
+=
+
+b
+=
+
+c
+-
+
+d
+-
+
+Execute (SetexToAtx with range):
+ :1,8SetexToAtx
+
+Expect (only convert setex headings in original range):
+ # a
+
+ # b
+
+ ## c
+
+ d
+ -
--- /dev/null
+Before:
+ let g:vim_markdown_strikethrough = 1
+ syn off | syn on
+
+After:
+ unlet! g:vim_markdown_strikethrough
+
+Given markdown;
+a ~~b~~ c
+
+Execute (strikethrough):
+ AssertNotEqual SyntaxOf('a'), 'mkdStrike'
+ AssertEqual SyntaxOf('b'), 'mkdStrike'
+ AssertNotEqual SyntaxOf('c'), 'mkdStrike'
+
+Given markdown;
+# ~~h1~~
+## ~~h2~~
+### ~~h3~~
+#### ~~h4~~
+##### ~~h5~~
+###### ~~h6~~
+
+Execute (strikethrough in atx headings):
+ AssertEqual SyntaxOf('h1'), 'mkdStrike'
+ AssertEqual SyntaxOf('h2'), 'mkdStrike'
+ AssertEqual SyntaxOf('h3'), 'mkdStrike'
+ AssertEqual SyntaxOf('h4'), 'mkdStrike'
+ AssertEqual SyntaxOf('h5'), 'mkdStrike'
+ AssertEqual SyntaxOf('h6'), 'mkdStrike'
+
+Given markdown;
+~~h1~~
+=
+
+~~h2~~
+-
+
+Execute (strikethrough in setext headings):
+ AssertEqual SyntaxOf('h1'), 'mkdStrike'
+ AssertEqual SyntaxOf('h2'), 'mkdStrike'
[a]( b
"c" )
-a (`a`) b. Fix: <https://github.com/plasticboy/vim-markdown/issues/113>
+a (`a`) b. Fix: <https://github.com/preservim/vim-markdown/issues/113>
Escaped:
unlet! b:mkd_known_filetypes
unlet! b:mkd_included_filetypes
unlet! g:vim_markdown_math
+ unlet! b:liquid_subtype
Given markdown;
a **b** c
Execute (link with url title):
AssertEqual SyntaxOf('https://domain.tld'), 'mkdInlineURL'
- AssertEqual SyntaxOf('https://domain.com'), 'mkdInlineURL'
+ AssertNotEqual SyntaxOf(']'), 'mkdInlineURL'
+ AssertEqual SyntaxOf('https://domain.com'), 'mkdURL'
AssertNotEqual SyntaxOf('not_a_link'), 'mkdInlineURL'
# Code Blocks
end
```
+```ruby {linenos=table,hl_lines=[8,"15-17"],linenostart=199}
+class b
+end
+```
+
Execute (fenced code block syntax with a language specifier):
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
call b:func(0)
AssertEqual SyntaxOf('include'), 'cInclude'
AssertEqual SyntaxOf('code'), 'mkdSnippetCPP'
AssertEqual SyntaxOf('def'), 'rubyDefine'
+ AssertEqual SyntaxOf('class'), 'rubyClass'
Given markdown;
``` c++
Execute (fenced code block with extended info strings):
AssertEqual SyntaxOf('a'), 'mkdCode'
+Given liquid;
+```vim
+let g:a = 1
+```
+
+Execute (fenced code block syntax in liquid file with markdown subtype):
+ let b:liquid_subtype = 'markdown'
+ let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
+ call b:func(0)
+ AssertEqual SyntaxOf('g:a'), 'vimVar'
+
# Code Blocks in pre and code tag
Given markdown;
Execute (math tex highlighting):
let g:vim_markdown_math=0
syn off | syn on
- AssertNotEqual SyntaxOf('sqrt'), 'texStatement'
- AssertNotEqual SyntaxOf('frac'), 'texStatement'
+ AssertNotEqual SyntaxOf('sqrt')[0:2], 'tex'
+ AssertNotEqual SyntaxOf('frac')[0:2], 'tex'
let g:vim_markdown_math=1
syn off | syn on
- AssertEqual SyntaxOf('sqrt'), 'texStatement'
- AssertEqual SyntaxOf('frac'), 'texStatement'
+ AssertEqual SyntaxOf('sqrt')[0:2], 'tex'
+ AssertEqual SyntaxOf('frac')[0:2], 'tex'
Given markdown;
$a b[$ c
AssertNotEqual SyntaxOf('c')[0:2], 'tex'
Given markdown;
-$(0 \le 1)$
+$(0 \leq 1)$
Execute (math conceal in $):
if has('conceal')
AssertEqual synconcealed(1, 2)[0], 0
AssertEqual synconcealed(1, 3)[0], 0
AssertEqual synconcealed(1, 4)[0], 0
- AssertEqual synconcealed(1, 5)[0], 1, '\le'
+ AssertEqual synconcealed(1, 5)[0], 1, '\leq'
AssertEqual synconcealed(1, 6)[0], 1
AssertEqual synconcealed(1, 7)[0], 1
- AssertEqual synconcealed(1, 8)[0], 0
+ AssertEqual synconcealed(1, 8)[0], 1
AssertEqual synconcealed(1, 9)[0], 0
AssertEqual synconcealed(1, 10)[0], 0
- AssertEqual synconcealed(1, 11)[0], 1, '$'
+ AssertEqual synconcealed(1, 11)[0], 0
+ AssertEqual synconcealed(1, 12)[0], 1, '$'
setlocal conceallevel=0
endif
Given markdown;
$$
\omega
-0 \le 1
+0 \leq 1
$$
Execute (math conceal in $$):
AssertEqual synconcealed(1, 1)[0], 1, '$$'
AssertEqual synconcealed(2, 1)[0], 1, '\omega'
AssertEqual synconcealed(3, 1)[0], 0, '0'
- AssertEqual synconcealed(3, 3)[0], 1, '\le'
- AssertEqual synconcealed(3, 7)[0], 0, '1'
+ AssertEqual synconcealed(3, 3)[0], 1, '\leq'
+ AssertEqual synconcealed(3, 8)[0], 0, '1'
AssertEqual synconcealed(4, 1)[0], 1, '$$'
setlocal conceallevel=0
endif
AssertEqual SyntaxOf('span'), 'htmlTagName'
AssertEqual SyntaxOf('<span>'), 'htmlTag'
AssertEqual SyntaxOf('</span>'), 'htmlEndTag'
+
+Given markdown;
+# _h1_
+
+## _h2_
+
+### _h3_
+
+#### _h4_
+
+##### _h5_
+
+###### _h6_
+
+Execute (underscore italic text in atx headings):
+ AssertEqual SyntaxOf('h1'), 'htmlItalic'
+ AssertEqual SyntaxOf('h2'), 'htmlItalic'
+ AssertEqual SyntaxOf('h3'), 'htmlItalic'
+ AssertEqual SyntaxOf('h4'), 'htmlItalic'
+ AssertEqual SyntaxOf('h5'), 'htmlItalic'
+ AssertEqual SyntaxOf('h6'), 'htmlItalic'
+
+Given markdown;
+# *h1*
+
+## *h2*
+
+### *h3*
+
+#### *h4*
+
+##### *h5*
+
+###### *h6*
+
+Execute (asterisk italic text in atx headings):
+ AssertEqual SyntaxOf('h1'), 'htmlItalic'
+ AssertEqual SyntaxOf('h2'), 'htmlItalic'
+ AssertEqual SyntaxOf('h3'), 'htmlItalic'
+ AssertEqual SyntaxOf('h4'), 'htmlItalic'
+ AssertEqual SyntaxOf('h5'), 'htmlItalic'
+ AssertEqual SyntaxOf('h6'), 'htmlItalic'
+
+Given markdown;
+_h1_
+=
+
+_h2_
+-
+
+Execute (underscore italic text in setext headings):
+ AssertEqual SyntaxOf('h1'), 'htmlItalic'
+ AssertEqual SyntaxOf('h2'), 'htmlItalic'
+
+Given markdown;
+*h1*
+=
+
+*h2*
+-
+
+Execute (asterisk italic text in setext headings):
+ AssertEqual SyntaxOf('h1'), 'htmlItalic'
+ AssertEqual SyntaxOf('h2'), 'htmlItalic'
+
+Given markdown;
+# __h1__
+
+## __h2__
+
+### __h3__
+
+#### __h4__
+
+##### __h5__
+
+###### __h6__
+
+Execute (underscore bold text in atx headings):
+ AssertEqual SyntaxOf('h1'), 'htmlBold'
+ AssertEqual SyntaxOf('h2'), 'htmlBold'
+ AssertEqual SyntaxOf('h3'), 'htmlBold'
+ AssertEqual SyntaxOf('h4'), 'htmlBold'
+ AssertEqual SyntaxOf('h5'), 'htmlBold'
+ AssertEqual SyntaxOf('h6'), 'htmlBold'
+
+Given markdown;
+# **h1**
+
+## **h2**
+
+### **h3**
+
+#### **h4**
+
+##### **h5**
+
+###### **h6**
+
+Execute (asterisk bold text in atx headings):
+ AssertEqual SyntaxOf('h1'), 'htmlBold'
+ AssertEqual SyntaxOf('h2'), 'htmlBold'
+ AssertEqual SyntaxOf('h3'), 'htmlBold'
+ AssertEqual SyntaxOf('h4'), 'htmlBold'
+ AssertEqual SyntaxOf('h5'), 'htmlBold'
+ AssertEqual SyntaxOf('h6'), 'htmlBold'
+
+Given markdown;
+__h1__
+=
+
+__h2__
+-
+
+Execute (underscore bold text in setext headings):
+ AssertEqual SyntaxOf('h1'), 'htmlBold'
+ AssertEqual SyntaxOf('h2'), 'htmlBold'
+
+Given markdown;
+**h1**
+=
+
+**h2**
+-
+
+Execute (asterisk bold text in setext headings):
+ AssertEqual SyntaxOf('h1'), 'htmlBold'
+ AssertEqual SyntaxOf('h2'), 'htmlBold'
+
+Given markdown;
+# ___h1___
+
+## ___h2___
+
+### ___h3___
+
+#### ___h4___
+
+##### ___h5___
+
+###### ___h6___
+
+Execute (underscore bold italic text in atx headings):
+ AssertEqual SyntaxOf('h1'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h2'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h3'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h4'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h5'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h6'), 'htmlBoldItalic'
+
+Given markdown;
+# ***h1***
+
+## ***h2***
+
+### ***h3***
+
+#### ***h4***
+
+##### ***h5***
+
+###### ***h6***
+
+Execute (asterisk bold italic text in atx headings):
+ AssertEqual SyntaxOf('h1'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h2'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h3'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h4'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h5'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h6'), 'htmlBoldItalic'
+
+Given markdown;
+___h1___
+=
+
+___h2___
+-
+
+Execute (underscore bold italic text in setext headings):
+ AssertEqual SyntaxOf('h1'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h2'), 'htmlBoldItalic'
+
+Given markdown;
+***h1***
+=
+
+***h2***
+-
+
+Execute (asterisk bold italic text in setext headings):
+ AssertEqual SyntaxOf('h1'), 'htmlBoldItalic'
+ AssertEqual SyntaxOf('h2'), 'htmlBoldItalic'
+
+Given markdown;
+# [^h1]
+
+## [^h2]
+
+### [^h3]
+
+#### [^h4]
+
+##### [^h5]
+
+###### [^h6]
+
+Execute (footnotes in atx headings):
+ AssertEqual SyntaxOf('h1'), 'mkdFootnotes'
+ AssertEqual SyntaxOf('h2'), 'mkdFootnotes'
+ AssertEqual SyntaxOf('h3'), 'mkdFootnotes'
+ AssertEqual SyntaxOf('h4'), 'mkdFootnotes'
+ AssertEqual SyntaxOf('h5'), 'mkdFootnotes'
+ AssertEqual SyntaxOf('h6'), 'mkdFootnotes'
+
+Given markdown;
+[^h1]
+=
+
+[^h2]
+-
+
+Execute (footnotes in setext headings):
+ AssertEqual SyntaxOf('h1'), 'mkdFootnotes'
+ AssertEqual SyntaxOf('h2'), 'mkdFootnotes'
|---|---|
| c | d |
+Given markdown (indented table);
+ | a | b |
+ |---|---|
+ | c | d |
+
+Execute (format well formatted, indented table):
+ TableFormat
+
+Expect (table is not modified):
+ | a | b |
+ |---|---|
+ | c | d |
+
Given markdown;
| left |right| center ||
| :- | --: |:---:|:|
| left | right | center | |
|:-----|------:|:------:|:--|
| left | right | center | |
+
+Given markdown (indented table with colons);
+ | left |right| center ||
+ | :- | --: |:---:|:|
+ | left |right| center ||
+
+Execute (format indented table with colons):
+ TableFormat
+
+Expect (preserve colons to align text):
+ | left | right | center | |
+ |:-----|------:|:------:|:--|
+ | left | right | center | |
+
+Given markdown (borderless table);
+ left |right| center
+ :- | --: |:---:
+ left |right| center
+
+Execute (format borderless table):
+ let g:vim_markdown_borderless_table = 1
+ TableFormat
+ unlet g:vim_markdown_borderless_table
+
+Expect (table with borders):
+ | left | right | center |
+ |:-----|------:|:------:|
+ | left | right | center |
set nocompatible
-set rtp+=../
-set rtp+=../build/tabular/
-set rtp+=../build/vim-toml/
-set rtp+=../build/vim-json/
-set rtp+=../build/vader.vim/
-set rtp-=~/.vim
-set rtp-=~/.vim/after
+
let $LANG='en_US'
+
+filetype off
+set runtimepath+=../
+set runtimepath+=../build/tabular/
+set runtimepath+=../build/vim-toml/
+set runtimepath+=../build/vim-json/
+set runtimepath+=../build/vader.vim/
filetype on
-filetype plugin on
-filetype indent on
-syntax on
+
+filetype plugin indent on
+syntax enable
function! Markdown_GetScriptID(fname) abort
let l:snlist = ''
endif
endfor
endfunction
+
function! Markdown_GetFunc(fname, funcname) abort
return function('<SNR>' . Markdown_GetScriptID(a:fname) . '_' . a:funcname)
endfunction