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
call add(anchors, tag_text) for tag_text in split(tag_group_text, ':')
if current_complete_anchor != '' call add(anchors, tag_text)
call add(anchors, current_complete_anchor.'#'.tag_text) if current_complete_anchor != ''
endif call add(anchors, current_complete_anchor.'#'.tag_text)
endif
endfor
let tag_count += 1 let tag_count += 1
endwhile endwhile
@ -2047,26 +2049,28 @@ 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):]
" Create metadata entry for tag in split(tag_group, ':')
let entry = {} " Create metadata entry
let entry.tagname = tag let entry = {}
let entry.pagename = page_name let entry.tagname = tag
let entry.lineno = line_nr let entry.pagename = page_name
if line_nr <= (header_line_nr + PROXIMITY_LINES_NR) let entry.lineno = line_nr
let entry.link = page_name . '#' . current_complete_anchor if line_nr <= (header_line_nr + PROXIMITY_LINES_NR)
elseif header_line_nr < 0 let entry.link = page_name . '#' . current_complete_anchor
" Tag appeared before the first header elseif header_line_nr < 0
let entry.link = page_name " Tag appeared before the first header
else let entry.link = page_name
let entry.link = page_name . '#' . tag else
endif let entry.link = page_name . '#' . tag
call add(metadata, entry) endif
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