fix duplicate tag issue #1326
This commit is contained in:
+27
-31
@@ -123,38 +123,34 @@ function! s:scan_tags(lines, page_name) abort
|
|||||||
|
|
||||||
" 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
|
" Get all matches
|
||||||
" Get all matches
|
let tag_groups = []
|
||||||
let tag_groups = []
|
call substitute(str, tag_search_rx, '\=add(tag_groups, submatch(0))', 'g')
|
||||||
call substitute(str, tag_search_rx, '\=add(tag_groups, submatch(0))', 'g')
|
if tag_groups == []
|
||||||
if tag_groups == []
|
continue
|
||||||
break
|
endif
|
||||||
endif
|
for tag_group in tag_groups
|
||||||
let tagend = matchend(str, tag_search_rx)
|
for tag in split(tag_group, tag_format.sep)
|
||||||
let str = str[(tagend):]
|
" Create metadata entry
|
||||||
for tag_group in tag_groups
|
let entry = {}
|
||||||
for tag in split(tag_group, tag_format.sep)
|
let entry.tagname = tag
|
||||||
" Create metadata entry
|
let entry.lineno = line_nr
|
||||||
let entry = {}
|
if line_nr <= PROXIMITY_LINES_NR && header_line_nr < 0
|
||||||
let entry.tagname = tag
|
" Tag appeared at the top of the file
|
||||||
let entry.lineno = line_nr
|
let entry.link = a:page_name
|
||||||
if line_nr <= PROXIMITY_LINES_NR && header_line_nr < 0
|
let entry.description = entry.link
|
||||||
" Tag appeared at the top of the file
|
elseif line_nr <= (header_line_nr + PROXIMITY_LINES_NR)
|
||||||
let entry.link = a:page_name
|
" Tag appeared right below a header
|
||||||
let entry.description = entry.link
|
let entry.link = a:page_name . '#' . current_complete_anchor
|
||||||
elseif line_nr <= (header_line_nr + PROXIMITY_LINES_NR)
|
let entry.description = current_header_description
|
||||||
" Tag appeared right below a header
|
else
|
||||||
let entry.link = a:page_name . '#' . current_complete_anchor
|
" Tag stands on its own
|
||||||
let entry.description = current_header_description
|
let entry.link = a:page_name . '#' . tag
|
||||||
else
|
let entry.description = entry.link
|
||||||
" Tag stands on its own
|
endif
|
||||||
let entry.link = a:page_name . '#' . tag
|
call add(entries, entry)
|
||||||
let entry.description = entry.link
|
|
||||||
endif
|
|
||||||
call add(entries, entry)
|
|
||||||
endfor
|
|
||||||
endfor
|
endfor
|
||||||
endwhile
|
endfor
|
||||||
|
|
||||||
endfor " loop over lines
|
endfor " loop over lines
|
||||||
return entries
|
return entries
|
||||||
|
|||||||
Reference in New Issue
Block a user