Fix: VimwikiTOC is broken against headers with link (Issue #182)

Problem: VimwikiTOC and follow_link do not support header (anchor) with
link in their body

Solution:
- VimwikiTOC (easy): Create function base.vim s:clean_header_text that
converts [DESC](URL) -> DESC
- follow_link (hard):
-- [[URL]]: was already working due to punctuation removal.
-- [DESC](URL): Search for a potential `]([^)]*)` after every character
This commit is contained in:
Tinmarino
2020-08-05 22:26:05 -04:00
parent e4186adc3d
commit 69ead3bf3c
7 changed files with 160 additions and 24 deletions

View File

@ -1,6 +1,8 @@
# VimwikiTOC {{{1
#
# TODO implement: If link in the heading (see README.md)
# Just generate the TOC
# See: link_* for link movement and creation
#
# TODO (10min) test if g:vimwiki_to_header well readen
# TODO (10min) test vimviki_toc_link_format
# TODO (1h) test if really wiki dependant (for 2 diffrent wikis)
@ -28,6 +30,30 @@
#
# Start {{{1
Given vimwiki (With link header (#182) {{{1):
# A [link](anything here) B
# t[link](anything here)
## 7.4.1528
Execute (VimwikiTOC: Set syntax markdown && Set sw=8):
call SetSyntax('markdown')
set sw=8
VimwikiTOC
Expect vimwiki (With link header (#182) {{{1):
# Contents
- [A link B](#a-link-b)
- [tlink](#tlink)
- [7.4.1528](#741528)
# A [link](anything here) B
# t[link](anything here)
## 7.4.1528
Given vimwiki (Underline header (SetExt) (#209) {{{1):
First with spaces

View File

@ -1,7 +1,14 @@
# Link internal to a file
#
# See: generate_toc.vim
#
# See issue #666 for anchor support (then internal links)
# Preambule set file onces and for all {{{1
# Otherwise the bash script is freezing
Given vimwiki (a):
a
@ -11,6 +18,52 @@ Execute (Set filename wiki_test.md):
Expect (a):
a
Given vimwiki (VimwikiTOC is broken against headers with link #182 {{{1):
[A link B](#a-link-b)
[tlink](#tlink)
[7.4.1528](#741528)
[link (333)](#link-333)
# A [link](anything here) B
# t[link](anything here)
## 7.4.1528
#### [link]() (333)
Execute (VimwikiTOC: Set syntax markdown && Set sw=8):
call SetSyntax('markdown')
Do (Enter link):
gg\<Cr>
A__HERE1__\<Esc>
ggj\<Cr>
A__HERE2__\<Esc>
ggjj\<Cr>
A__HERE3__\<Esc>
ggjjj\<Cr>
A__HERE4__\<Esc>
Expect vimwiki (Good anchor with link navigation):
[A link B](#a-link-b)
[tlink](#tlink)
[7.4.1528](#741528)
[link (333)](#link-333)
# A [link](anything here) B__HERE1__
# t[link](anything here)__HERE2__
## 7.4.1528__HERE3__
#### [link]() (333)__HERE4__
# Link to anchor in SetExt {{{1
# Like that
# -----