File: html_convert_default.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 (300 lines) | stat: -rw-r--r-- 4,456 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
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# Conversion: Wiki -> Html

#################################################
Given vimwiki (Comments):
  This is some text
  %% This is a comment
  Test%%+INLINE COMMENT+%%1
  %%+INLINE COMMENT+%%Test2
  Test3%%+INLINE COMMENT+%%
  %%+ Multiline
  comment
  that
  is
  removed
  +%%
  Final text

Do (Convert):
  :call ConvertWiki2Html()\<Cr>
# Keep only body
  ggd/<body>\<Cr>

Expect (Comments Removed):
  <body>

  <p>
  This is some text
  Test1
  Test2
  Test3
  </p>






  <p>
  Final text
  </p>

  </body>
  </html>


#################################################
Given vimwiki (Table no heading {{{1):
  | header1 | header2 |
  |  val1    | val2    |
  |  val1    | val2    |
  |  val1    | val2    |

Do (Convert):
  :call ConvertWiki2Html()\<Cr>
# Keep only body
  ggd/<body>\<Cr>


Expect (Table no heading):
  <body>

  <table>
  <tr>
  <td>
  header1
  </td>
  <td>
  header2
  </td>
  </tr>
  <tr>
  <td>
  val1
  </td>
  <td>
  val2
  </td>
  </tr>
  <tr>
  <td>
  val1
  </td>
  <td>
  val2
  </td>
  </tr>
  <tr>
  <td>
  val1
  </td>
  <td>
  val2
  </td>
  </tr>
  </table>

  </body>
  </html>


Given vimwiki (Table with heading {{{1):
  | header1 | header2 | header3 |
  |---------|---------|---------|
  |  val1    | val2    | var3 |
  |  val4    | val5    | var6 |

Do (Convert):
  :call ConvertWiki2Html()\<Cr>
# Keep only body
  ggd/<body>\<Cr>


Expect (Table with heading):
  <body>

  <table>
  <thead>
  <tr>
  <th>
  header1
  </th>
  <th>
  header2
  </th>
  <th>
  header3
  </th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>
  val1
  </td>
  <td>
  val2
  </td>
  <td>
  var3
  </td>
  </tr>
  <tr>
  <td>
  val4
  </td>
  <td>
  val5
  </td>
  <td>
  var6
  </td>
  </tr>
  </tbody>
  </table>

  </body>
  </html>


#################################################
Execute (Log):
   Log '#473: Syntax "local:" doesnt work as expected. #473'

Given vimwiki (Void Md):

Execute (Edit Test473 Wiki):
  edit $HOME/testwiki/TestHtml.wiki

Do (Add local link: [[local:$HOME/here|Link]]):
  :edit $HOME/testwiki/Test473.wiki\<CR>
  i
  [[local:
  \<C-r>=$HOME\<Cr>
  /here|Link]]
  \<Esc>
  :call WriteMe()\<Cr>
  :Vimwiki2HTML\<Cr>


Execute (Save and Convert to html):
  edit $HOME/testwiki/Test473.wiki
  Vimwiki2HTML
  AssertEqual '[[local:'.$HOME.'/here|Link]]', getline(1)


Given (Void Html):

# TODO mutualise
Do (Get Html body):
  :read $HOME/html/default/Test473.html\<CR>
# Goto body
  gg/<body>\<CR>
# Copy in b
  "bdat
# Delete All
  ggdG
# Paste body
  "bP
# Remove last line
  Gdd
# Save (Not necessary)
  :write

Expect (Local link):
  <body>

  <p>
  <a href="../../here">Link</a>
  </p>

  </body>


Execute (Delete):
  call DeleteFile(' $HOME/testwiki/Test473.wiki')

#################################################
Given (Void):

Execute (Edit TestHtml Wiki):
  edit $HOME/testwiki/TestHtml.wiki
  AssertEqual $HOME . '/testwiki/TestHtml.wiki', expand('%')
  AssertEqual 'default', vimwiki#vars#get_wikilocal('syntax')
  AssertEqual 0, vimwiki#vars#get_bufferlocal('wiki_nr')

Do (Markdwon with %plainhtml):
  :edit $HOME/testwiki/TestHtml.wiki\<CR>
  :normal ggdG\<Cr>
  i%plainhtml<div id="test">\<CR>
  my paragraph\<CR>
  %plainhtml</div>\<CR>\<Esc>
  :set bt=\<CR>
  :write\<CR>

Execute (Save and Convert to html):
  edit $HOME/testwiki/TestHtml.wiki
  Vimwiki2HTML

Given (Void):

Do (Get Html body):
  :read $HOME/html/default/TestHtml.html\<CR>
# Goto body
  gg/<body>\<CR>
# Copy in b
  "bdat
# Delete All
  ggdG
# Paste body
  "bP
# Remove last line
  Gdd
# Save (Not necessary)
  :write



Expect (Plain Html):
# the whole default html file should be here as a base + the modifications
# from "Given"
  <body>

  <div id="test">
  <p>
  my paragraph
  </p>
  </div>

  </body>


Execute (Delete):
  call DeleteFile('$HOME/testwiki/TestHtml.wiki')


Given vimwiki (PR: Add option to configure date string format 1073) {{{1):
  %template template_1073
  content

Do (template_date_format):
# Set conf
  :let g:vimwiki_wikilocal_vars[0]['template_date_format'] = '%b %d, %Y'\<Cr>
# Convert
  :call ConvertWiki2Html()\<Cr>
# Erase oth and date
  :%s/[0-9]\+/Z/g\<Cr>
  :%s/[A-Z][a-z][a-z]/Z/g\<Cr>
# Restore peace
  :let g:vimwiki_wikilocal_vars[0]['template_date_format'] = ''\<Cr>

Expect (Date proper format):
  <html>
  <body>
      <div class="content">
          <p><small>Zt updated on Z Z, Z</small></p>
      </div>
  </body>
  </html>

# vim: sw=2 foldmethod=marker foldlevel=30