process links of the form [[#anchor]] correctly
when typing :VimwikiAll2HTML
This commit is contained in:
parent
1b6b50a3b7
commit
502212b58d
@ -328,10 +328,6 @@ endfunction " }}}
|
||||
function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme
|
||||
let lnk = a:lnk
|
||||
|
||||
" a link starting with # means current file with an anchor
|
||||
if lnk =~ '^#'
|
||||
let lnk = expand('%:t:r').lnk
|
||||
endif
|
||||
|
||||
" if link is schemeless add wikiN: scheme
|
||||
let is_schemeless = lnk !~ g:vimwiki_rxSchemeUrl
|
||||
@ -458,6 +454,14 @@ function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme
|
||||
let url = path.subdir.lnk.ext
|
||||
endif
|
||||
|
||||
" lnk and url should be '' if the given wiki link has the form [[#anchor]].
|
||||
" We cannot do lnk = expand('%:t:r') or so, because this function is called
|
||||
" from vimwiki#html#WikiAll2HTML() for many files, so expand('%:t:r')
|
||||
" doesn't give the currently processed file
|
||||
if lnk == ''
|
||||
let url = ''
|
||||
endif
|
||||
|
||||
" result
|
||||
return [idx, scheme, path, subdir, lnk, ext, url, anchor]
|
||||
endfunction "}}}
|
||||
@ -506,7 +510,7 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
let [idx, scheme, path, subdir, lnk, ext, url, anchor] =
|
||||
\ vimwiki#base#resolve_scheme(a:link, 0)
|
||||
|
||||
if url == ''
|
||||
if path == ''
|
||||
if g:vimwiki_debug
|
||||
echom 'open_link: idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.', url='.url.', anchor='.anchor
|
||||
endif
|
||||
@ -514,6 +518,11 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
return
|
||||
endif
|
||||
|
||||
if url == ''
|
||||
let lnk = expand('%:t:r')
|
||||
let url = path.subdir.lnk.ext
|
||||
endif
|
||||
|
||||
let update_prev_link = ( (scheme == '' || scheme =~ 'wiki' || scheme =~ 'diary')
|
||||
\ && lnk != expand('%:t:r')
|
||||
\ ? 1 : 0)
|
||||
|
@ -390,7 +390,6 @@ function! s:tag_wikiincl(value) "{{{
|
||||
|
||||
let url = escape(url, '#')
|
||||
let line = vimwiki#html#linkify_image(url, descr, verbatim_str)
|
||||
return line
|
||||
endif
|
||||
return line
|
||||
endfunction "}}}
|
||||
@ -402,7 +401,7 @@ function! s:tag_wikilink(value) "{{{
|
||||
" [[fileurl.ext|descr]] -> <a href="fileurl.ext">descr</a>
|
||||
" [[dirurl/|descr]] -> <a href="dirurl/index.html">descr</a>
|
||||
" [[url#a1#a2]] -> <a href="url.html#a1-a2">url#a1#a2</a>
|
||||
" [[#a1#a2]] -> <a href="file.html#a1-a2">#a1#a2</a>
|
||||
" [[#a1#a2]] -> <a href="#a1-a2">#a1#a2</a>
|
||||
let str = a:value
|
||||
let url = matchstr(str, g:vimwiki_rxWikiLinkMatchUrl)
|
||||
let descr = matchstr(str, g:vimwiki_rxWikiLinkMatchDescr)
|
||||
|
@ -2242,7 +2242,7 @@ similar to 'local:' and 'file:' schemes, but are always opened with Vim: >
|
||||
\ ', subdir='.subdir.', lnk='.lnk.', ext='.ext.', url='.url.
|
||||
\ ', anchor='.anchor
|
||||
endif
|
||||
if url == ''
|
||||
if path == ''
|
||||
echom 'Vimwiki Error: Unable to resolve link!'
|
||||
return 0
|
||||
else
|
||||
|
@ -100,7 +100,8 @@ function! Complete_wikifiles(findstart, base)
|
||||
" we look for anchors in the given wikifile
|
||||
|
||||
let segments = split(a:base, '#', 1)
|
||||
let link_infos = vimwiki#base#resolve_scheme(segments[0].'#', 0)
|
||||
let given_wikifile = segments[0]=='' ? expand('%:t:r') : segments[0]
|
||||
let link_infos = vimwiki#base#resolve_scheme(given_wikifile.'#', 0)
|
||||
let wikifile = link_infos[6]
|
||||
let syntax = VimwikiGet('syntax', link_infos[0])
|
||||
let anchors = vimwiki#base#get_anchors(wikifile, syntax)
|
||||
|
Loading…
Reference in New Issue
Block a user