Fix: clean_url removing Chinese character
Issue: <Enter> create link bug with Chinese characters #849 Thank: @BSDxxxx
This commit is contained in:
parent
39812e5c96
commit
1852c6c542
@ -2119,6 +2119,7 @@ function! s:clean_url(url) abort
|
|||||||
let url = substitute(a:url, '\'.vimwiki#vars#get_wikilocal('ext').'$', '', '')
|
let url = substitute(a:url, '\'.vimwiki#vars#get_wikilocal('ext').'$', '', '')
|
||||||
" remove protocol and tld
|
" remove protocol and tld
|
||||||
let url = substitute(url, '^\a\+\d*:', '', '')
|
let url = substitute(url, '^\a\+\d*:', '', '')
|
||||||
|
" remove absolute path prefix
|
||||||
let url = substitute(url, '^//', '', '')
|
let url = substitute(url, '^//', '', '')
|
||||||
let url = substitute(url, '^\([^/]\+\)\.\a\{2,4}/', '\1/', '')
|
let url = substitute(url, '^\([^/]\+\)\.\a\{2,4}/', '\1/', '')
|
||||||
let url_l = split(url, '/\|=\|-\|&\|?\|\.')
|
let url_l = split(url, '/\|=\|-\|&\|?\|\.')
|
||||||
@ -2129,8 +2130,10 @@ function! s:clean_url(url) abort
|
|||||||
if url_l[-1] =~# '^\(htm\|html\|php\)$'
|
if url_l[-1] =~# '^\(htm\|html\|php\)$'
|
||||||
let url_l = url_l[0:-2]
|
let url_l = url_l[0:-2]
|
||||||
endif
|
endif
|
||||||
" remove words consisting of only hexadecimal digits or non-word characters
|
" remove words with black listed codepoints
|
||||||
let url_l = filter(url_l, 'v:val !~? "^\\A\\{4,}$"')
|
" TODO mutualize blacklist in a variable
|
||||||
|
let url_l = filter(url_l, 'v:val !~? "[!\"$%&''()*+,:;<=>?\[\]\\^`{}]"')
|
||||||
|
" remove words consisting of only hexadecimal digits
|
||||||
let url_l = filter(url_l, 'v:val !~? "^\\x\\{4,}$" || v:val !~? "\\d"')
|
let url_l = filter(url_l, 'v:val !~? "^\\x\\{4,}$" || v:val !~? "\\d"')
|
||||||
return join(url_l, ' ')
|
return join(url_l, ' ')
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -86,6 +86,7 @@ function! s:populate_global_variables() abort
|
|||||||
" buffer (and not on a link) to create a link
|
" buffer (and not on a link) to create a link
|
||||||
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
|
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
|
||||||
" non-Ascii characters, except that . is not accepted as the last character
|
" non-Ascii characters, except that . is not accepted as the last character
|
||||||
|
" TODO look behind for . reduces the second part of the regex that is the same with '.' added
|
||||||
let g:vimwiki_global_vars.rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]*[^[:blank:]!"$%&''()*+.,:;<=>?\[\]\\^`{}]'
|
let g:vimwiki_global_vars.rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]*[^[:blank:]!"$%&''()*+.,:;<=>?\[\]\\^`{}]'
|
||||||
|
|
||||||
let g:vimwiki_global_vars.rx_wikilink_prefix1 = g:vimwiki_global_vars.rx_wikilink_prefix .
|
let g:vimwiki_global_vars.rx_wikilink_prefix1 = g:vimwiki_global_vars.rx_wikilink_prefix .
|
||||||
|
Loading…
Reference in New Issue
Block a user