commit 17cfd6e61366be08578781f167a781437f7393c9
parent b912e4e3c702f3ce617e54b846c13e1754e55d5d
Author: Ivan Tishchenko <ivan.tishchenko@dsr-company.con>
Date: Fri, 23 Jan 2015 23:13:27 +0300
Modify patterns and code -- tag colons must be either at line boundary, or surrounded with white spaces
Diffstat:
3 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
@@ -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
diff --git a/syntax/omnipresent_syntax.vim b/syntax/omnipresent_syntax.vim
@@ -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*$'
diff --git a/syntax/vimwiki_default.vim b/syntax/vimwiki_default.vim
@@ -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