]> 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:

TableFormat does not remove colons for alignment
authorHiroshi Shirosaki <h.shirosaki@gmail.com>
Thu, 25 Feb 2016 01:44:41 +0000 (10:44 +0900)
committerHiroshi Shirosaki <h.shirosaki@gmail.com>
Thu, 25 Feb 2016 01:44:41 +0000 (10:44 +0900)
Fix #265, #220

ftplugin/markdown.vim
test/table-format.vader

index c7fba7fae6bdf275344714e9426a7ca5c3dd471d..71c67357ac1ed11c6409a8984c826e3565559cd9 100644 (file)
@@ -459,8 +459,11 @@ function! s:TableFormat()
     " Remove everything that is not a pipe othewise well formated tables would grow
     " because of addition of 2 spaces on the separator line by Tabularize /|.
     let l:flags = (&gdefault ? '' : 'g')
-    execute 's/[^|]//' . l:flags
+    execute 's/\(:\@<!-:\@!\|[^|:-]\)//e' . l:flags
+    execute 's/--/-/e' . l:flags
     Tabularize /|
+    execute 's/:\( \+\)|/\1:|/e' . l:flags
+    execute 's/|\( \+\):/|:\1/e' . l:flags
     execute 's/ /-/' . l:flags
     call setpos('.', l:pos)
 endfunction
index c29ab0345e922cbb7cce9e22511176a63b966af3..2fc06a394b70f4102341d1faa88aff9ab010680b 100644 (file)
@@ -29,3 +29,16 @@ Expect (table is not modified):
   | a | b |
   |---|---|
   | c | d |
+
+Given markdown;
+| left |right|  center  ||
+| :- | --: |:---:|:|
+| left |right|  center  ||
+
+Execute (format table with colons):
+  TableFormat
+
+Expect (preserve colons to align text):
+  | left | right | center |   |
+  |:-----|------:|:------:|:--|
+  | left | right | center |   |