Bram Moolenaar, 18.07.2008:
>
> Markus Heidelberg wrote:
>
> > > So how can we bypass this? Splitting s:HtmlFormat() in two
> > > functions, one for conversion of the HTML characters, the other for
> > > generation of the HTML tags? Then we could probably add
> > > s:LeadingSpace between these two function calls.
> >
> > What about this?
>
> Looks a lot better.
>
> Perhaps HtmlFormatTags() could be called HtmlFormatSpan()?
OK, I did it. I also renamed HtmlFormatReserved() to HtmlFormatChars() since
it doesn't only handle HTML reserved characters.
> Not sure if HtmlFormatTags() also need to replace unprintable chars.
Now it's only done in HtmlFormatChars().
It seems as if the replacement of "\x0c" in line 112 doesn't have any effect.
Unprintable characters are already replaced and the class PAGE-BREAK isn't
defined anywhere.
*** 2html.vim.orig 2008-07-17 23:36:24.000000000 +0200
--- 2html.vim 2008-07-19 01:25:03.000000000 +0200
***************
*** 102,110 ****
endfun
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)
" Replace unprintable characters
let formatted = strtrans(a:text)
--- 102,108 ----
endfun
endif
! function! s:HtmlFormatChars(text)
" Replace unprintable characters
let formatted = strtrans(a:text)
***************
*** 117,124 ****
let formatted = substitute(formatted, '^ ', s:HtmlSpace, 'g')
endif
" Enclose in a span of class style_name
! let formatted = '<span class="' . a:style_name . '">' . formatted .
'</span>'
" Add the class to class list if it's not there yet
let s:id = hlID(a:style_name)
--- 115,126 ----
let formatted = substitute(formatted, '^ ', s:HtmlSpace, 'g')
endif
+ return formatted
+ endfun
+
+ function! s:HtmlFormatSpan(text, style_name)
" Enclose in a span of class style_name
! let formatted = '<span class="' . a:style_name . '">' . a:text . '</span>'
" Add the class to class list if it's not there yet
let s:id = hlID(a:style_name)
***************
*** 129,134 ****
--- 131,142 ----
return formatted
endfun
+ " 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)
+ return s:HtmlFormatSpan(s:HtmlFormatChars(a:text), a:style_name)
+ endfun
+
" Return CSS style describing given highlight id (can be empty)
function! s:CSS1(id)
let a = ""
***************
*** 303,314 ****
if s:filler > 0
let s:n = s:filler
while s:n > 0
! if s:numblines
! " Indent if line numbering is on
! let s:new = repeat(s:LeadingSpace, strlen(s:end) + 1) .
repeat(s:difffillchar, 3)
! else
! let s:new = repeat(s:difffillchar, 3)
! endif
if s:n > 2 && s:n < s:filler && !exists("html_whole_filler")
let s:new = s:new . " " . s:filler . " inserted lines "
--- 311,317 ----
if s:filler > 0
let s:n = s:filler
while s:n > 0
! let s:new = repeat(s:difffillchar, 3)
if s:n > 2 && s:n < s:filler && !exists("html_whole_filler")
let s:new = s:new . " " . s:filler . " inserted lines "
***************
*** 320,326 ****
let s:new = s:new . repeat(s:difffillchar, &columns - strlen(s:new))
endif
! let s:new = s:HtmlFormat(s:new, "DiffDelete")
exe s:newwin . "wincmd w"
exe "normal! a" . s:new . s:HtmlEndline . "\n\e"
exe s:orgwin . "wincmd w"
--- 323,336 ----
let s:new = s:new . repeat(s:difffillchar, &columns - strlen(s:new))
endif
! let s:new = s:HtmlFormatChars(s:new)
!
! if s:numblines
! " Indent if line numbering is on
! let s:new = repeat(s:LeadingSpace, strlen(s:end) + 1) . s:new
! endif
!
! let s:new = s:HtmlFormatSpan(s:new, "DiffDelete")
exe s:newwin . "wincmd w"
exe "normal! a" . s:new . s:HtmlEndline . "\n\e"
exe s:orgwin . "wincmd w"
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---