File: link_syntax_markdown.vader

package info (click to toggle)
vim-vimwiki 2024.01.24-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,692 kB
  • sloc: sh: 313; makefile: 2
file content (122 lines) | stat: -rw-r--r-- 3,807 bytes parent folder | download | duplicates (2)
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
# Test resolution of as many link types as possible in Markdown syntax

# This relies on the line numbers for each type of link in link_syntax.md and
# link_syntax/nested.md, which seems primitive, but does seem to work.

# Links in a top-level page {{{

Execute (Assure link_syntax.md exists):
  Log "Testing links in a top-level page with native syntax."
  VimwikiIndex 2
  VimwikiGoto link_syntax
  AssertEqual $HOME . '/testmarkdown/link_syntax.md', expand('%')

Do (Check plain wiki page link to index):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax\<CR>
  :1\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>

Do (Check absolute-in-wiki page link to index with leading slash):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax\<CR>
  :2\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>

# //foo "absolute" links - these are also checked in link_generation.vader:
Do (Check absolute-on-filesystem page link to /tmp/some_page with 2 leading slashes):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax\<CR>
  :3\<CR>
  \<CR>
  :AssertEqual '/tmp/some_page.md', expand('%')\<CR>

Do (Check absolute-on-filesystem page link to index using tilde for homedir):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax\<CR>
  :4\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>

Do (Check diary link):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax\<CR>
  :5\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/diary/2020-07-22.md', expand('%')\<CR>

Do (Check link to nested page):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax\<CR>
  :6\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/link_syntax/nested.md', expand('%')\<CR>

Do (Check relative link to nested page with ./link_syntax/nested):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax\<CR>
  :7\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/link_syntax/nested.md', expand('%')\<CR>

# }}}

# Links in a nested file {{{

Execute (Assure link_syntax/nested.md exists):
  Log "Testing links in a nested page with native syntax."
  VimwikiIndex 2
  VimwikiGoto link_syntax/nested
  AssertEqual $HOME . '/testmarkdown/link_syntax/nested.md', expand('%')

Do (Nested: Check plain wiki page link to self - link_syntax/nested.md):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax/nested\<CR>
  :1\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/link_syntax/nested.md', expand('%')\<CR>

Do (Nested: Check absolute-in-wiki page link to index with leading slash):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax/nested\<CR>
  :2\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>

# //foo "absolute" links - these are also checked in link_generation.vader:
Do (Nested: Check absolute-on-filesystem page link to /tmp/some_page with 2 leading slashes):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax/nested\<CR>
  :3\<CR>
  \<CR>
  :AssertEqual '/tmp/some_page.md', expand('%')\<CR>

Do (Nested: Check absolute-on-filesystem page link to index using tilde for homedir):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax/nested\<CR>
  :4\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/index.md', expand('%')\<CR>

Do (Nested: Check diary link):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax/nested\<CR>
  :5\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/diary/2020-07-22.md', expand('%')\<CR>

Do (Nested: Check relative link to page in parent directory):
  :VimwikiIndex 2\<CR>
  :VimwikiGoto link_syntax/nested\<CR>
  :6\<CR>
  \<CR>
  :AssertEqual $HOME . '/testmarkdown/link_syntax.md', expand('%')\<CR>

# }}}

# To be perfectly honest I don't know why or if this is necessary, but without
# it I was getting leftover tabs for the last file visited here. -- brennen
Execute (Clean):
  call ReloadVimwiki()