Skip to content

Commit

Permalink
feat: use url_encode for bibdesk
Browse files Browse the repository at this point in the history
refer: #2908
  • Loading branch information
lervag committed Apr 29, 2024
1 parent 022a130 commit 23cf764
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autoload/vimtex/context/cite.vim
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ endfunction

" }}}1
function! s:actions.open_bdsk() abort dict " {{{1
call vimtex#util#www('x-bdsk://' .. self.entry.key)
call vimtex#util#www('x-bdsk://' .. vimtex#util#url_encode(self.entry.key))
endfunction

" }}}1
12 changes: 12 additions & 0 deletions autoload/vimtex/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,18 @@ function! vimtex#util#undostore() abort " {{{1
endif
endfunction

" }}}1
function! vimtex#util#url_encode(str) abort " {{{1
" This code is based on Tip Pope's vim-unimpaired:
" https://github.com/tpope/vim-unimpaired
return substitute(
\ iconv(a:str, 'latin1', 'utf-8'),
\ '[^A-Za-z0-9_.~-]',
\ '\="%".printf("%02X",char2nr(submatch(0)))',
\ 'g'
\)
endfunction

" }}}1
function! vimtex#util#www(url) abort " {{{1
let l:cmd = get(#{
Expand Down

0 comments on commit 23cf764

Please sign in to comment.