1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
|
# Automatic link generation
# Related to:
# - wiki file discovery
# - buffer list insertion (see: vimwiki#base#update_listing_in_buffer)
Execute (Reset sw to default (due to batch)):
set sw=8
# 1 VimwikiGenerateLinks {{{1
##########################
# Wiki Syntax (no caption, default) {{{2
#################
Execute (Log):
Log 'Wiki Syntax (no caption, default)'
call ReloadVimwiki()
AssertEqual '-1_margin', vimwiki#vars#get_wikilocal('list_margin') . '_margin'
Given (Void):
Execute (VimwikiGenerateLinks):
edit $HOME/testwiki/Test.wiki
VimwikiGenerateLinks
Expect (The links with a header):
= Generated Links =
- [[buzz_bozz]]
- [[index]]
- [[link_syntax]]
- [[link_syntax/nested]]
Execute (VimwikiGenerateLinks x 2):
edit $HOME/testwiki/Test.wiki
VimwikiGenerateLinks
call append('$', 'Last Line')
VimwikiGenerateLinks
Expect (The links with a header (bis)):
= Generated Links =
- [[buzz_bozz]]
- [[index]]
- [[link_syntax]]
- [[link_syntax/nested]]
Last Line
Execute (Clean Test.wiki):
call DeleteFile('$HOME/testwiki/Test.wiki')
# Wiki Syntax (with caption) {{{2
#################
Execute (Log):
Log 'Wiki Syntax (with caption)'
let vimwiki_default.generated_links_caption = 1
call ReloadVimwiki()
AssertEqual '-1_margin', vimwiki#vars#get_wikilocal('list_margin') . '_margin'
Given (Void):
Execute (VimwikiGenerateLinks):
edit $HOME/testwiki/Test.wiki
VimwikiGenerateLinks
Expect (The links with a header):
= Generated Links =
- [[buzz_bozz|Buzz Bozz]]
- [[index|Test Wiki]]
- [[link_syntax]]
- [[link_syntax/nested]]
Execute (VimwikiGenerateLinks x 2):
edit $HOME/testwiki/Test.wiki
VimwikiGenerateLinks
call append('$', 'Last Line')
VimwikiGenerateLinks
Expect (The links with a header (bis)):
= Generated Links =
- [[buzz_bozz|Buzz Bozz]]
- [[index|Test Wiki]]
- [[link_syntax]]
- [[link_syntax/nested]]
Last Line
Execute (Clean Test.wiki):
call DeleteFile('$HOME/testwiki/Test.wiki')
# Markdown Syntax {{{2
#################
Execute (Log):
Log 'Markdown Syntax'
Given (Void):
Execute (Goto markdown resource wiki):
VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
Execute (Edit Test file / VimwikiGenerateLinks):
edit $HOME/testmarkdown/Test.md
AssertEqual $HOME . '/testmarkdown/Test.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
VimwikiGenerateLinks
Expect (The links with a header):
# Generated Links
- [Buzz Bozz](buzz_bozz)
- [Test Wiki](index)
- [link_syntax](link_syntax)
- [link_syntax/nested](link_syntax/nested)
Do (Save Test.md && Re-GenerateLinks):
:edit $HOME/testmarkdown/Test.md\<CR>
:call WriteMe()\<CR>
:VimwikiGenerateLinks\<CR>
:VimwikiGenerateLinks\<CR>
Expect (The links with a header with file Test):
# Generated Links
- [Generated Links](Test)
- [Buzz Bozz](buzz_bozz)
- [Test Wiki](index)
- [link_syntax](link_syntax)
- [link_syntax/nested](link_syntax/nested)
Execute (Clean: Remove Test.md):
call DeleteFile('$HOME/testmarkdown/Test.md')
# 2 VimwikiDiaryGenerateLinks {{{1
#############################
# Wiki Syntax {{{1
#################
Execute (Log):
Log 'Wiki Syntax'
Do (Create diary files):
:edit $HOME/testwiki/diary/2019-12-10.wiki\<Cr>
:call append('$', 'Content')\<Cr>
:call WriteMe()\<Cr>
:edit $HOME/testwiki/diary/2019-07-13.wiki\<Cr>
:call append('$', 'Content')\<Cr>
:call WriteMe()\<Cr>
:edit $HOME/testwiki/diary/2019-03-01.wiki\<Cr>
:call append('$', 'Content')\<Cr>
:call WriteMe()\<Cr>
Do (Edit diary.wiki && GenerateDiaryLinks):
:edit $HOME/testwiki/diary/diary.wiki\<CR>
:VimwikiDiaryGenerateLinks\<CR>
Expect (diary index generated):
= Diary =
== 2020 ==
=== July ===
- [[2020-07-25|day 4]]
- [[2020-07-24|day 3]]
- [[2020-07-23|Day 2]]
- [[2020-07-22]]
== 2019 ==
=== December ===
- [[2019-12-10]]
=== July ===
- [[2019-07-13]]
=== March ===
- [[2019-03-01]]
Execute (Clean):
Log "End: Clean"
call DeleteFile('$HOME/testwiki/diary/2019-12-10.wiki')
call DeleteFile('$HOME/testwiki/diary/2019-07-13.wiki')
call DeleteFile('$HOME/testwiki/diary/2019-03-01.wiki')
Log "End: Reset shiftwidth to the default: 8"
# Wiki Markdown {{{1
#################
Execute (Log):
Log 'Markdown Syntax'
Execute (New Command):
Log "2. Testing VimwikiDiaryGenerateLinks TODO"
set sw=4
AssertEqual 4, &sw
Do (Edit diary/2019-12-10):
:edit $HOME/testmarkdown/diary/2019-12-10.md\<CR>
iinformative content\<Esc>
:call WriteMe()\<CR>
Do (Edit and save diary/2019-07-13):
:edit $HOME/testmarkdown/diary/2019-07-13.md\<CR>
i# informative title\<Esc>
:call WriteMe()\<CR>
Do (Edit and save diary/2018-03-01):
:edit $HOME/testmarkdown/diary/2019-03-01.md\<CR>
:call WriteMe()\<CR>
Do (Edit diary.md && GenerateDiaryLinks):
:edit $HOME/testmarkdown/diary/diary.md\<CR>
:VimwikiDiaryGenerateLinks\<CR>
Expect (diary index generated):
# Diary
## 2020
### July
- [2020-07-22](2020-07-22)
## 2019
### December
- [2019-12-10](2019-12-10)
### July
- [informative title](2019-07-13)
### March
- [2019-03-01](2019-03-01)
Execute (Clean):
call DeleteFile('$HOME/testmarkdown/diary/2019-12-10.md')
call DeleteFile('$HOME/testmarkdown/diary/2019-07-13.md')
call DeleteFile('$HOME/testmarkdown/diary/2019-03-01.md')
Log "End: Reset shiftwidth to the default: 8"
set sw&
# vim: sw=2:foldmethod=marker:foldlevel=30:foldignore=:
|