From: deris0126 Date: Sat, 14 Jun 2014 08:47:13 +0000 (+0900) Subject: Fix indent after list items X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/9f93f60f520ce3d4013cf1fb1eaafe541f92dfb9 Fix indent after list items 1. Fix not only *+- but also \ matched Need not escape inside [] because backslash codes do not work inside []. So pattern [\*+-] match also \. 2. Fix not only list but also horizontal are indented If only space and three '*' or '-' character are in the line, this line means horizontal item. If current line is below horizontal item, it need not to indent. Following example is horizontal item. --- *** - - - * * * And list item must be specified space after [*-+]. Following example is list item. * foo - bar + baz But following example is not list item. *foo -bar +baz Add indent test file for above bugs. Fix #90 --- diff --git a/indent/mkd.vim b/indent/mkd.vim index a26ac0e..21b8397 100755 --- a/indent/mkd.vim +++ b/indent/mkd.vim @@ -10,7 +10,8 @@ setlocal autoindent if exists("*GetMkdIndent") | finish | endif function! s:is_li_start(line) - return a:line =~ '^\s*[\*+-]' + return a:line !~ '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' && + \ a:line =~ '^\s*[*+-] \+' endfunction function! s:is_blank_line(line) diff --git a/test/indent.md b/test/indent.md new file mode 100644 index 0000000..6d250a1 --- /dev/null +++ b/test/indent.md @@ -0,0 +1,26 @@ +1. Confirm indent with new line insert after list items + +'\' is not list item. +\ foo + +If only space and three '*' or '-' character are in the line, +this line means horizontal item. +If current line is below horizontal item, it need not to indent. +Following example is horizontal item. + +--- +*** +- - - +* * * + +And list item must be specified space after [*-+]. +Following example is list item. + +* foo +- bar ++ baz + +But following example is not list item. +*foo +-bar ++baz