Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for tables without borders #643

Merged
merged 7 commits into from
Nov 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add vim_markdown_borderless_table flag
if is set to 1 we try to transform the borderless table to normal one
  • Loading branch information
gko committed Nov 1, 2023
commit ba1c49cdbb92d61a57d650c32303bcaa9ca433da
16 changes: 10 additions & 6 deletions ftplugin/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,17 @@ endfunction
function! s:TableFormat()
let l:pos = getpos('.')

normal! {
call search('|')
execute 'silent .,''}s/\v^(\s{0,})\|?([^\|])/\1|\2/e'
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'

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.
Expand Down