]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'c58a4f3586473f7476510714698e60835fcb94ef'
authormartin f. krafft <madduck@madduck.net>
Tue, 8 Apr 2025 15:01:19 +0000 (17:01 +0200)
committermartin f. krafft <madduck@madduck.net>
Tue, 8 Apr 2025 15:01:19 +0000 (17:01 +0200)
22 files changed:
1  2 
.vim/bundle/vim-markdown/.github/workflows/reviewdog.yml
.vim/bundle/vim-markdown/.github/workflows/vader.yml
.vim/bundle/vim-markdown/.github/workflows/vint.yml
.vim/bundle/vim-markdown/.vintrc.yaml
.vim/bundle/vim-markdown/CONTRIBUTING.md
.vim/bundle/vim-markdown/README.md
.vim/bundle/vim-markdown/after/ftplugin/markdown.vim
.vim/bundle/vim-markdown/doc/vim-markdown.txt
.vim/bundle/vim-markdown/ftdetect/markdown.vim
.vim/bundle/vim-markdown/ftplugin/markdown.vim
.vim/bundle/vim-markdown/indent/markdown.vim
.vim/bundle/vim-markdown/syntax/markdown.vim
.vim/bundle/vim-markdown/test/folding-toc.vader
.vim/bundle/vim-markdown/test/header-decrease.vader
.vim/bundle/vim-markdown/test/insert-toc.vader
.vim/bundle/vim-markdown/test/map.vader
.vim/bundle/vim-markdown/test/setextoatx.vader
.vim/bundle/vim-markdown/test/strikethrough.vader
.vim/bundle/vim-markdown/test/syntax.md
.vim/bundle/vim-markdown/test/syntax.vader
.vim/bundle/vim-markdown/test/table-format.vader
.vim/bundle/vim-markdown/test/vimrc

index 0000000000000000000000000000000000000000,421e438b5df04219c1d157178f1e12f42f1884ed..421e438b5df04219c1d157178f1e12f42f1884ed
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,13 +1,13 @@@
+ 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
index 0000000000000000000000000000000000000000,05b12ecb8aa5b477c01cfbe4c0a26da9147330c3..05b12ecb8aa5b477c01cfbe4c0a26da9147330c3
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,31 +1,31 @@@
+ 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! *"
index 0000000000000000000000000000000000000000,909de43ace24edfb08f8687313cfa4c843a4f12e..909de43ace24edfb08f8687313cfa4c843a4f12e
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,15 +1,15 @@@
+ 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 .
index 0000000000000000000000000000000000000000,c44b6aba8904d827c6cffd781fc99e3c2b21e3d4..c44b6aba8904d827c6cffd781fc99e3c2b21e3d4
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,5 +1,5 @@@
+ cmdargs:
+   severity: style_problem
+   color: true
+   env:
+     neovim: false
index 86912a4a67ac6b7f9f33041e17539c0eaca3f2ed,736f0238071a1c02f584a042c4a155761bbd8ec9..736f0238071a1c02f584a042c4a155761bbd8ec9
@@@ -34,7 -34,7 +34,7 @@@ There are many flavors of markdown, eac
  
  ## 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.
  
@@@ -46,7 -46,7 +46,7 @@@ All new features must have unit tests
  
  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:
index fd3be68762df7eb7c81fb72bcbe5a2270548142a,3ccf532547fcdde3d4494d2b86f0175f3f773fcc..3ccf532547fcdde3d4494d2b86f0175f3f773fcc
@@@ -1,6 -1,7 +1,7 @@@
  # Vim Markdown
  
- [![Build Status](https://travis-ci.org/plasticboy/vim-markdown.svg)](https://travis-ci.org/plasticboy/vim-markdown)
+ [![Vint](https://github.com/preservim/vim-markdown/workflows/Vint/badge.svg)](https://github.com/preservim/vim-markdown/actions?workflow=Vint)
+ [![Vader](https://github.com/preservim/vim-markdown/workflows/Vader/badge.svg)](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.
  
@@@ -18,7 -19,7 +19,7 @@@ If you use [Vundle](https://github.com/
  
  ```vim
  Plugin 'godlygeek/tabular'
- Plugin 'plasticboy/vim-markdown'
+ Plugin 'preservim/vim-markdown'
  ```
  
  The `tabular` plugin must come *before* `vim-markdown`.
@@@ -34,19 -35,21 +35,21 @@@ If you use [Pathogen](https://github.co
  
  ```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
@@@ -65,8 -68,10 +68,10 @@@ The following commands are useful to op
  - `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
  
@@@ -261,8 -266,6 +266,6 @@@ The following options control which syn
  
      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`
  
@@@ -433,11 -455,17 +455,17 @@@ The following requires `:filetype plugi
  
  -   `: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.
  
index 8be6ff918be1c33aca7912f17a1384b86254cea7,390515ffbf7c629a03497010f42b9ca087441d18..390515ffbf7c629a03497010f42b9ca087441d18
@@@ -9,35 -9,41 +9,41 @@@
  
  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
@@@ -45,8 -51,8 +51,8 @@@
          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
@@@ -168,12 -178,12 +178,12 @@@ endi
  
  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
  
index 4d73129328a98f6413d227559bd447a4050626a4,3e843571ab6dfc51c01b1752d74b28242aa9db8a..3e843571ab6dfc51c01b1752d74b28242aa9db8a
@@@ -55,7 -55,7 +55,7 @@@ Installation 
  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'.
  
@@@ -67,11 -67,11 +67,11 @@@ Then run inside Vim
  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
@@@ -102,9 -102,13 +102,13 @@@ The following commands are useful to op
                                                                *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*
@@@ -490,6 -494,30 +494,30 @@@ Change how to open new files 
  >
    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 ~
@@@ -525,7 -553,7 +553,7 @@@ The following work on normal and visua
  - ']]': 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'
@@@ -651,7 -679,7 +679,7 @@@ References 
  [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
index 07682da4cd5da623e60725215198c89f5bda7411,e7c6f864ca91b68e69f26e0f4f39ff99c70db6d0..e7c6f864ca91b68e69f26e0f4f39ff99c70db6d0
@@@ -3,6 -3,6 +3,6 @@@ if !has('patch-7.4.480'
      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
index 200293e840bbc2bb1181900e727cd0270fe00407,33ed3cc96a1e59280caa4f2319048dd731f39bf4..33ed3cc96a1e59280caa4f2319048dd731f39bf4
@@@ -1,6 -1,6 +1,6 @@@
  "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.
@@@ -56,7 -56,7 +56,7 @@@ let s:levelRegexpDict = 
      \ 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.
@@@ -94,7 -94,7 +94,7 @@@ endfunctio
  "
  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'
@@@ -147,13 -147,68 +147,68 @@@ function! s:GetHeaderLevel(...
          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`.
@@@ -175,6 -230,7 +230,7 @@@ endfunctio
  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'
@@@ -303,65 -359,38 +359,38 @@@ function! s:Toc(...
      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
  
@@@ -452,6 -541,19 +541,19 @@@ endfunctio
  "
  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
  
@@@ -569,8 -671,13 +671,13 @@@ endfunctio
  "
  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
@@@ -580,8 -687,24 +687,24 @@@ endfunctio
  " 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
@@@ -666,7 -773,7 +773,7 @@@ if !get(g:, 'vim_markdown_no_default_ke
      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
@@@ -702,8 -811,8 +811,8 @@@ function! s:MarkdownHighlightSources(fo
      " 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
@@@ -766,15 -877,23 +877,23 @@@ function! s:SyntaxInclude(filetype
      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
index 2fa4cda8f7686fb9dd43a76286ea0e6088688080,a954c92346146cb7067a23440d827d0227eb40d7..a954c92346146cb7067a23440d827d0227eb40d7
@@@ -1,4 -1,4 +1,4 @@@
- if exists("b:did_indent") | finish | endif
+ if exists('b:did_indent') | finish | endif
  let b:did_indent = 1
  
  setlocal indentexpr=GetMarkdownIndent()
@@@ -8,7 -8,7 +8,7 @@@ setlocal autoinden
  " 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)
@@@ -48,7 -48,7 +48,7 @@@ function GetMarkdownIndent(
      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.
index c1a2b2cae04ee9390a049069b8ce4619cc60e33b,07ae0a8a4eefdbec784cf22a23b4bf8ad95ad7bd..07ae0a8a4eefdbec784cf22a23b4bf8ad95ad7bd
@@@ -7,7 -7,7 +7,7 @@@
  
  
  " 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>
@@@ -70,10 -70,10 +70,10 @@@ execute 'syn region mkdLink matchgroup=
  " 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=">"
@@@ -86,14 -86,14 +86,14 @@@ syn region mkdLinkTitle matchgroup=mkdD
  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    /  \+$/
@@@ -103,14 -103,15 +103,15 @@@ execute 'syn region mkdCode matchgroup=
  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\)*$/
@@@ -155,30 -156,32 +156,32 @@@ if get(g:, 'vim_markdown_strikethrough'
      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
index 79c5400185d0b710a64fa8107a599a2916a63285,8d688f77e9cde2eb1f3a742dfbc105f620becc63..8d688f77e9cde2eb1f3a742dfbc105f620becc63
@@@ -2,6 -2,7 +2,7 @@@
  
  Before:
    source ../after/ftplugin/markdown.vim
+   setlocal foldtext=foldtext()
  
  After:
    setlocal foldexpr=0
@@@ -120,28 -121,28 +121,28 @@@ Execute (check TOC)
    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;
  ---
@@@ -174,5 -175,5 +175,5 @@@ Execute (check Toc of yaml front matter
    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
index 0000000000000000000000000000000000000000,4fa58ef64a9f09b12cbe75a193db0aaacd321da7..4fa58ef64a9f09b12cbe75a193db0aaacd321da7
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,116 +1,116 @@@
+ 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
index 0000000000000000000000000000000000000000,b8d669bc6335f14f8e47a43b31fe4d5d1b76058e..b8d669bc6335f14f8e47a43b31fe4d5d1b76058e
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,147 +1,147 @@@
+ 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
index 7ecdfad188da56b79695f9cf04583ef8f2506aa7,57fe6190256518872b102045a75f32d34468b7d9..57fe6190256518872b102045a75f32d34468b7d9
@@@ -146,8 -146,8 +146,8 @@@ Given markdown
  
  b
  
- Execute (]c):
+ Execute (]h):
    normal! 3G
    AssertEqual line('.'), 3
-   normal ]c
+   normal ]h
    AssertEqual line('.'), 1
index 0000000000000000000000000000000000000000,a27938fa28114ffe3718f522ef9dc6b7f34563af..a27938fa28114ffe3718f522ef9dc6b7f34563af
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,48 +1,48 @@@
+ 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
+   -
index 0000000000000000000000000000000000000000,4fe392abf76effe49c81b7bbd5c17565d6a0257d..4fe392abf76effe49c81b7bbd5c17565d6a0257d
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,41 +1,41 @@@
+ 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'
index 33f5500e88716e4e6d7afac4232ca19817e9c5f3,9c89e3f61dcdc1190f6020f9577463c72dad4743..9c89e3f61dcdc1190f6020f9577463c72dad4743
@@@ -31,7 -31,7 +31,7 @@@ en
  [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:
  
index 5ce94fc2ee99e2f24f9c2c8b4ac0bd6d6463231b,b111de0d347bbf422df65a06c1e76733c90e4086..b111de0d347bbf422df65a06c1e76733c90e4086
@@@ -2,6 -2,7 +2,7 @@@ Before
    unlet! b:mkd_known_filetypes
    unlet! b:mkd_included_filetypes
    unlet! g:vim_markdown_math
+   unlet! b:liquid_subtype
  
  Given markdown;
  a **b** c
@@@ -634,7 -635,8 +635,8 @@@ Given markdown
  
  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
@@@ -738,12 -740,18 +740,18 @@@ def 
  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;
@@@ -957,12 -976,12 +976,12 @@@ $$ \frac{a}{b} $
  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
@@@ -985,7 -1004,7 +1004,7 @@@ Execute (math ends with $$)
    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
@@@ -1282,3 -1302,227 +1302,227 @@@ Execute (HTML tag in text)
    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'
index 2fc06a394b70f4102341d1faa88aff9ab010680b,f7028cb0a81f840c50c0a080341af35980c207c4..f7028cb0a81f840c50c0a080341af35980c207c4
@@@ -30,6 -30,19 +30,19 @@@ Expect (table is not modified)
    |---|---|
    | 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  ||
  | :- | --: |:---:|:|
@@@ -42,3 -55,31 +55,31 @@@ Expect (preserve colons to align text)
    | 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 |
index 638ab3f76be5ab9347e16d327099f2269e7c737f,84a85b09769a18988799e4a677c6f0dea52f44ae..84a85b09769a18988799e4a677c6f0dea52f44ae
@@@ -1,16 -1,17 +1,17 @@@
  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 = ''
@@@ -24,6 -25,7 +25,7 @@@
          endif
      endfor
  endfunction
  function! Markdown_GetFunc(fname, funcname) abort
      return function('<SNR>' . Markdown_GetScriptID(a:fname) . '_' . a:funcname)
  endfunction