" Vim plugin for converting a syntax highlighted file to HTML. " Maintainer: Bram Moolenaar " Last Change: 2003 Apr 06 " Don't do this when: " - when 'compatible' is set " - this plugin was already loaded " - user commands are not available. if !&cp && !exists(":TOhtml") && has("user_commands") command -range=% TOhtml :call Convert2HTML(, ) func Convert2HTML(line1, line2) if a:line2 >= a:line1 let g:html_start_line = a:line1 let g:html_end_line = a:line2 else let g:html_start_line = a:line2 let g:html_end_line = a:line1 endif if !&diff runtime syntax/2html.vim else let winnr = [] windo | if (&diff) | call add(winnr, winbufnr(0)) | endif for window in winnr exe ":" . bufwinnr(window) . "wincmd w" let g:html_start_line = 1 let g:html_end_line = line('$') runtime syntax/2html.vim endfor call Diff2HTML(winnr) endif unlet g:html_start_line unlet g:html_end_line endfunc func Diff2HTML(vars) let bufnr = [] for wind in a:vars let name=bufname(wind) . '.html' if name == '.html' let name='Untitled.html' endif call add(bufnr, bufnr(name)) endfor let html = [] call add(html, '') call add(html, '') call add(html, 'diff') call add(html, '') call add(html, '') call add(html, '') call add(html, '') call add(html, '') call add(html, '') for buf in a:vars call add(html, '') endfor call add(html, '') for buf in bufnr let temp=[] exe ":" . bufwinnr(buf) . 'wincmd w' 1,/?,$d_ let temp=getline(1,'$') call add(html, '') endfor call add(html, '') call add(html, '
'.bufname(buf).'
') let html+=temp call add(html, '
') call add(html, '
') call add(html, '') call add(html, '') let i=1 let name="Diff" . ".html" while filereadable(name) let name = substitute(name, '\d*\.html$', '', '') . i . ".html" let i+=1 endw exe ":new " . name set modifiable call append(0,html) endfunc endif