Modify patterns and code -- tag colons must be either at line boundary, or surrounded with white spaces

This commit is contained in:
Ivan Tishchenko 2015-01-23 23:13:27 +03:00
parent b912e4e3c7
commit 17cfd6e613
3 changed files with 30 additions and 25 deletions

View File

@ -668,14 +668,16 @@ function! vimwiki#base#get_anchors(filename, syntax) "{{{
" collect tags text (there can be several in one line) " collect tags text (there can be several in one line)
let tag_count = 1 let tag_count = 1
while 1 while 1
let tag_text = matchstr(line, rxtag, 0, tag_count) let tag_group_text = matchstr(line, rxtag, 0, tag_count)
if tag_text == '' if tag_group_text == ''
break break
endif endif
for tag_text in split(tag_group_text, ':')
call add(anchors, tag_text) call add(anchors, tag_text)
if current_complete_anchor != '' if current_complete_anchor != ''
call add(anchors, current_complete_anchor.'#'.tag_text) call add(anchors, current_complete_anchor.'#'.tag_text)
endif endif
endfor
let tag_count += 1 let tag_count += 1
endwhile endwhile
@ -2047,12 +2049,13 @@ function! vimwiki#base#scan_tags(lines, page_name) "{{{
" Scan line for tags. There can be many of them. " Scan line for tags. There can be many of them.
let str = line let str = line
while 1 while 1
let tag = matchstr(str, rxtag) let tag_group = matchstr(str, rxtag)
if tag == '' if tag_group == ''
break break
endif endif
let tagend = matchend(str, rxtag) let tagend = matchend(str, rxtag)
let str = str[(tagend):] let str = str[(tagend):]
for tag in split(tag_group, ':')
" Create metadata entry " Create metadata entry
let entry = {} let entry = {}
let entry.tagname = tag let entry.tagname = tag
@ -2067,6 +2070,7 @@ function! vimwiki#base#scan_tags(lines, page_name) "{{{
let entry.link = page_name . '#' . tag let entry.link = page_name . '#' . tag
endif endif
call add(metadata, entry) call add(metadata, entry)
endfor
endwhile endwhile
endfor " loop over lines endfor " loop over lines

View File

@ -14,8 +14,8 @@ let g:vimwiki_default_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\
let g:vimwiki_default_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@=' let g:vimwiki_default_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_default_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@=' let g:vimwiki_default_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]' let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
let g:vimwiki_default_tag_search = ':\zs[^:[:space:]]\+\ze:' let g:vimwiki_default_tag_search = '\(^\|\s\)\zs:\([^:[:space:]]\+:\)\+\ze\(\s\|$\)'
let g:vimwiki_default_tag_match = ':__Tag__:' let g:vimwiki_default_tag_match = '\(^\|\s\):\([^:[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)'
let g:vimwiki_markdown_header_search = '^\s*\(#\{1,6}\)\([^#].*\)$' let g:vimwiki_markdown_header_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
let g:vimwiki_markdown_header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$' let g:vimwiki_markdown_header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'

View File

@ -95,4 +95,5 @@ let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$' let g:vimwiki_rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$' let g:vimwiki_rxComment = '^\s*%%.*$'
let g:vimwiki_rxTags = ':\([^:[:space:]]\+:\)\+' let g:vimwiki_rxTags = '\(^\|\s\)\zs:\([^:[:space:]]\+:\)\+\ze\(\s\|$\)'
" see also g:vimwiki_default_tag_search