From 23cf7649231bcd5c1f9a0c7cb3f7e7b8839f19d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Mon, 29 Apr 2024 15:23:33 +0200 Subject: [PATCH] feat: use url_encode for bibdesk refer: #2908 --- autoload/vimtex/context/cite.vim | 2 +- autoload/vimtex/util.vim | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/autoload/vimtex/context/cite.vim b/autoload/vimtex/context/cite.vim index 63a265d6d4..7be33114da 100644 --- a/autoload/vimtex/context/cite.vim +++ b/autoload/vimtex/context/cite.vim @@ -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 diff --git a/autoload/vimtex/util.vim b/autoload/vimtex/util.vim index ba4e544117..c258927339 100644 --- a/autoload/vimtex/util.vim +++ b/autoload/vimtex/util.vim @@ -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(#{