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)
let tag_count = 1
while 1
let tag_text = matchstr(line, rxtag, 0, tag_count)
if tag_text == ''
let tag_group_text = matchstr(line, rxtag, 0, tag_count)
if tag_group_text == ''
break
endif
call add(anchors, tag_text)
if current_complete_anchor != ''
call add(anchors, current_complete_anchor.'#'.tag_text)
endif
for tag_text in split(tag_group_text, ':')
call add(anchors, tag_text)
if current_complete_anchor != ''
call add(anchors, current_complete_anchor.'#'.tag_text)
endif
endfor
let tag_count += 1
endwhile
@ -2047,26 +2049,28 @@ function! vimwiki#base#scan_tags(lines, page_name) "{{{
" Scan line for tags. There can be many of them.
let str = line
while 1
let tag = matchstr(str, rxtag)
if tag == ''
let tag_group = matchstr(str, rxtag)
if tag_group == ''
break
endif
let tagend = matchend(str, rxtag)
let str = str[(tagend):]
" Create metadata entry
let entry = {}
let entry.tagname = tag
let entry.pagename = page_name
let entry.lineno = line_nr
if line_nr <= (header_line_nr + PROXIMITY_LINES_NR)
let entry.link = page_name . '#' . current_complete_anchor
elseif header_line_nr < 0
" Tag appeared before the first header
let entry.link = page_name
else
let entry.link = page_name . '#' . tag
endif
call add(metadata, entry)
for tag in split(tag_group, ':')
" Create metadata entry
let entry = {}
let entry.tagname = tag
let entry.pagename = page_name
let entry.lineno = line_nr
if line_nr <= (header_line_nr + PROXIMITY_LINES_NR)
let entry.link = page_name . '#' . current_complete_anchor
elseif header_line_nr < 0
" Tag appeared before the first header
let entry.link = page_name
else
let entry.link = page_name . '#' . tag
endif
call add(metadata, entry)
endfor
endwhile
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_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'
let g:vimwiki_default_tag_search = ':\zs[^:[:space:]]\+\ze:'
let g:vimwiki_default_tag_match = ':__Tag__:'
let g:vimwiki_default_tag_search = '\(^\|\s\)\zs:\([^:[:space:]]\+:\)\+\ze\(\s\|$\)'
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_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'

View File

@ -95,4 +95,5 @@ let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
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