1
0
forked from aniani/vim

Updates for :TOhtml. (Benjamin Fritz)

This commit is contained in:
Bram Moolenaar
2010-08-13 11:30:02 +02:00
parent 2f1e050414
commit 8df7f88890
3 changed files with 33 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
" Vim autoload file for the tohtml plugin. " Vim autoload file for the tohtml plugin.
" Maintainer: Ben Fritz <fritzophrenic@gmail.com> " Maintainer: Ben Fritz <fritzophrenic@gmail.com>
" Last Change: 2010 Aug 06 " Last Change: 2010 Aug 12
" "
" Additional contributors: " Additional contributors:
" "
@@ -52,6 +52,11 @@ func! tohtml#Diff2HTML(win_list, buf_list)
let xml_line = "" let xml_line = ""
let tag_close = '>' let tag_close = '>'
let s:old_paste = &paste
set paste
let s:old_magic = &magic
set magic
if s:settings.use_xhtml if s:settings.use_xhtml
if s:settings.encoding != "" if s:settings.encoding != ""
let xml_line = "<?xml version=\"1.0\" encoding=\"" . s:settings.encoding . "\"?>" let xml_line = "<?xml version=\"1.0\" encoding=\"" . s:settings.encoding . "\"?>"
@@ -250,6 +255,9 @@ func! tohtml#Diff2HTML(win_list, buf_list)
\ ]) \ ])
endif endif
endif endif
let &paste = s:old_paste
let &magic = s:old_magic
endfunc endfunc
" Gets a single user option and sets it in the passed-in Dict, or gives it the " Gets a single user option and sets it in the passed-in Dict, or gives it the

View File

@@ -1,22 +1,23 @@
" Vim plugin for converting a syntax highlighted file to HTML. " Vim plugin for converting a syntax highlighted file to HTML.
" Maintainer: Ben Fritz <fritzophrenic@gmail.com> " Maintainer: Ben Fritz <fritzophrenic@gmail.com>
" Last Change: 2010 Aug 07 " Last Change: 2010 Aug 12
" "
" The core of the code is in $VIMRUNTIME/autoload/tohtml.vim and " The core of the code is in $VIMRUNTIME/autoload/tohtml.vim and
" $VIMRUNTIME/syntax/2html.vim " $VIMRUNTIME/syntax/2html.vim
" "
" TODO: " TODO:
" * Bug: error thrown when nowrapscan is set " * Restore open/closed folds and cursor position after processing each file
" * Line number column has one character too few on empty lines " with option not to restore for speed increase
" without CSS.
" * Add extra meta info (generation time, etc.) " * Add extra meta info (generation time, etc.)
" * Tidy up so we can use strict doctype more? " * Tidy up so we can use strict doctype more?
" * Implementation detail: add threshold for writing the lines to the html
" buffer before we're done (5000 or so lines should do it)
" * TODO comments for code cleanup scattered throughout " * TODO comments for code cleanup scattered throughout
if exists('g:loaded_2html_plugin') if exists('g:loaded_2html_plugin')
finish finish
endif endif
let g:loaded_2html_plugin = 'vim7.3_v4' let g:loaded_2html_plugin = 'vim7.3_v6'
" Define the :TOhtml command when: " Define the :TOhtml command when:
" - 'compatible' is not set " - 'compatible' is not set

View File

@@ -1,6 +1,6 @@
" Vim syntax support file " Vim syntax support file
" Maintainer: Ben Fritz <fritzophrenic@gmail.com> " Maintainer: Ben Fritz <fritzophrenic@gmail.com>
" Last Change: 2010 Aug 07 " Last Change: 2010 Aug 12
" "
" Additional contributors: " Additional contributors:
" "
@@ -126,10 +126,11 @@ function! s:HtmlFormat(text, style_name, diff_style_name)
" Replace the reserved html characters " 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') let formatted = substitute(substitute(substitute(substitute(substitute(formatted, '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g')
" Replace double spaces and leading spaces " Replace double spaces, leading spaces, and trailing spaces if needed
if ' ' != s:HtmlSpace if ' ' != s:HtmlSpace
let formatted = substitute(formatted, ' ', s:HtmlSpace . s:HtmlSpace, 'g') let formatted = substitute(formatted, ' ', s:HtmlSpace . s:HtmlSpace, 'g')
let formatted = substitute(formatted, '^ ', s:HtmlSpace, 'g') let formatted = substitute(formatted, '^ ', s:HtmlSpace, 'g')
let formatted = substitute(formatted, ' \+$', s:HtmlSpace, 'g')
endif endif
" Enclose in a span of class style_name " Enclose in a span of class style_name
@@ -201,9 +202,11 @@ endif
" Set some options to make it work faster. " Set some options to make it work faster.
" Don't report changes for :substitute, there will be many of them. " Don't report changes for :substitute, there will be many of them.
" Don't change other windows; turn off scroll bind temporarily
let s:old_title = &title let s:old_title = &title
let s:old_icon = &icon let s:old_icon = &icon
let s:old_et = &l:et let s:old_et = &l:et
let s:old_bind = &l:scrollbind
let s:old_report = &report let s:old_report = &report
let s:old_search = @/ let s:old_search = @/
let s:old_more = &more let s:old_more = &more
@@ -211,6 +214,7 @@ set notitle noicon
setlocal et setlocal et
set nomore set nomore
set report=1000000 set report=1000000
setlocal noscrollbind
if exists(':ownsyntax') && exists('w:current_syntax') if exists(':ownsyntax') && exists('w:current_syntax')
let s:current_syntax = w:current_syntax let s:current_syntax = w:current_syntax
@@ -247,7 +251,9 @@ let s:newwin_stl = &l:stl
" on the new window, set the least time-consuming fold method " on the new window, set the least time-consuming fold method
let s:old_fdm = &foldmethod let s:old_fdm = &foldmethod
let s:old_fen = &foldenable
setlocal foldmethod=manual setlocal foldmethod=manual
setlocal nofoldenable
let s:newwin = winnr() let s:newwin = winnr()
let s:orgwin = bufwinnr(s:orgbufnr) let s:orgwin = bufwinnr(s:orgbufnr)
@@ -327,7 +333,7 @@ if s:settings.use_css
\ ".closed-fold:hover > .toggle-filler { display: none; }", \ ".closed-fold:hover > .toggle-filler { display: none; }",
\ ".closed-fold:hover > .Folded { display: none; }", \ ".closed-fold:hover > .Folded { display: none; }",
\ s:settings.use_xhtml ? "" : '-->', \ s:settings.use_xhtml ? "" : '-->',
\ '<style>']) \ '</style>'])
" TODO: IE7 doesn't *actually* support XHTML, maybe we should remove this. " TODO: IE7 doesn't *actually* support XHTML, maybe we should remove this.
" But if it's served up as tag soup, maybe the following will work, so " But if it's served up as tag soup, maybe the following will work, so
" leave it in for now. " leave it in for now.
@@ -1055,6 +1061,7 @@ endif
%s:\s\+$::e %s:\s\+$::e
" Restore old settings " Restore old settings
let &l:foldenable = s:old_fen
let &l:foldmethod = s:old_fdm let &l:foldmethod = s:old_fdm
let &report = s:old_report let &report = s:old_report
let &title = s:old_title let &title = s:old_title
@@ -1065,6 +1072,7 @@ let @/ = s:old_search
let &more = s:old_more let &more = s:old_more
exe s:orgwin . "wincmd w" exe s:orgwin . "wincmd w"
let &l:et = s:old_et let &l:et = s:old_et
let &l:scrollbind = s:old_bind
exe s:newwin . "wincmd w" exe s:newwin . "wincmd w"
exec 'resize' s:old_winheight exec 'resize' s:old_winheight
let &l:winfixheight = s:old_winfixheight let &l:winfixheight = s:old_winfixheight
@@ -1075,10 +1083,12 @@ let &ls=s:ls
" Save a little bit of memory (worth doing?) " Save a little bit of memory (worth doing?)
unlet s:htmlfont unlet s:htmlfont
unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search s:old_magic s:old_more s:old_fdm s:old_winheight s:old_winfixheight unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search
unlet s:whatterm s:idlist s:lnum s:end s:margin s:fgc s:bgc unlet s:old_magic s:old_more s:old_fdm s:old_fen s:old_winheight
unlet s:whatterm s:idlist s:lnum s:end s:margin s:fgc s:bgc s:old_winfixheight
unlet! s:col s:id s:attr s:len s:line s:new s:expandedtab s:concealinfo unlet! s:col s:id s:attr s:len s:line s:new s:expandedtab s:concealinfo
unlet! s:orgwin s:newwin s:orgbufnr s:idx s:i s:offset s:ls s:origwin_stl s:newwin_stl s:current_syntax unlet! s:orgwin s:newwin s:orgbufnr s:idx s:i s:offset s:ls s:origwin_stl
unlet! s:newwin_stl s:current_syntax
if !v:profiling if !v:profiling
delfunc s:HtmlColor delfunc s:HtmlColor
delfunc s:HtmlFormat delfunc s:HtmlFormat
@@ -1099,7 +1109,8 @@ if !v:profiling
endif endif
endif endif
unlet! s:new_lnum s:diffattr s:difffillchar s:foldfillchar s:HtmlSpace s:LeadingSpace s:HtmlEndline s:firstfold s:foldcolumn unlet! s:new_lnum s:diffattr s:difffillchar s:foldfillchar s:HtmlSpace
unlet! s:LeadingSpace s:HtmlEndline s:firstfold s:foldcolumn
unlet s:foldstack s:allfolds s:foldId s:numcol s:settings unlet s:foldstack s:allfolds s:foldId s:numcol s:settings
let &cpo = s:cpo_sav let &cpo = s:cpo_sav