Fix wrong creation of links caused by previous commit

This commit is contained in:
EinfachToll 2014-06-22 16:26:40 +02:00
parent 4a04fc7519
commit aa32fc2ba5
2 changed files with 117 additions and 92 deletions

View File

@ -51,28 +51,32 @@ let s:time0 = vimwiki#u#time(g:starttime) "XXX
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink regexps {{{
let g:vimwiki_rxWikiLinkPrefix = '\[\['
let g:vimwiki_rxWikiLinkSuffix = '\]\]'
let g:vimwiki_rxWikiLinkSeparator = '|'
" [[URL]]
let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSuffix
" [[URL|DESCRIPTION]]
let g:vimwiki_WikiLinkTemplate2 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSeparator. '__LinkDescription__'.
\ g:vimwiki_rxWikiLinkSuffix
let s:wikilink_prefix = '[['
let s:wikilink_suffix = ']]'
let s:wikilink_separator = '|'
let s:rx_wikilink_prefix = vimwiki#u#escape(s:wikilink_prefix)
let s:rx_wikilink_suffix = vimwiki#u#escape(s:wikilink_suffix)
let s:rx_wikilink_separator = vimwiki#u#escape(s:wikilink_separator)
" match every Wikilink with a given URL
" templates for the creation of wiki links
" [[URL]]
let g:vimwiki_WikiLinkTemplate1 = s:wikilink_prefix . '__LinkUrl__'.
\ s:wikilink_suffix
" [[URL|DESCRIPTION]]
let g:vimwiki_WikiLinkTemplate2 = s:wikilink_prefix . '__LinkUrl__'.
\ s:wikilink_separator . '__LinkDescription__' . s:wikilink_suffix
" template for matching all wiki links with a given target file
let g:vimwiki_WikiLinkMatchUrlTemplate =
\ g:vimwiki_rxWikiLinkPrefix .
\ s:rx_wikilink_prefix .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ g:vimwiki_rxWikiLinkSuffix .
\ s:rx_wikilink_suffix .
\ '\|' .
\ g:vimwiki_rxWikiLinkPrefix .
\ s:rx_wikilink_prefix .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ g:vimwiki_rxWikiLinkSeparator .
\ s:rx_wikilink_separator .
\ '.*' .
\ g:vimwiki_rxWikiLinkSuffix
\ s:rx_wikilink_suffix
let s:valid_chars = '[^\\\]]'
let g:vimwiki_rxWikiLinkUrl = s:valid_chars.'\{-}'
@ -80,26 +84,26 @@ let g:vimwiki_rxWikiLinkDescr = s:valid_chars.'\{-}'
let g:vimwiki_rxWord = '[^[:blank:]()\\]\+'
"
" [[URL]], or [[URL|DESCRIPTION]]
" a) match [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.'\%('.g:vimwiki_rxWikiLinkSeparator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
let g:vimwiki_rxWikiLink = s:rx_wikilink_prefix.
\ g:vimwiki_rxWikiLinkUrl.'\%('.s:rx_wikilink_separator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.s:rx_wikilink_suffix
" b) match URL within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLinkMatchUrl = g:vimwiki_rxWikiLinkPrefix.
\ '\zs'. g:vimwiki_rxWikiLinkUrl.'\ze\%('. g:vimwiki_rxWikiLinkSeparator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
let g:vimwiki_rxWikiLinkMatchUrl = s:rx_wikilink_prefix.
\ '\zs'. g:vimwiki_rxWikiLinkUrl.'\ze\%('. s:rx_wikilink_separator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.s:rx_wikilink_suffix
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLinkMatchDescr = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator.'\%('.
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. g:vimwiki_rxWikiLinkSuffix
let g:vimwiki_rxWikiLinkMatchDescr = s:rx_wikilink_prefix.
\ g:vimwiki_rxWikiLinkUrl.s:rx_wikilink_separator.'\%('.
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. s:rx_wikilink_suffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLinkPrefix1 = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator
let g:vimwiki_rxWikiLinkSuffix1 = g:vimwiki_rxWikiLinkSuffix
let s:rx_wikilink_prefix1 = s:rx_wikilink_prefix . g:vimwiki_rxWikiLinkUrl .
\ s:rx_wikilink_separator
let s:rx_wikilink_suffix1 = s:rx_wikilink_suffix
" }}}
@ -201,28 +205,34 @@ function! s:highlight_existing_links() "{{{
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
" match [[URL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL|...}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
endfunction "}}}
@ -259,20 +269,24 @@ let s:rxSchemes = '\%('.
\ '\):'
" a) match [[nonwiki-scheme-URL]]
let s:target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate1),
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
let s:target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLinkTemplate2),
\ s:rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" a) match {{nonwiki-scheme-URL}}
let s:target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate1),
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
" b) match {{nonwiki-scheme-URL}[{...}]}
let s:target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiInclTemplate2),
\ s:rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(s:target, 'VimwikiLink')
@ -325,10 +339,10 @@ execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'.s:
" concealed link parts " {{{
if g:vimwiki_debug > 1
echom 'WikiLink Prefix: '.g:vimwiki_rxWikiLinkPrefix
echom 'WikiLink Suffix: '.g:vimwiki_rxWikiLinkSuffix
echom 'WikiLink Prefix1: '.g:vimwiki_rxWikiLinkPrefix1
echom 'WikiLink Suffix1: '.g:vimwiki_rxWikiLinkSuffix1
echom 'WikiLink Prefix: '.s:rx_wikilink_prefix
echom 'WikiLink Suffix: '.s:rx_wikilink_suffix
echom 'WikiLink Prefix1: '.s:rx_wikilink_prefix1
echom 'WikiLink Suffix1: '.s:rx_wikilink_suffix1
echom 'WikiIncl Prefix: '.g:vimwiki_rxWikiInclPrefix1
echom 'WikiIncl Suffix: '.g:vimwiki_rxWikiInclSuffix1
endif
@ -350,10 +364,10 @@ endif
" is present) and may be concealed
" conceal wikilinks
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix.'/'.s:options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix.'/'.s:options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix1.'/'.s:options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix1.'/'.s:options
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_prefix.'/'.s:options
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_suffix.'/'.s:options
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_prefix1.'/'.s:options
execute 'syn match VimwikiLinkChar /'.s:rx_wikilink_suffix1.'/'.s:options
" conceal wikiincls
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.s:options

View File

@ -30,30 +30,33 @@ let g:vimwiki_rxWikiLink0MatchDescr = g:vimwiki_rxWikiLinkMatchDescr
" LINKS: setup wikilink1 regexps {{{
" 1. [URL][], or [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1Prefix = '\['
let g:vimwiki_rxWikiLink1Suffix = '\]'
let g:vimwiki_rxWikiLink1Separator = '\]\['
let s:wikilink_md_prefix = '['
let s:wikilink_md_suffix = ']'
let s:wikilink_md_separator = ']['
let s:rx_wikilink_md_prefix = vimwiki#u#escape(s:wikilink_md_prefix)
let s:rx_wikilink_md_suffix = vimwiki#u#escape(s:wikilink_md_suffix)
let s:rx_wikilink_md_separator = vimwiki#u#escape(s:wikilink_md_separator)
" [URL][]
let g:vimwiki_WikiLink1Template1 = g:vimwiki_rxWikiLink1Prefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Separator. g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_WikiLink1Template1 = s:wikilink_md_prefix . '__LinkUrl__'.
\ s:wikilink_md_separator. s:wikilink_md_suffix
" [DESCRIPTION][URL]
let g:vimwiki_WikiLink1Template2 = g:vimwiki_rxWikiLink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWikiLink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_WikiLink1Template2 = s:wikilink_md_prefix. '__LinkDescription__'.
\ s:wikilink_md_separator. '__LinkUrl__'.
\ s:wikilink_md_suffix
"
let g:vimwiki_WikiLinkMatchUrlTemplate .=
\ '\|' .
\ g:vimwiki_rxWikiLink1Prefix .
\ s:rx_wikilink_md_prefix .
\ '.*' .
\ g:vimwiki_rxWikiLink1Separator .
\ s:rx_wikilink_md_separator .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ g:vimwiki_rxWikiLink1Suffix .
\ s:rx_wikilink_md_suffix .
\ '\|' .
\ g:vimwiki_rxWikiLink1Prefix .
\ s:rx_wikilink_md_prefix .
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
\ g:vimwiki_rxWikiLink1Separator .
\ g:vimwiki_rxWikiLink1Suffix
\ s:rx_wikilink_md_separator .
\ s:rx_wikilink_md_suffix
let s:valid_chars = '[^\\\[\]]'
let g:vimwiki_rxWikiLink1Url = s:valid_chars.'\{-}'
@ -61,37 +64,37 @@ let g:vimwiki_rxWikiLink1Descr = s:valid_chars.'\{-}'
let g:vimwiki_rxWikiLink1InvalidPrefix = '[\]\[]\@<!'
let g:vimwiki_rxWikiLink1InvalidSuffix = '[\]\[]\@!'
let g:vimwiki_rxWikiLink1Prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
\ g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix = g:vimwiki_rxWikiLink1Suffix.
let s:rx_wikilink_md_prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
\ s:rx_wikilink_md_prefix
let s:rx_wikilink_md_suffix = s:rx_wikilink_md_suffix.
\ g:vimwiki_rxWikiLink1InvalidSuffix
"
" 1. [URL][], [DESCRIPTION][URL]
" 1a) match [URL][], [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1 = g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Url. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Suffix.
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Descr.g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_rxWikiLink1 = s:rx_wikilink_md_prefix.
\ g:vimwiki_rxWikiLink1Url. s:rx_wikilink_md_separator.
\ s:rx_wikilink_md_suffix.
\ '\|'. s:rx_wikilink_md_prefix.
\ g:vimwiki_rxWikiLink1Descr.s:rx_wikilink_md_separator.
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
" 1b) match URL within [URL][], [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1MatchUrl = g:vimwiki_rxWikiLink1Prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Suffix.
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Descr. g:vimwiki_rxWikiLink1Separator.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_rxWikiLink1MatchUrl = s:rx_wikilink_md_prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. s:rx_wikilink_md_separator.
\ s:rx_wikilink_md_suffix.
\ '\|'. s:rx_wikilink_md_prefix.
\ g:vimwiki_rxWikiLink1Descr. s:rx_wikilink_md_separator.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. s:rx_wikilink_md_suffix
" 1c) match DESCRIPTION within [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1MatchDescr = g:vimwiki_rxWikiLink1Prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Descr.'\ze'. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_rxWikiLink1MatchDescr = s:rx_wikilink_md_prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Descr.'\ze'. s:rx_wikilink_md_separator.
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLink1Prefix1 = g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix1 = g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
let g:vimwiki_rxWikiLink1Prefix1 = s:rx_wikilink_md_prefix
let g:vimwiki_rxWikiLink1Suffix1 = s:rx_wikilink_md_separator.
\ g:vimwiki_rxWikiLink1Url.s:rx_wikilink_md_suffix
" }}}
" *. ANY wikilink {{{
@ -247,29 +250,35 @@ function! s:highlight_existing_links() "{{{
" match [URL][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DIRURL][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][DIRURL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [MKDREF][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][MKDREF]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
let target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
endfunction "}}}
@ -302,11 +311,13 @@ let s:rxSchemes = '\%('.
\ '\):'
" a) match [nonwiki-scheme-URL]
let s:target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template1),
\ s:rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
" b) match [DESCRIPTION][nonwiki-scheme-URL]
let s:target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(g:vimwiki_WikiLink1Template2),
\ s:rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1')
" }}}
@ -339,8 +350,8 @@ endif
" is present) and may be concealed
let s:options = ' contained transparent contains=NONE'
" conceal wikilink1
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix.'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix.'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.s:rx_wikilink_md_prefix.'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.s:rx_wikilink_md_suffix.'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix1.'/'.s:options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix1.'/'.s:options