2020-08-03 04:05:37 +02:00
|
|
|
# VimwikiTOC {{{1
|
2020-07-30 21:27:19 +02:00
|
|
|
#
|
2020-08-06 04:26:05 +02:00
|
|
|
# Just generate the TOC
|
|
|
|
# See: link_* for link movement and creation
|
|
|
|
#
|
2020-07-30 21:27:19 +02:00
|
|
|
# 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)
|
2020-08-03 04:05:37 +02:00
|
|
|
#
|
|
|
|
# Doc: from #664:
|
|
|
|
# -- 1. It downcases the string => OK: from previous big collection
|
|
|
|
# -- 2. remove anything that is not a letter, number, space or hyphen (see the source for how Unicode is handled) => from 'bad characters'
|
|
|
|
# -- 3. changes any space to a hyphen => OK: from previous big
|
|
|
|
# -- 4. If that is not unique, add "-1", "-2", "-3",... to make it unique => TODO not implemented
|
2020-08-04 06:44:01 +02:00
|
|
|
#
|
2020-08-03 05:10:44 +02:00
|
|
|
#
|
|
|
|
# TODO if link in heading
|
|
|
|
#Given vimwiki (Two same heading {{{1):
|
|
|
|
# # Pre [link](anything no parenthesis) Post
|
|
|
|
#
|
|
|
|
#Execute (Set syntax markdown && Set sw=8):
|
|
|
|
# call SetSyntax('markdown')
|
|
|
|
# set sw=8
|
|
|
|
# VimwikiTOC
|
|
|
|
#
|
|
|
|
#Expect (Suffix -1 and -2):
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
2020-08-03 04:05:37 +02:00
|
|
|
# Start {{{1
|
|
|
|
|
2020-08-06 23:02:51 +02:00
|
|
|
Given vimwiki (One heading: May delete last line (#910) {{{1):
|
|
|
|
# Basic-title
|
|
|
|
|
|
|
|
|
|
|
|
Execute (VimwikiTOC x 1):
|
|
|
|
call SetSyntax('markdown')
|
|
|
|
set sw=8
|
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
|
|
|
|
Expect(Good content with 1 item x 1):
|
|
|
|
# Contents
|
|
|
|
|
|
|
|
- [Basic-title](#basic-title)
|
|
|
|
|
|
|
|
# Basic-title
|
|
|
|
|
|
|
|
Execute (VimwikiTOC x 2):
|
|
|
|
call SetSyntax('markdown')
|
|
|
|
set sw=8
|
|
|
|
VimwikiTOC
|
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
Expect(Good content with 1 item x 1):
|
|
|
|
# Contents
|
|
|
|
|
|
|
|
- [Basic-title](#basic-title)
|
|
|
|
|
|
|
|
# Basic-title
|
|
|
|
|
|
|
|
|
2020-08-06 04:26:05 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2020-08-03 05:10:44 +02:00
|
|
|
|
2020-08-04 06:44:01 +02:00
|
|
|
Given vimwiki (Underline header (SetExt) (#209) {{{1):
|
|
|
|
First with spaces
|
|
|
|
=====
|
|
|
|
|
|
|
|
toto
|
|
|
|
|
|
|
|
Second
|
|
|
|
-------
|
|
|
|
toto
|
|
|
|
|
|
|
|
Third
|
|
|
|
-----
|
|
|
|
toto
|
|
|
|
|
|
|
|
Four
|
|
|
|
=====
|
|
|
|
toto
|
|
|
|
Last
|
|
|
|
----
|
|
|
|
|
|
|
|
Execute (Set syntax markdown && Set sw=8):
|
|
|
|
call SetSyntax('markdown')
|
|
|
|
set sw=8
|
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
Expect (Heading SetExt created):
|
|
|
|
# Contents
|
|
|
|
|
|
|
|
- [First with spaces](#first-with-spaces)
|
|
|
|
- [Second](#second)
|
|
|
|
- [Third](#third)
|
|
|
|
- [Four](#four)
|
|
|
|
- [Last](#last)
|
|
|
|
|
|
|
|
First with spaces
|
|
|
|
=====
|
|
|
|
|
|
|
|
toto
|
|
|
|
|
|
|
|
Second
|
|
|
|
-------
|
|
|
|
toto
|
|
|
|
|
|
|
|
Third
|
|
|
|
-----
|
|
|
|
toto
|
|
|
|
|
|
|
|
Four
|
|
|
|
=====
|
|
|
|
toto
|
|
|
|
Last
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2020-08-03 05:10:44 +02:00
|
|
|
|
|
|
|
Given vimwiki (Two same heading (#968) {{{1):
|
|
|
|
# One
|
|
|
|
toto
|
|
|
|
# ONE
|
|
|
|
like
|
|
|
|
## oNe
|
|
|
|
you
|
|
|
|
|
|
|
|
Execute (Set syntax markdown && Set sw=8):
|
|
|
|
call SetSyntax('markdown')
|
|
|
|
set sw=8
|
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
Expect (Suffix -2 and -3):
|
|
|
|
# Contents
|
|
|
|
|
|
|
|
- [One](#one)
|
|
|
|
- [ONE](#one-2)
|
|
|
|
- [oNe](#one-3)
|
|
|
|
|
|
|
|
# One
|
|
|
|
toto
|
|
|
|
# ONE
|
|
|
|
like
|
|
|
|
## oNe
|
|
|
|
you
|
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
|
|
|
|
Given vimwiki (Heading with many bad caracters {{{1):
|
|
|
|
# One !@#@#(!%#&$^(!@
|
|
|
|
## Two !!~!!:"@!>@!>?<
|
|
|
|
|
|
|
|
Execute (Set syntax markdown && VimwikiTOC):
|
|
|
|
call SetSyntax('markdown')
|
|
|
|
set sw=8
|
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
Expect (Bad characters are removed):
|
|
|
|
# Contents
|
2020-08-04 06:44:01 +02:00
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
- [One !@#@#(!%#&$^(!@](#one-)
|
|
|
|
- [Two !!~!!:"@!>@!>?<](#two-)
|
2020-08-04 06:44:01 +02:00
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
# One !@#@#(!%#&$^(!@
|
|
|
|
## Two !!~!!:"@!>@!>?<
|
|
|
|
|
|
|
|
|
|
|
|
# Large previous tests {{{1
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
Execute (Reset TOC header to default):
|
2020-07-30 21:27:19 +02:00
|
|
|
call vimwiki#vars#set_wikilocal('toc_header', 'Contents')
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
Given vimwiki (Headings):
|
|
|
|
# Header 1
|
|
|
|
random text
|
|
|
|
## Header 1.1
|
|
|
|
random text
|
|
|
|
### Header 1.1.1
|
|
|
|
random text
|
2019-12-21 17:09:16 +01:00
|
|
|
|
2019-12-15 05:37:28 +01:00
|
|
|
# Header 2
|
|
|
|
### Header 2.1.1
|
|
|
|
|
|
|
|
Execute (Set syntax markdown && Set sw=8):
|
|
|
|
call SetSyntax('markdown')
|
|
|
|
set sw=8
|
|
|
|
|
|
|
|
Execute (VimwikiTOC):
|
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
Expect (With a TOC sw=8):
|
|
|
|
# Contents
|
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
- [Header 1](#header-1)
|
|
|
|
- [Header 1.1](#header-11)
|
|
|
|
- [Header 1.1.1](#header-111)
|
|
|
|
- [Header 2](#header-2)
|
|
|
|
- [Header 2.1.1](#header-211)
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
# Header 1
|
|
|
|
random text
|
|
|
|
## Header 1.1
|
|
|
|
random text
|
|
|
|
### Header 1.1.1
|
|
|
|
random text
|
|
|
|
|
|
|
|
# Header 2
|
|
|
|
### Header 2.1.1
|
|
|
|
|
|
|
|
Execute (Set sw=4 && VimwikiTOC):
|
|
|
|
set sw=4
|
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
Expect (With a TOC sw=4):
|
|
|
|
# Contents
|
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
- [Header 1](#header-1)
|
|
|
|
- [Header 1.1](#header-11)
|
|
|
|
- [Header 1.1.1](#header-111)
|
|
|
|
- [Header 2](#header-2)
|
|
|
|
- [Header 2.1.1](#header-211)
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
# Header 1
|
|
|
|
random text
|
|
|
|
## Header 1.1
|
|
|
|
random text
|
|
|
|
### Header 1.1.1
|
|
|
|
random text
|
|
|
|
|
|
|
|
# Header 2
|
|
|
|
### Header 2.1.1
|
|
|
|
|
|
|
|
Do (Destroy some stuff):
|
|
|
|
jj
|
|
|
|
dd
|
|
|
|
jj
|
|
|
|
dd
|
|
|
|
|
|
|
|
Execute (VimwikiTOC):
|
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
Expect (Brand new TOC):
|
|
|
|
# Contents
|
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
- [Header 1](#header-1)
|
|
|
|
- [Header 1.1](#header-11)
|
|
|
|
- [Header 1.1.1](#header-111)
|
|
|
|
- [Header 2](#header-2)
|
|
|
|
- [Header 2.1.1](#header-211)
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
# Header 1
|
|
|
|
random text
|
|
|
|
## Header 1.1
|
|
|
|
random text
|
|
|
|
### Header 1.1.1
|
|
|
|
random text
|
|
|
|
|
|
|
|
# Header 2
|
|
|
|
### Header 2.1.1
|
|
|
|
|
|
|
|
|
|
|
|
Execute (Let toc_header = Sommaire && VimwikiTOC):
|
2020-07-30 21:27:19 +02:00
|
|
|
call vimwiki#vars#set_wikilocal('toc_header', 'Sommaire')
|
2019-12-15 05:37:28 +01:00
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
Expect (Append a Sommaire && Leave Contents alone):
|
|
|
|
# Sommaire
|
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
- [Header 1](#header-1)
|
|
|
|
- [Header 1.1](#header-11)
|
|
|
|
- [Header 1.1.1](#header-111)
|
|
|
|
- [Header 2](#header-2)
|
|
|
|
- [Header 2.1.1](#header-211)
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
# Header 1
|
|
|
|
random text
|
|
|
|
## Header 1.1
|
|
|
|
random text
|
|
|
|
### Header 1.1.1
|
|
|
|
random text
|
|
|
|
|
|
|
|
# Header 2
|
|
|
|
### Header 2.1.1
|
|
|
|
|
|
|
|
Do (Destroy some stuff):
|
|
|
|
jj
|
|
|
|
dd
|
|
|
|
jj
|
|
|
|
dd
|
|
|
|
|
|
|
|
Execute (VimwikiTOC):
|
|
|
|
VimwikiTOC
|
|
|
|
|
|
|
|
Expect (Brand new TOC with sommaire):
|
|
|
|
# Sommaire
|
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
- [Header 1](#header-1)
|
|
|
|
- [Header 1.1](#header-11)
|
|
|
|
- [Header 1.1.1](#header-111)
|
|
|
|
- [Header 2](#header-2)
|
|
|
|
- [Header 2.1.1](#header-211)
|
2019-12-15 05:37:28 +01:00
|
|
|
|
|
|
|
# Header 1
|
|
|
|
random text
|
|
|
|
## Header 1.1
|
|
|
|
random text
|
|
|
|
### Header 1.1.1
|
|
|
|
random text
|
|
|
|
|
|
|
|
# Header 2
|
|
|
|
### Header 2.1.1
|
|
|
|
|
|
|
|
|
2020-06-04 23:29:47 +02:00
|
|
|
Execute (call vimwiki#vars#set_global('toc_header_level', 6):
|
2020-07-30 21:27:19 +02:00
|
|
|
call vimwiki#vars#set_wikilocal('toc_header_level', 6)
|
2020-06-04 23:29:47 +02:00
|
|
|
VimwikiTOC
|
|
|
|
# Reset default
|
2020-07-30 21:27:19 +02:00
|
|
|
call vimwiki#vars#set_wikilocal('toc_header_level', 1)
|
2020-06-04 23:29:47 +02:00
|
|
|
|
|
|
|
Expect (Content prepended):
|
|
|
|
###### Sommaire
|
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
- [Header 1](#header-1)
|
|
|
|
- [Header 1.1](#header-11)
|
|
|
|
- [Header 1.1.1](#header-111)
|
|
|
|
- [Header 2](#header-2)
|
|
|
|
- [Header 2.1.1](#header-211)
|
2020-06-04 23:29:47 +02:00
|
|
|
|
|
|
|
# Header 1
|
|
|
|
random text
|
|
|
|
## Header 1.1
|
|
|
|
random text
|
|
|
|
### Header 1.1.1
|
|
|
|
random text
|
|
|
|
|
|
|
|
# Header 2
|
|
|
|
### Header 2.1.1
|
|
|
|
|
2020-08-03 04:05:37 +02:00
|
|
|
" vim: sw=2 foldmethod=marker foldlevel=30 foldignore=#
|