From 3ac8e1ae14bbdfaf4bc9dd9a76e84faef7625792 Mon Sep 17 00:00:00 2001 From: Brennen Bearnes Date: Mon, 18 Jul 2022 17:44:04 -0600 Subject: [PATCH] fixed s:get_links so that it finds both link styles when using markdown syntax --- autoload/vimwiki/base.vim | 14 ++++++++++---- doc/vimwiki.txt | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 2093751..0cce6cf 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -947,10 +947,10 @@ function! s:get_links(wikifile, idx) abort endif let syntax = vimwiki#vars#get_wikilocal('syntax', a:idx) + let rx_link = vimwiki#vars#get_syntaxlocal('wikilink', syntax) + if syntax ==# 'markdown' - let rx_link = vimwiki#vars#get_syntaxlocal('rxWeblink1MatchUrl', syntax) - else - let rx_link = vimwiki#vars#get_syntaxlocal('wikilink', syntax) + let md_rx_link = vimwiki#vars#get_syntaxlocal('rxWeblink1MatchUrl', syntax) endif let links = [] @@ -963,9 +963,15 @@ function! s:get_links(wikifile, idx) abort while 1 let col = match(line, rx_link, 0, link_count)+1 let link_text = matchstr(line, rx_link, 0, link_count) + + " if a link wasn't found, also try markdown syntax (if enabled) + if link_text ==? '' && syntax ==# 'markdown' + let link_text = matchstr(line, md_rx_link, 0, link_count) + endif if link_text ==? '' break endif + let link_count += 1 let target = vimwiki#base#resolve_link(link_text, a:wikifile) if target.filename !=? '' && target.scheme =~# '\mwiki\d\+\|diary\|file\|local' @@ -1523,7 +1529,7 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header, " them right back. let foldenable_save = &l:foldenable setlocal nofoldenable - + " Clause: don't update file if there are no changes if (join(getline(start_lnum + 2, end_lnum - 1), '') == join(a_list, '')) return diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 2f3836f..d8307d8 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -3973,6 +3973,7 @@ Contributors and their Github usernames in roughly chronological order: - Jean-Luc Bastarache (@jlbas) - Youssof Taha (@ysftaha) - Thomas Leyh (@leyhline) + - nebulaeandstars (@nebulaeandstars) ============================================================================== 16. Changelog *vimwiki-changelog* @@ -4046,6 +4047,7 @@ Changed:~ Removed:~ Fixed:~ + * PR #1245 / issue #1244: Fix VimwikiBacklinks handling of bracketed links * Issue #1193: Fix wildcard expansion in |find_autoload_file| * PR #1108: Fix resolution of leading-slash page links, add link tests * Allow title values with quotes