7
|
1 " Vim syntax support file
|
|
2 " Maintainer: Bram Moolenaar <Bram@vim.org>
|
856
|
3 " Last Change: 2006 Apr 30
|
7
|
4 " (modified by David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>)
|
|
5 " (XHTML support by Panagiotis Issaris <takis@lumumba.luc.ac.be>)
|
|
6
|
|
7 " Transform a file into HTML, using the current syntax highlighting.
|
|
8
|
|
9 " Number lines when explicitely requested or when `number' is set
|
|
10 if exists("html_number_lines")
|
|
11 let s:numblines = html_number_lines
|
|
12 else
|
|
13 let s:numblines = &number
|
|
14 endif
|
|
15
|
|
16 " When not in gui we can only guess the colors.
|
|
17 if has("gui_running")
|
|
18 let s:whatterm = "gui"
|
|
19 else
|
|
20 let s:whatterm = "cterm"
|
|
21 if &t_Co == 8
|
|
22 let s:cterm_color0 = "#808080"
|
|
23 let s:cterm_color1 = "#ff6060"
|
|
24 let s:cterm_color2 = "#00ff00"
|
|
25 let s:cterm_color3 = "#ffff00"
|
|
26 let s:cterm_color4 = "#8080ff"
|
|
27 let s:cterm_color5 = "#ff40ff"
|
|
28 let s:cterm_color6 = "#00ffff"
|
|
29 let s:cterm_color7 = "#ffffff"
|
|
30 else
|
|
31 let s:cterm_color0 = "#000000"
|
|
32 let s:cterm_color1 = "#c00000"
|
|
33 let s:cterm_color2 = "#008000"
|
|
34 let s:cterm_color3 = "#804000"
|
|
35 let s:cterm_color4 = "#0000c0"
|
|
36 let s:cterm_color5 = "#c000c0"
|
|
37 let s:cterm_color6 = "#008080"
|
|
38 let s:cterm_color7 = "#c0c0c0"
|
|
39 let s:cterm_color8 = "#808080"
|
|
40 let s:cterm_color9 = "#ff6060"
|
|
41 let s:cterm_color10 = "#00ff00"
|
|
42 let s:cterm_color11 = "#ffff00"
|
|
43 let s:cterm_color12 = "#8080ff"
|
|
44 let s:cterm_color13 = "#ff40ff"
|
|
45 let s:cterm_color14 = "#00ffff"
|
|
46 let s:cterm_color15 = "#ffffff"
|
|
47 endif
|
|
48 endif
|
|
49
|
|
50 " Return good color specification: in GUI no transformation is done, in
|
|
51 " terminal return RGB values of known colors and empty string on unknown
|
|
52 if s:whatterm == "gui"
|
|
53 function! s:HtmlColor(color)
|
|
54 return a:color
|
|
55 endfun
|
|
56 else
|
|
57 function! s:HtmlColor(color)
|
|
58 if exists("s:cterm_color" . a:color)
|
|
59 execute "return s:cterm_color" . a:color
|
|
60 else
|
|
61 return ""
|
|
62 endif
|
|
63 endfun
|
|
64 endif
|
|
65
|
|
66 if !exists("html_use_css")
|
|
67 " Return opening HTML tag for given highlight id
|
|
68 function! s:HtmlOpening(id)
|
|
69 let a = ""
|
|
70 if synIDattr(a:id, "inverse")
|
|
71 " For inverse, we always must set both colors (and exchange them)
|
|
72 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
|
|
73 let a = a . '<span style="background-color: ' . ( x != "" ? x : s:fgc ) . '">'
|
|
74 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
|
|
75 let a = a . '<font color="' . ( x != "" ? x : s:bgc ) . '">'
|
|
76 else
|
|
77 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
|
|
78 if x != "" | let a = a . '<span style="background-color: ' . x . '">' | endif
|
|
79 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
|
|
80 if x != "" | let a = a . '<font color="' . x . '">' | endif
|
|
81 endif
|
|
82 if synIDattr(a:id, "bold") | let a = a . "<b>" | endif
|
|
83 if synIDattr(a:id, "italic") | let a = a . "<i>" | endif
|
|
84 if synIDattr(a:id, "underline") | let a = a . "<u>" | endif
|
|
85 return a
|
|
86 endfun
|
|
87
|
|
88 " Return closing HTML tag for given highlight id
|
|
89 function s:HtmlClosing(id)
|
|
90 let a = ""
|
|
91 if synIDattr(a:id, "underline") | let a = a . "</u>" | endif
|
|
92 if synIDattr(a:id, "italic") | let a = a . "</i>" | endif
|
|
93 if synIDattr(a:id, "bold") | let a = a . "</b>" | endif
|
|
94 if synIDattr(a:id, "inverse")
|
|
95 let a = a . '</font></span>'
|
|
96 else
|
|
97 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
|
|
98 if x != "" | let a = a . '</font>' | endif
|
|
99 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
|
|
100 if x != "" | let a = a . '</span>' | endif
|
|
101 endif
|
|
102 return a
|
|
103 endfun
|
|
104 endif
|
|
105
|
34
|
106 " Return HTML valid characters enclosed in a span of class style_name with
|
|
107 " unprintable characters expanded and double spaces replaced as necessary.
|
|
108 function! s:HtmlFormat(text, style_name)
|
|
109 " Replace unprintable characters
|
|
110 let formatted = strtrans(a:text)
|
|
111
|
|
112 " Replace the reserved html characters
|
|
113 let formatted = substitute(substitute(substitute(substitute(substitute(formatted, '&', '\&', 'g'), '<', '\<', 'g'), '>', '\>', 'g'), '"', '\"', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g')
|
856
|
114
|
837
|
115 " Replace double spaces and leading spaces
|
856
|
116 if ' ' != s:HtmlSpace
|
34
|
117 let formatted = substitute(formatted, ' ', s:HtmlSpace . s:HtmlSpace, 'g')
|
837
|
118 let formatted = substitute(formatted, '^ ', s:HtmlSpace, 'g')
|
34
|
119 endif
|
|
120
|
|
121 " Enclose in a span of class style_name
|
|
122 let formatted = '<span class="' . a:style_name . '">' . formatted . '</span>'
|
|
123
|
|
124 " Add the class to class list if it's not there yet
|
|
125 let s:id = hlID(a:style_name)
|
|
126 if stridx(s:idlist, "," . s:id . ",") == -1
|
|
127 let s:idlist = s:idlist . s:id . ","
|
|
128 endif
|
|
129
|
|
130 return formatted
|
|
131 endfun
|
|
132
|
7
|
133 " Return CSS style describing given highlight id (can be empty)
|
|
134 function! s:CSS1(id)
|
|
135 let a = ""
|
|
136 if synIDattr(a:id, "inverse")
|
|
137 " For inverse, we always must set both colors (and exchange them)
|
|
138 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
|
|
139 let a = a . "color: " . ( x != "" ? x : s:bgc ) . "; "
|
|
140 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
|
|
141 let a = a . "background-color: " . ( x != "" ? x : s:fgc ) . "; "
|
|
142 else
|
|
143 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
|
|
144 if x != "" | let a = a . "color: " . x . "; " | endif
|
|
145 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
|
|
146 if x != "" | let a = a . "background-color: " . x . "; " | endif
|
|
147 endif
|
|
148 if synIDattr(a:id, "bold") | let a = a . "font-weight: bold; " | endif
|
|
149 if synIDattr(a:id, "italic") | let a = a . "font-style: italic; " | endif
|
|
150 if synIDattr(a:id, "underline") | let a = a . "text-decoration: underline; " | endif
|
|
151 return a
|
|
152 endfun
|
|
153
|
|
154 " Figure out proper MIME charset from the 'encoding' option.
|
|
155 if exists("html_use_encoding")
|
|
156 let s:html_encoding = html_use_encoding
|
|
157 else
|
|
158 let s:vim_encoding = &encoding
|
|
159 if s:vim_encoding =~ '^8bit\|^2byte'
|
|
160 let s:vim_encoding = substitute(s:vim_encoding, '^8bit-\|^2byte-', '', '')
|
|
161 endif
|
|
162 if s:vim_encoding == 'latin1'
|
|
163 let s:html_encoding = 'iso-8859-1'
|
|
164 elseif s:vim_encoding =~ "^cp12"
|
|
165 let s:html_encoding = substitute(s:vim_encoding, 'cp', 'windows-', '')
|
|
166 elseif s:vim_encoding == 'sjis'
|
|
167 let s:html_encoding = 'Shift_JIS'
|
575
|
168 elseif s:vim_encoding == 'big5'
|
|
169 let s:html_encoding = "Big5"
|
7
|
170 elseif s:vim_encoding == 'euc-cn'
|
|
171 let s:html_encoding = 'GB_2312-80'
|
|
172 elseif s:vim_encoding == 'euc-tw'
|
|
173 let s:html_encoding = ""
|
|
174 elseif s:vim_encoding =~ '^euc\|^iso\|^koi'
|
|
175 let s:html_encoding = substitute(s:vim_encoding, '.*', '\U\0', '')
|
|
176 elseif s:vim_encoding == 'cp949'
|
|
177 let s:html_encoding = 'KS_C_5601-1987'
|
|
178 elseif s:vim_encoding == 'cp936'
|
|
179 let s:html_encoding = 'GBK'
|
|
180 elseif s:vim_encoding =~ '^ucs\|^utf'
|
|
181 let s:html_encoding = 'UTF-8'
|
|
182 else
|
|
183 let s:html_encoding = ""
|
|
184 endif
|
|
185 endif
|
|
186
|
|
187
|
|
188 " Set some options to make it work faster.
|
|
189 " Don't report changes for :substitute, there will be many of them.
|
|
190 let s:old_title = &title
|
|
191 let s:old_icon = &icon
|
|
192 let s:old_et = &l:et
|
|
193 let s:old_report = &report
|
|
194 let s:old_search = @/
|
|
195 set notitle noicon
|
|
196 setlocal et
|
|
197 set report=1000000
|
|
198
|
|
199 " Split window to create a buffer with the HTML file.
|
|
200 let s:orgbufnr = winbufnr(0)
|
|
201 if expand("%") == ""
|
|
202 new Untitled.html
|
|
203 else
|
|
204 new %.html
|
|
205 endif
|
|
206 let s:newwin = winnr()
|
|
207 let s:orgwin = bufwinnr(s:orgbufnr)
|
|
208
|
|
209 set modifiable
|
|
210 %d
|
|
211 let s:old_paste = &paste
|
|
212 set paste
|
|
213 let s:old_magic = &magic
|
|
214 set magic
|
|
215
|
|
216 if exists("use_xhtml")
|
39
|
217 if s:html_encoding != ""
|
|
218 exe "normal! a<?xml version=\"1.0\" encoding=\"" . s:html_encoding . "\"?>\n\e"
|
|
219 else
|
|
220 exe "normal! a<?xml version=\"1.0\"?>\n\e"
|
|
221 endif
|
34
|
222 let s:tag_close = '/>'
|
7
|
223 else
|
34
|
224 let s:tag_close = '>'
|
|
225 endif
|
|
226
|
|
227 let s:HtmlSpace = ' '
|
836
|
228 let s:LeadingSpace = ' '
|
34
|
229 let s:HtmlEndline = ''
|
|
230 if exists("html_no_pre")
|
|
231 let s:HtmlEndline = '<br' . s:tag_close
|
|
232 if exists("use_xhtml")
|
836
|
233 let s:LeadingSpace = ' '
|
34
|
234 else
|
836
|
235 let s:LeadingSpace = ' '
|
34
|
236 endif
|
836
|
237 let s:HtmlSpace = '\' . s:LeadingSpace
|
7
|
238 endif
|
|
239
|
|
240 " HTML header, with the title and generator ;-). Left free space for the CSS,
|
|
241 " to be filled at the end.
|
39
|
242 exe "normal! a<html>\n\e"
|
|
243 exe "normal! a<head>\n<title>" . expand("%:p:~") . "</title>\n\e"
|
34
|
244 exe "normal! a<meta name=\"Generator\" content=\"Vim/" . v:version/100 . "." . v:version %100 . '"' . s:tag_close . "\n\e"
|
7
|
245 if s:html_encoding != ""
|
34
|
246 exe "normal! a<meta http-equiv=\"content-type\" content=\"text/html; charset=" . s:html_encoding . '"' . s:tag_close . "\n\e"
|
7
|
247 endif
|
|
248 if exists("html_use_css")
|
|
249 exe "normal! a<style type=\"text/css\">\n<!--\n-->\n</style>\n\e"
|
|
250 endif
|
|
251 if exists("html_no_pre")
|
836
|
252 if exists("use_xhtml")
|
|
253 exe "normal! a</head>\n<body>\n<p>\n\e"
|
|
254 else
|
|
255 exe "normal! a</head>\n<body>\n\e"
|
|
256 endif
|
7
|
257 else
|
836
|
258 if exists("use_xhtml")
|
|
259 exe "normal! a</head>\n<body>\n<p>\n<pre>\n\e"
|
|
260 else
|
|
261 exe "normal! a</head>\n<body>\n<pre>\n\e"
|
|
262 endif
|
7
|
263 endif
|
|
264
|
|
265 exe s:orgwin . "wincmd w"
|
|
266
|
|
267 " List of all id's
|
|
268 let s:idlist = ","
|
|
269
|
|
270 " Loop over all lines in the original text.
|
|
271 " Use html_start_line and html_end_line if they are set.
|
|
272 if exists("html_start_line")
|
|
273 let s:lnum = html_start_line
|
|
274 if s:lnum < 1 || s:lnum > line("$")
|
|
275 let s:lnum = 1
|
|
276 endif
|
|
277 else
|
|
278 let s:lnum = 1
|
|
279 endif
|
|
280 if exists("html_end_line")
|
|
281 let s:end = html_end_line
|
|
282 if s:end < s:lnum || s:end > line("$")
|
|
283 let s:end = line("$")
|
|
284 endif
|
|
285 else
|
|
286 let s:end = line("$")
|
|
287 endif
|
|
288
|
279
|
289 if has('folding') && !exists('html_ignore_folding')
|
34
|
290 let s:foldfillchar = &fillchars[matchend(&fillchars, 'fold:')]
|
|
291 if s:foldfillchar == ''
|
|
292 let s:foldfillchar = '-'
|
29
|
293 endif
|
34
|
294 endif
|
|
295 let s:difffillchar = &fillchars[matchend(&fillchars, 'diff:')]
|
|
296 if s:difffillchar == ''
|
|
297 let s:difffillchar = '-'
|
29
|
298 endif
|
|
299
|
|
300
|
7
|
301 while s:lnum <= s:end
|
|
302
|
32
|
303 " If there are filler lines for diff mode, show these above the line.
|
|
304 let s:filler = diff_filler(s:lnum)
|
|
305 if s:filler > 0
|
|
306 let s:n = s:filler
|
|
307 while s:n > 0
|
34
|
308 if s:numblines
|
856
|
309 " Indent if line numbering is on
|
|
310 let s:new = repeat(s:LeadingSpace, strlen(s:end) + 1) . repeat(s:difffillchar, 3)
|
32
|
311 else
|
856
|
312 let s:new = repeat(s:difffillchar, 3)
|
32
|
313 endif
|
|
314
|
34
|
315 if s:n > 2 && s:n < s:filler && !exists("html_whole_filler")
|
|
316 let s:new = s:new . " " . s:filler . " inserted lines "
|
|
317 let s:n = 2
|
|
318 endif
|
|
319
|
|
320 if !exists("html_no_pre")
|
856
|
321 " HTML line wrapping is off--go ahead and fill to the margin
|
|
322 let s:new = s:new . repeat(s:difffillchar, &columns - strlen(s:new))
|
34
|
323 endif
|
|
324
|
|
325 let s:new = s:HtmlFormat(s:new, "DiffDelete")
|
32
|
326 exe s:newwin . "wincmd w"
|
34
|
327 exe "normal! a" . s:new . s:HtmlEndline . "\n\e"
|
32
|
328 exe s:orgwin . "wincmd w"
|
34
|
329
|
32
|
330 let s:n = s:n - 1
|
|
331 endwhile
|
|
332 unlet s:n
|
|
333 endif
|
|
334 unlet s:filler
|
|
335
|
|
336 " Start the line with the line number.
|
|
337 if s:numblines
|
34
|
338 let s:new = repeat(' ', strlen(s:end) - strlen(s:lnum)) . s:lnum . ' '
|
32
|
339 else
|
|
340 let s:new = ""
|
|
341 endif
|
|
342
|
279
|
343 if has('folding') && !exists('html_ignore_folding') && foldclosed(s:lnum) > -1
|
29
|
344 "
|
|
345 " This is the beginning of a folded block
|
|
346 "
|
34
|
347 let s:new = s:new . foldtextresult(s:lnum)
|
29
|
348 if !exists("html_no_pre")
|
34
|
349 " HTML line wrapping is off--go ahead and fill to the margin
|
|
350 let s:new = s:new . repeat(s:foldfillchar, &columns - strlen(s:new))
|
29
|
351 endif
|
856
|
352
|
34
|
353 let s:new = s:HtmlFormat(s:new, "Folded")
|
7
|
354
|
856
|
355 " Skip to the end of the fold
|
29
|
356 let s:lnum = foldclosedend(s:lnum)
|
|
357
|
|
358 else
|
|
359 "
|
|
360 " A line that is not folded.
|
|
361 "
|
34
|
362 let s:line = getline(s:lnum)
|
|
363
|
29
|
364 let s:len = strlen(s:line)
|
|
365
|
|
366 if s:numblines
|
837
|
367 let s:new = s:HtmlFormat(s:new, "lnr")
|
7
|
368 endif
|
29
|
369
|
32
|
370 " Get the diff attribute, if any.
|
|
371 let s:diffattr = diff_hlID(s:lnum, 1)
|
|
372
|
29
|
373 " Loop over each character in the line
|
|
374 let s:col = 1
|
34
|
375 while s:col <= s:len || (s:col == 1 && s:diffattr)
|
29
|
376 let s:startcol = s:col " The start column for processing text
|
32
|
377 if s:diffattr
|
|
378 let s:id = diff_hlID(s:lnum, s:col)
|
|
379 let s:col = s:col + 1
|
|
380 " Speed loop (it's small - that's the trick)
|
|
381 " Go along till we find a change in hlID
|
|
382 while s:col <= s:len && s:id == diff_hlID(s:lnum, s:col) | let s:col = s:col + 1 | endwhile
|
856
|
383 if s:len < &columns && !exists("html_no_pre")
|
32
|
384 " Add spaces at the end to mark the changed line.
|
856
|
385 let s:line = s:line . repeat(' ', &columns - s:len)
|
|
386 let s:len = &columns
|
|
387 endif
|
32
|
388 else
|
|
389 let s:id = synID(s:lnum, s:col, 1)
|
|
390 let s:col = s:col + 1
|
|
391 " Speed loop (it's small - that's the trick)
|
|
392 " Go along till we find a change in synID
|
|
393 while s:col <= s:len && s:id == synID(s:lnum, s:col, 1) | let s:col = s:col + 1 | endwhile
|
|
394 endif
|
29
|
395
|
34
|
396 " Expand tabs
|
|
397 let s:expandedtab = strpart(s:line, s:startcol - 1, s:col - s:startcol)
|
|
398 let idx = stridx(s:expandedtab, "\t")
|
|
399 while idx >= 0
|
856
|
400 let i = &ts - ((idx + s:startcol - 1) % &ts)
|
|
401 let s:expandedtab = substitute(s:expandedtab, '\t', repeat(' ', i), '')
|
|
402 let idx = stridx(s:expandedtab, "\t")
|
34
|
403 endwhile
|
|
404
|
29
|
405 " Output the text with the same synID, with class set to {s:id_name}
|
|
406 let s:id = synIDtrans(s:id)
|
|
407 let s:id_name = synIDattr(s:id, "name", s:whatterm)
|
34
|
408 let s:new = s:new . s:HtmlFormat(s:expandedtab, s:id_name)
|
29
|
409 endwhile
|
|
410 endif
|
7
|
411
|
|
412 exe s:newwin . "wincmd w"
|
34
|
413 exe "normal! a" . s:new . s:HtmlEndline . "\n\e"
|
7
|
414 exe s:orgwin . "wincmd w"
|
|
415 let s:lnum = s:lnum + 1
|
|
416 endwhile
|
|
417 " Finish with the last line
|
|
418 exe s:newwin . "wincmd w"
|
|
419 if exists("html_no_pre")
|
836
|
420 if exists("use_xhtml")
|
|
421 exe "normal! a</p>\n</body>\n</html>\e"
|
|
422 else
|
837
|
423 exe "normal! a</body>\n</html>\e"
|
836
|
424 endif
|
7
|
425 else
|
836
|
426 if exists("use_xhtml")
|
|
427 exe "normal! a</pre>\n</p>\n</body>\n</html>\e"
|
|
428 else
|
|
429 exe "normal! a</pre>\n</body>\n</html>\e"
|
|
430 endif
|
7
|
431 endif
|
|
432
|
|
433
|
|
434 " Now, when we finally know which, we define the colors and styles
|
|
435 if exists("html_use_css")
|
|
436 1;/<style type="text/+1
|
|
437 endif
|
|
438
|
|
439 " Find out the background and foreground color.
|
|
440 let s:fgc = s:HtmlColor(synIDattr(hlID("Normal"), "fg#", s:whatterm))
|
|
441 let s:bgc = s:HtmlColor(synIDattr(hlID("Normal"), "bg#", s:whatterm))
|
|
442 if s:fgc == ""
|
|
443 let s:fgc = ( &background == "dark" ? "#ffffff" : "#000000" )
|
|
444 endif
|
|
445 if s:bgc == ""
|
|
446 let s:bgc = ( &background == "dark" ? "#000000" : "#ffffff" )
|
|
447 endif
|
|
448
|
|
449 " Normal/global attributes
|
|
450 " For Netscape 4, set <body> attributes too, though, strictly speaking, it's
|
|
451 " incorrect.
|
|
452 if exists("html_use_css")
|
|
453 if exists("html_no_pre")
|
|
454 execute "normal! A\nbody { color: " . s:fgc . "; background-color: " . s:bgc . "; font-family: Courier, monospace; }\e"
|
|
455 else
|
|
456 execute "normal! A\npre { color: " . s:fgc . "; background-color: " . s:bgc . "; }\e"
|
|
457 yank
|
|
458 put
|
|
459 execute "normal! ^cwbody\e"
|
|
460 endif
|
|
461 else
|
|
462 if exists("html_no_pre")
|
|
463 execute '%s:<body>:<body ' . 'bgcolor="' . s:bgc . '" text="' . s:fgc . '" style="font-family\: Courier, monospace;">'
|
|
464 else
|
|
465 execute '%s:<body>:<body ' . 'bgcolor="' . s:bgc . '" text="' . s:fgc . '">'
|
|
466 endif
|
|
467 endif
|
|
468
|
|
469 " Line numbering attributes
|
|
470 if s:numblines
|
|
471 if exists("html_use_css")
|
|
472 execute "normal! A\n.lnr { " . s:CSS1(hlID("LineNr")) . "}\e"
|
|
473 else
|
837
|
474 execute '%s+^<span class="lnr">\([^<]*\)</span>+' . s:HtmlOpening(hlID("LineNr")) . '\1' . s:HtmlClosing(hlID("LineNr")) . '+g'
|
7
|
475 endif
|
|
476 endif
|
|
477
|
|
478 " Gather attributes for all other classes
|
|
479 let s:idlist = strpart(s:idlist, 1)
|
|
480 while s:idlist != ""
|
|
481 let s:attr = ""
|
|
482 let s:col = stridx(s:idlist, ",")
|
|
483 let s:id = strpart(s:idlist, 0, s:col)
|
|
484 let s:idlist = strpart(s:idlist, s:col + 1)
|
|
485 let s:attr = s:CSS1(s:id)
|
|
486 let s:id_name = synIDattr(s:id, "name", s:whatterm)
|
|
487 " If the class has some attributes, export the style, otherwise DELETE all
|
|
488 " its occurences to make the HTML shorter
|
|
489 if s:attr != ""
|
|
490 if exists("html_use_css")
|
|
491 execute "normal! A\n." . s:id_name . " { " . s:attr . "}"
|
|
492 else
|
|
493 execute '%s+<span class="' . s:id_name . '">\([^<]*\)</span>+' . s:HtmlOpening(s:id) . '\1' . s:HtmlClosing(s:id) . '+g'
|
|
494 endif
|
|
495 else
|
|
496 execute '%s+<span class="' . s:id_name . '">\([^<]*\)</span>+\1+g'
|
|
497 if exists("html_use_css")
|
|
498 1;/<style type="text/+1
|
|
499 endif
|
|
500 endif
|
|
501 endwhile
|
|
502
|
|
503 " Add hyperlinks
|
39
|
504 %s+\(https\=://\S\{-}\)\(\([.,;:}]\=\(\s\|$\)\)\|[\\"'<>]\|>\|<\|"\)+<a href="\1">\1</a>\2+ge
|
7
|
505
|
|
506 " The DTD
|
|
507 if exists("html_use_css")
|
39
|
508 if exists("use_xhtml")
|
|
509 exe "normal! gg$a\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\e"
|
|
510 else
|
|
511 exe "normal! gg0i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n\e"
|
|
512 endif
|
|
513 endif
|
|
514
|
856
|
515 if exists("use_xhtml")
|
39
|
516 exe "normal! gg/<html/e\na xmlns=\"http://www.w3.org/1999/xhtml\"\e"
|
7
|
517 endif
|
|
518
|
|
519 " Cleanup
|
|
520 %s:\s\+$::e
|
|
521
|
|
522 " Restore old settings
|
|
523 let &report = s:old_report
|
|
524 let &title = s:old_title
|
|
525 let &icon = s:old_icon
|
|
526 let &paste = s:old_paste
|
|
527 let &magic = s:old_magic
|
|
528 let @/ = s:old_search
|
|
529 exe s:orgwin . "wincmd w"
|
|
530 let &l:et = s:old_et
|
|
531 exe s:newwin . "wincmd w"
|
|
532
|
|
533 " Save a little bit of memory (worth doing?)
|
|
534 unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search
|
|
535 unlet s:whatterm s:idlist s:lnum s:end s:fgc s:bgc s:old_magic
|
34
|
536 unlet! s:col s:id s:attr s:len s:line s:new s:expandedtab s:numblines
|
7
|
537 unlet s:orgwin s:newwin s:orgbufnr
|
170
|
538 if !v:profiling
|
|
539 delfunc s:HtmlColor
|
|
540 delfunc s:HtmlFormat
|
|
541 delfunc s:CSS1
|
|
542 if !exists("html_use_css")
|
|
543 delfunc s:HtmlOpening
|
|
544 delfunc s:HtmlClosing
|
|
545 endif
|
7
|
546 endif
|
836
|
547 silent! unlet s:diffattr s:difffillchar s:foldfillchar s:HtmlSpace s:LeadingSpace s:HtmlEndline
|