]> granicus.if.org Git - vim/commitdiff
Updated runtime files. :TOhtml improvements by Benjamin Fritz.
authorBram Moolenaar <Bram@vim.org>
Thu, 29 Jul 2010 18:43:36 +0000 (20:43 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 29 Jul 2010 18:43:36 +0000 (20:43 +0200)
runtime/autoload/tohtml.vim
runtime/doc/pi_netrw.txt
runtime/doc/syntax.txt
runtime/doc/todo.txt
runtime/indent/vb.vim
runtime/plugin/tohtml.vim
runtime/syntax/2html.vim

index 620c9c35022753689e38f0b7e899a158e9efb1cc..55399a788e4aec48c865d4e1c7009715cdd83ada 100644 (file)
@@ -1,6 +1,6 @@
 " Vim autoload file for the tohtml plugin.
 " Maintainer: Ben Fritz <fritzophrenic@gmail.com>
-" Last Change: 2010 July 24
+" Last Change: 2010 Jul 29
 "
 " Additional contributors:
 "
@@ -39,7 +39,6 @@ func! tohtml#Convert2HTML(line1, line2)
       let g:html_diff_win_num += 1
       runtime syntax/2html.vim
       call add(buf_list, bufnr('%'))
-      "exec '%s#<span id=''\zsfold\d\+\ze''#win'.win_num.'\0#ge'
     endfor
     unlet g:html_diff_win_num
     if !save_hwf
@@ -56,7 +55,9 @@ endfunc
 
 func! tohtml#Diff2HTML(win_list, buf_list)
   " TODO: add logic for xhtml
-  let style = []
+  let style = ['-->']
+  let body_line = ''
+
   let html = []
   call add(html, '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"')
   call add(html, '  "http://www.w3.org/TR/html4/loose.dtd">')
@@ -69,6 +70,7 @@ func! tohtml#Diff2HTML(win_list, buf_list)
   " validate without warnings about encoding
 
   call add(html, '</head>')
+  let body_line_num = len(html)
   call add(html, '<body>')
   call add(html, '<table border="1" width="100%">')
 
@@ -78,6 +80,9 @@ func! tohtml#Diff2HTML(win_list, buf_list)
   endfor
   call add(html, '</tr><tr>')
 
+  let diff_style_start = 0
+  let insert_index = 0
+
   for buf in a:buf_list
     let temp = []
     exe bufwinnr(buf) . 'wincmd w'
@@ -86,13 +91,40 @@ func! tohtml#Diff2HTML(win_list, buf_list)
     " to act on everything in a fold by mistake.
     setlocal nofoldenable
 
+    " When not using CSS or when using xhtml, the <body> line can be important.
+    " Assume it will be the same for all buffers and grab it from the first
+    " buffer. Similarly, need to grab the body end line as well.
+    if body_line == ''
+      1
+      call search('<body')
+      let body_line = getline('.')
+      $
+      call search('</body>', 'b')
+      let s:body_end_line = getline('.')
+    endif
+
     " Grab the style information.  Some of this will be duplicated...
     1
     let style_start = search('^<style type="text/css">')
     1
     let style_end = search('^</style>')
     if style_start > 0 && style_end > 0
-      let style += getline(style_start + 1, style_end - 1)
+      let buf_styles = getline(style_start + 1, style_end - 1)
+      for a_style in buf_styles
+       if index(style, a_style) == -1
+         if diff_style_start == 0
+           if a_style =~ '\<Diff\(Change\|Text\|Add\|Delete\)'
+             let diff_style_start = len(style)-1
+           endif
+         endif
+         call insert(style, a_style, insert_index)
+         let insert_index += 1
+       endif
+      endfor
+    endif
+
+    if diff_style_start != 0
+      let insert_index = diff_style_start
     endif
 
     " Delete those parts that are not needed so
@@ -115,9 +147,11 @@ func! tohtml#Diff2HTML(win_list, buf_list)
     quit!
   endfor
 
+  let html[body_line_num] = body_line
+
   call add(html, '</tr>')
   call add(html, '</table>')
-  call add(html, '</body>')
+  call add(html, s:body_end_line)
   call add(html, '</html>')
 
   let i = 1
index ec6c139857addc710934ccf719aeb0ed679728b9..ec3404f5fc6e863c1097aa6ae0b4924353d6f458 100644 (file)
@@ -1,4 +1,4 @@
-*pi_netrw.txt*  For Vim version 7.3c.  Last change: 2010 Jul 27
+*pi_netrw.txt*  For Vim version 7.3c.  Last change: 2010 Jul 28
 
            -----------------------------------------------------
            NETRW REFERENCE MANUAL    by Charles E. Campbell, Jr.
@@ -316,20 +316,20 @@ settings are described below, in |netrw-browser-options|, and in
 |netrw-externapp|:
 
  *b:netrw_lastfile*    last file Network-read/written retained on a
-                       per-buffer basis (supports plain :Nw )
+                     per-buffer basis (supports plain :Nw )
 
  *g:netrw_bufsettings* the settings that netrw buffers have
-                       (default) noma nomod nonu nowrap ro nobl
+                     (default) noma nomod nonu nowrap ro nobl
 
  *g:netrw_chgwin*      specifies a window number where file edits will take
-                       place.  (also see |netrw-C|)
-                       (default) not defined
+                     place.  (also see |netrw-C|)
+                     (default) not defined
 
  *g:Netrw_funcref*     specifies a function (or functions) to be called when
-                       netrw edits a file.  The file is first edited, and
-                       then the function reference (|Funcref|) is called.
-                       This variable may also hold a |List| of Funcrefs.
-                       (default) not defined
+                     netrw edits a file.  The file is first edited, and
+                     then the function reference (|Funcref|) is called.
+                     This variable may also hold a |List| of Funcrefs.
+                     (default) not defined
 >
                            Example: place in .vimrc; affects all file opening
                            fun! MyFuncRef()
@@ -337,74 +337,74 @@ settings are described below, in |netrw-browser-options|, and in
                            let g:Netrw_funcref= function("MyFuncRef")
 <
  *g:netrw_ftp*         if it doesn't exist, use default ftp
-                       =0 use default ftp                     (uid password)
-                       =1 use alternate ftp method       (user uid password)
-                       If you're having trouble with ftp, try changing the
-                       value of this variable to see if the alternate ftp
-                       method works for your setup.
+                     =0 use default ftp                       (uid password)
+                     =1 use alternate ftp method         (user uid password)
+                     If you're having trouble with ftp, try changing the
+                     value of this variable to see if the alternate ftp
+                     method works for your setup.
 
  *g:netrw_ftpextracmd* default: doesn't exist
-                        If this variable exists, then any string it contains
-                       will be placed into the commands set to your ftp
-                       client.  As an example:
-                         ="passive"
+                     If this variable exists, then any string it contains
+                     will be placed into the commands set to your ftp
+                     client.  As an example:
+                       ="passive"
 
  *g:netrw_ftpmode*     ="binary"                                   (default)
-                       ="ascii"
+                     ="ascii"
 
  *g:netrw_ignorenetrc* =0 (default for linux, cygwin)
-                       =1 If you have a <.netrc> file but it doesn't work and
-                          you want it ignored, then set this variable as
-                          shown. (default for Windows + cmd.exe)
+                     =1 If you have a <.netrc> file but it doesn't work and
+                        you want it ignored, then set this variable as
+                        shown. (default for Windows + cmd.exe)
 
  *g:netrw_menu*                =0 disable netrw's menu
-                       =1 (default) netrw's menu enabled
+                     =1 (default) netrw's menu enabled
 
  *g:netrw_nogx*                if this variable exists, then the "gx" map will not
-                       be available (see |netrw-gx|)
+                     be available (see |netrw-gx|)
 
  *g:netrw_uid*         (ftp) user-id,      retained on a per-vim-session basis
  *s:netrw_passwd*      (ftp) password,     retained on a per-vim-session basis
 
  *g:netrw_preview*     =0 (default) preview window shown in a horizontally
-                           split window
-                       =1 preview window shown in a vertically split window.
-                       Also affects the "previous window" (see |netrw-P|) in
-                       the same way.
+                         split window
+                     =1 preview window shown in a vertically split window.
+                     Also affects the "previous window" (see |netrw-P|) in
+                     the same way.
 
  *g:netrw_scpport*      = "-P" : option to use to set port for scp
  *g:netrw_sshport*      = "-p" : option to use to set port for ssh
 
  *g:netrw_sepchr*      =\0xff
-                       =\0x01 for enc == euc-jp (and perhaps it should be for
+                     =\0x01 for enc == euc-jp (and perhaps it should be for
                                                  others, too, please let me
                                                  know)
-                       Separates priority codes from filenames internally.
-                       See |netrw-p12|.
+                     Separates priority codes from filenames internally.
+                     See |netrw-p12|.
 
   *g:netrw_silent*     =0 : transfers done normally
-                       =1 : transfers done silently
+                     =1 : transfers done silently
 
  *g:netrw_use_errorwindow* =1 : messages from netrw will use a separate one
-                                line window.  This window provides reliable
-                               delivery of messages. (default)
-                          =0 : messages from netrw will use echoerr ;
-                               messages don't always seem to show up this
-                               way, but one doesn't have to quit the window.
+                              line window.  This window provides reliable
+                             delivery of messages. (default)
+                        =0 : messages from netrw will use echoerr ;
+                             messages don't always seem to show up this
+                             way, but one doesn't have to quit the window.
 
  *g:netrw_win95ftp*    =1 if using Win95, will remove four trailing blank
-                          lines that o/s's ftp "provides" on transfers
-                       =0 force normal ftp behavior (no trailing line removal)
+                        lines that o/s's ftp "provides" on transfers
+                     =0 force normal ftp behavior (no trailing line removal)
 
  *g:netrw_cygwin*      =1 assume scp under windows is from cygwin. Also
-                          permits network browsing to use ls with time and
-                          size sorting (default if windows)
-                       =0 assume Windows' scp accepts windows-style paths
-                          Network browsing uses dir instead of ls
-                       This option is ignored if you're using unix
+                        permits network browsing to use ls with time and
+                        size sorting (default if windows)
+                     =0 assume Windows' scp accepts windows-style paths
+                        Network browsing uses dir instead of ls
+                     This option is ignored if you're using unix
 
  *g:netrw_use_nt_rcp*  =0 don't use the rcp of WinNT, Win2000 and WinXP
-                       =1 use WinNT's rcp in binary mode         (default)
+                     =1 use WinNT's rcp in binary mode         (default)
 
 PATHS                                                  *netrw-path* {{{2
 
@@ -598,7 +598,7 @@ password.
 PASSWORD                                               *netrw-passwd*
 
 The script attempts to get passwords for ftp invisibly using |inputsecret()|,
-a built-in Vim function.  See |netrw-uidpass| for how to change the password
+a built-in Vim function.  See |netrw-userpass| for how to change the password
 after one has set it.
 
 Unfortunately there doesn't appear to be a way for netrw to feed a password to
@@ -809,12 +809,12 @@ temporary file:
        open machine [port]                    open machine [port]
        user userid password                   userid password
        [g:netrw_ftpmode]                      password
-       [g:netrw_extracmd]                     [g:netrw_ftpmode]
+       [g:netrw_ftpextracmd]                  [g:netrw_ftpmode]
        get filename tempfile                  [g:netrw_extracmd]
                                               get filename tempfile >
   ---------------------------------------------------------------------
 <
-The |g:netrw_ftpmode| and |g:netrw_extracmd| are optional.
+The |g:netrw_ftpmode| and |g:netrw_ftpextracmd| are optional.
 
 Netrw then executes the lines above by use of a filter:
 >
index 73e7404053358200b00caacb37f32e8e6500241d..399eed3eba534f44b639b887415191b72140a07e 100644 (file)
@@ -431,7 +431,7 @@ shorter and valid HTML 4 file), use: >
 Concealed text is removed from the HTML and replaced with the appropriate
 character from |:syn-cchar| or 'listchars' depending on the current value of
 'conceallevel'. If you always want to display all text in your document,
-either set 'conceallevel' to before invoking 2html, or use: >
+either set 'conceallevel' to zero before invoking 2html, or use: >
    :let g:html_ignore_conceal = 1
 
 Similarly, closed folds are put in the HTML as they are displayed.  If you
index 743eaf73628bc6ec0c19d76530dc57596b980fb3..66bbf5dc431f04578058749ffebf7c9e029b4cb7 100644 (file)
@@ -33,6 +33,7 @@ be worked on, but only if you sponsor Vim development.  See |sponsor|.
 Patch for :filetype completion. (Dominique Pelle, Jul 28)
 
 Windows 7: "Open with..." menu starts Vim without a file.
+Need to use other registry methods in if_ole.cpp?
 
 Windows 7: installing Vim again doesn't find the previously installed Vim.
 
index 5f386f79109b211fe3f2154e8246a612e6dda42a..55a8ea302aee3d72de7b1b43f720ca7b1a8a4193 100644 (file)
@@ -48,7 +48,7 @@ fun! VbGetIndent(lnum)
     let ind = indent(lnum)
 
     " Add
-    if previous_line =~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)\s\+\)\=\%(function\|sub\|property\)\|select\|case\|default\|if\>.\{-}\<then\>\s*$\|else\|elseif\|do\|for\|while\|enum\|with\)\>'
+    if previous_line =~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)\s\+\)\=\%(function\|sub\|property\)\|select\|case\|default\|if\|else\|elseif\|do\|for\|while\|enum\|with\)\>'
        let ind = ind + &sw
     endif
 
index 867b85d40d59c290bf324186171fcd3f7591807a..5ef59ca5ad32f14150f09dac520eef77fdbcce71 100644 (file)
@@ -1,14 +1,22 @@
 " Vim plugin for converting a syntax highlighted file to HTML.
 " Maintainer: Ben Fritz <fritzophrenic@gmail.com>
-" Last Change: 2010 July 24
+" Last Change: 2010 Jul 28
 "
 " The core of the code is in $VIMRUNTIME/autoload/tohtml.vim and
 " $VIMRUNTIME/syntax/2html.vim
+"
+" TODO:
+"   * Diff mode with xhtml gives invalid markup
+"   * Diff mode does not determine encoding
+"   * Line number column has one character too few on empty lines
+"     without CSS.
+"   * Add extra meta info (generation time, etc.)
+"   * TODO comments for code cleanup scattered throughout
 
 if exists('g:loaded_2html_plugin')
   finish
 endif
-let g:loaded_2html_plugin = 'vim7.3_v1'
+let g:loaded_2html_plugin = 'vim7.3_v2'
 
 " Define the :TOhtml command when:
 " - 'compatible' is not set
index 5094433cd6452990192c5de605749750e2de41ca..cf4620e9e01def1dcadcc6793794cffb2a88d412 100644 (file)
@@ -1,6 +1,6 @@
 " Vim syntax support file
 " Maintainer: Ben Fritz <fritzophrenic@gmail.com>
-" Last Change: 2010 July 24
+" Last Change: 2010 Jul 28
 "
 " Additional contributors:
 "
@@ -129,10 +129,14 @@ endif
 
 " Return HTML valid characters enclosed in a span of class style_name with
 " unprintable characters expanded and double spaces replaced as necessary.
-function! s:HtmlFormat(text, style_name)
+function! s:HtmlFormat(text, style_name, diff_style_name)
   " Replace unprintable characters
   let formatted = strtrans(a:text)
 
+  " separate the two classes by a space to apply them both if there is a diff
+  " style name
+  let l:style_name = a:style_name . (a:diff_style_name == '' ? '' : ' ') . a:diff_style_name
+
   " Replace the reserved html characters
   let formatted = substitute(substitute(substitute(substitute(substitute(formatted, '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g')
 
@@ -143,12 +147,26 @@ function! s:HtmlFormat(text, style_name)
   endif
 
   " Enclose in a span of class style_name
-  let formatted = '<span class="' . a:style_name . '">' . formatted . '</span>'
+  let formatted = '<span class="' . l:style_name . '">' . formatted . '</span>'
 
-  " Add the class to class list if it's not there yet
+  " Add the class to class list if it's not there yet.
+  " Add normal groups to the beginning so diff groups can override them.
   let s:id = hlID(a:style_name)
-  if stridx(s:idlist, "," . s:id . ",") == -1
-    let s:idlist = s:idlist . s:id . ","
+  if index(s:idlist, s:id ) == -1
+    if a:style_name =~ 'Diff\%(Add\|Change\|Delete\|Text\)'
+      call add(s:idlist, s:id)
+    else
+      call insert(s:idlist, s:id)
+    endif
+  endif
+  
+  " Add the diff highlight class to class list if used and it's not there yet.
+  " Add diff groups to the end so they override the other highlighting.
+  if a:diff_style_name != ""
+    let s:diff_id = hlID(a:diff_style_name)
+    if index(s:idlist, s:diff_id) == -1
+      call add(s:idlist, s:diff_id)
+    endif
   endif
 
   return formatted
@@ -437,7 +455,7 @@ endif
 exe s:orgwin . "wincmd w"
 
 " List of all id's
-let s:idlist = ","
+let s:idlist = []
 
 " set up progress bar in the status line
 if !s:html_no_progress && has("statusline")
@@ -702,7 +720,7 @@ while s:lnum <= s:end
        let s:new = s:new . repeat(s:difffillchar, 3)
       endif
 
-      let s:new = s:HtmlFormat(s:new, "DiffDelete")
+      let s:new = s:HtmlFormat(s:new, "DiffDelete", "")
       if s:numblines
        " Indent if line numbering is on; must be after escaping.
        let s:new = repeat(s:LeadingSpace, s:margin) . s:new
@@ -734,7 +752,7 @@ while s:lnum <= s:end
       let s:new = s:new . repeat(s:foldfillchar, &columns - strlen(s:new))
     endif
 
-    let s:new = s:HtmlFormat(s:new, "Folded")
+    let s:new = s:HtmlFormat(s:new, "Folded", "")
 
     " Skip to the end of the fold
     let s:new_lnum = foldclosedend(s:lnum)
@@ -807,7 +825,7 @@ while s:lnum <= s:end
 
        " add fold text, moving the span ending to the next line so collapsing
        " of folds works correctly
-       let s:new = s:new . substitute(s:HtmlFormat(s:numcol . foldtextresult(s:lnum), "Folded"), '</span>', s:HtmlEndline.'\n\0', '')
+       let s:new = s:new . substitute(s:HtmlFormat(s:numcol . foldtextresult(s:lnum), "Folded", ""), '</span>', s:HtmlEndline.'\n\0', '')
        let s:new = s:new . "<span class='fulltext'>"
 
        " open the fold now that we have the fold text to allow retrieval of
@@ -827,7 +845,7 @@ while s:lnum <= s:end
          " add the empty foldcolumn for unfolded lines if there is a fold
          " column at all
          if s:foldcolumn > 0
-           let s:new = s:new . s:HtmlFormat(repeat(' ', s:foldcolumn), "FoldColumn")
+           let s:new = s:new . s:HtmlFormat(repeat(' ', s:foldcolumn), "FoldColumn", "")
          endif
        else
          " add the fold column for folds not on the opening line
@@ -842,7 +860,8 @@ while s:lnum <= s:end
 
     " Now continue with the unfolded line text
     if s:numblines
-      let s:new = s:new . s:HtmlFormat(s:numcol, "lnr")
+      " TODO: why not use the real highlight name here?
+      let s:new = s:new . s:HtmlFormat(s:numcol, "lnr", "")
     endif
 
     " Get the diff attribute, if any.
@@ -853,6 +872,11 @@ while s:lnum <= s:end
 
     " Loop over each character in the line
     let s:col = 1
+
+    " most of the time we won't use the diff_id, initialize to zero
+    let s:diff_id = 0
+    let s:diff_id_name = ""
+
     while s:col <= s:len || (s:col == 1 && s:diffattr)
       let s:startcol = s:col " The start column for processing text
       if !exists('g:html_ignore_conceal') && has('conceal')
@@ -866,13 +890,18 @@ while s:lnum <= s:end
        " characters.
        while s:col <= s:len && s:concealinfo == synconcealed(s:lnum, s:col) | let s:col = s:col + 1 | endwhile
       elseif s:diffattr
-       let s:id = diff_hlID(s:lnum, s:col)
+       let s:diff_id = diff_hlID(s:lnum, s:col)
+       let s:id = synID(s:lnum, s:col, 1)
        let s:col = s:col + 1
        " Speed loop (it's small - that's the trick)
        " Go along till we find a change in hlID
-       while s:col <= s:len && s:id == diff_hlID(s:lnum, s:col) | let s:col = s:col + 1 | endwhile
+       while s:col <= s:len && s:id == synID(s:lnum, s:col, 1)
+             \   && s:diff_id == diff_hlID(s:lnum, s:col) |
+             \     let s:col = s:col + 1 |
+             \ endwhile
        if s:len < &columns && !exists("g:html_no_pre")
-         " Add spaces at the end to mark the changed line.
+         " Add spaces at the end of the raw text line to extend the changed
+         " line to the full width.
          let s:line = s:line . repeat(' ', &columns - virtcol([s:lnum, s:len]) - s:margin)
          let s:len = &columns
        endif
@@ -913,6 +942,9 @@ while s:lnum <= s:end
        " get the highlight group name to use
        let s:id = synIDtrans(s:id)
        let s:id_name = synIDattr(s:id, "name", s:whatterm)
+       if s:diff_id
+         let s:diff_id_name = synIDattr(s:diff_id, "name", s:whatterm)
+       endif
       else
        " use Conceal highlighting for concealed text
        let s:id_name = 'Conceal'
@@ -920,9 +952,9 @@ while s:lnum <= s:end
       endif
 
       " Output the text with the same synID, with class set to {s:id_name},
-      " unless it has been concealed completely. Always output empty lines.
+      " unless it has been concealed completely.
       if strlen(s:expandedtab) > 0
-       let s:new = s:new . s:HtmlFormat(s:expandedtab,  s:id_name)
+       let s:new = s:new . s:HtmlFormat(s:expandedtab,  s:id_name, s:diff_id_name)
       endif
     endwhile
   endif
@@ -948,18 +980,18 @@ if exists("g:html_dynamic_folds")
 
   " add fold column to the style list if not already there
   let s:id = hlID('FoldColumn')
-  if stridx(s:idlist, "," . s:id . ",") == -1
-    let s:idlist = s:idlist . s:id . ","
+  if index(s:idlist, s:id) == -1
+    call insert(s:idlist, s:id)
   endif
 endif
 
-" Close off the font tag that encapsulates the whole <body>
-if !exists("g:html_use_css")
-  let s:lines[-1].="</font>"
-endif
-
 if exists("g:html_no_pre")
-  call extend(s:lines, ["</body>", "</html>"])
+  if !exists("g:html_use_css")
+    " Close off the font tag that encapsulates the whole <body>
+    call extend(s:lines, ["</font></body>", "</html>"])
+  else
+    call extend(s:lines, ["</body>", "</html>"])
+  endif
 else
   call extend(s:lines, ["</pre>", "</body>", "</html>"])
 endif
@@ -1009,9 +1041,6 @@ if s:numblines
 endif
 
 " Gather attributes for all other classes
-let s:idlist_str = s:idlist
-unlet s:idlist
-let s:idlist = split(s:idlist_str, ',')
 if !s:html_no_progress && !empty(s:idlist)
   let s:pgb = s:ProgressBar("Processing classes:", len(s:idlist),s:newwin)
 endif
@@ -1027,12 +1056,18 @@ while !empty(s:idlist)
     if exists("g:html_use_css")
       execute "normal! A\n." . s:id_name . " { " . s:attr . "}"
     else
-      execute '%s+<span class="' . s:id_name . '">\([^<]*\)</span>+' . s:HtmlOpening(s:id) . '\1' . s:HtmlClosing(s:id) . '+g'
+      " replace spans of just this class name with non-CSS style markup
+      execute '%s+<span class="' . s:id_name . '">\([^<]*\)</span>+' . s:HtmlOpening(s:id) . '\1' . s:HtmlClosing(s:id) . '+ge'
+      " Replace spans of this class name AND a diff class with non-CSS style
+      " markup surrounding a span of just the diff class. The diff class will
+      " be handled later because we know that information is at the end.
+      execute '%s+<span class="' . s:id_name . ' \(Diff\%(Add\|Change\|Delete\|Text\)\)">\([^<]*\)</span>+' . s:HtmlOpening(s:id) . '<span class="\1">\2</span>' . s:HtmlClosing(s:id) . '+ge'
     endif
   else
     execute '%s+<span class="' . s:id_name . '">\([^<]*\)</span>+\1+ge'
+    execute '%s+<span class="' . s:id_name . ' \(Diff\%(Add\|Change\|Delete\|Text\)\)">\([^<]*\)</span>+<span class="\1">\2</span>+ge'
     if exists("g:html_use_css")
-      1;/<style type="text/+1
+      1;/<\/style>/-2
     endif
   endif
 
@@ -1045,7 +1080,6 @@ while !empty(s:idlist)
     endif
   endif
 endwhile
-unlet s:idlist_str
 
 " Add hyperlinks
 %s+\(https\=://\S\{-}\)\(\([.,;:}]\=\(\s\|$\)\)\|[\\"'<>]\|&gt;\|&lt;\|&quot;\)+<a href="\1">\1</a>\2+ge