I was able to get a reasonable result by manually merging the body of
the two html files generated into an outer table, but I had an issue
the table wrapping some lines due to lack of width and take the files
out of sync. To workaround, I had to fix the table width's to be large
enough and avoid the wrap. I couldn't find a way to disable wrapping
all together or set automatically based on the longest lines, may be
this is one of those wacky javascript problems to solve. Here is the
template that I came up with (the background color here reflects my
current colorscheme).
<!--HTML template for side by side diff:-->
<html>
<head>
<title>diff</title>
<meta name="Generator" content="Vim/7.2">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#333333" text="#ffffff"><font face="monospace">
<table border="1" width="1600">
<tr>
<td width="700" valign="top">
<!-- First file goes here -->
</td>
<td valign="top">
<!-- Second file goes here -->
</td>
</tr>
</table>
</font>
</body>
</html>
<!--
vim: ft=html
-->
It would be nice to automate this merge. If I end up doing this over
and over, I might cook up a macro/plugin but would love to get ideas
from here.
PS: Make sure you set g:html_whole_filler before running 2html.vim,
otherwise the columns won't sync up.
--
HTH,
Hari
I also expecting this function.
Then I can export html and share to other one see the different without vim.
On Mi, 02 Sep 2009, Hari Krishna Dara wrote:
> I couldn't determine if this was discussed before by searching. I want
> to export the current vimdiff to html, but 2html.vim only exports on
> window at a time. Is there a plugin or a trick to come up with both
> the windows participating in the diff?
Interesting question. A made a simple hack, that will display all
diffed files in a frameset. See
http://www.256bit.org/~chrisbra/patches/Diff.html for the generated
html file
and
http://www.256bit.org/~chrisbra/patches/tohtml_diff.diff for the patch
to tohtml.vim
Frames have the advantaged of beeing relatively simply created, (I
made no changes to syntax/2html.vim) but the disadvantage of not being able
to get synchronized scrolled (except for javascript maybe?)
regards,
Christian
--
Beer & pretzels can't be served at the same time in any bar or restaurant.
[real standing law in North Dakota, United States of America]
On Do, 03 Sep 2009, Hari Krishna Dara wrote:
>
> On Thu, Sep 3, 2009 at 3:59 PM, Christian Brabandt<cbl...@256bit.org> wrote:
> >
> > Hi Hari!
> >
> > On Mi, 02 Sep 2009, Hari Krishna Dara wrote:
> >
> >> I couldn't determine if this was discussed before by searching. I want
> >> to export the current vimdiff to html, but 2html.vim only exports on
> >> window at a time. Is there a plugin or a trick to come up with both
> >> the windows participating in the diff?
> >
> > Interesting question. A made a simple hack, that will display all
> > diffed files in a frameset. See
> > http://www.256bit.org/~chrisbra/patches/Diff.html for the generated
> > html file
> > and
> > http://www.256bit.org/~chrisbra/patches/tohtml_diff.diff for the patch
> > to tohtml.vim
> >
> > Frames have the advantaged of beeing relatively simply created, (I
> > made no changes to syntax/2html.vim) but the disadvantage of not being able
> > to get synchronized scrolled (except for javascript maybe?)
>
> Exactly... I first thought about frames, but didn't consider it for two reasons:
> - synchronization is not possible or straight-forward (as you mentioned above).
> - Copy pasting into a HTML/RTF email is not easy/possible.
Try
http://www.256bit.org/~chrisbra/patches/tohtml_diff1.diff for the patch
and http://www.256bit.org/~chrisbra/patches/Diff2.html for the generated
html file
regards,
Christian
--
It is illegal to take more than three sips of beer at a time while standing.
[real standing law in Texas, United States of America]
I am talking about plugins/tohtml.vim which defines the TOhtml command.
regards,
Christian
I believe the wrapping is a browser issue. Try a different one.
> Also, I would prefer that the script be standalone driving 2html.vim
> (though it would then mean, the generated output is not consumable as
> it is, as it is a standalone html document). That way, it is easier to
> upgrade to newer versions of Vim when this file is changed.
That's what it does.
regards,
Christian
It is since about the 26th of July.
Markus
BTW: New Version of Patch:
http://www.256bit.org/~chrisbra/patches/tohtml_diff2.diff
produced the following html:
http://www.256bit.org/~chrisbra/patches/Diff3.html
(this version shouldn't suffer from wrapping lines in the table
cells).
regards,
Christian
--
ARTHUR: You are indeed brave Sir knight, but the fight is mine.
BLACK KNIGHT: Had enough?
ARTHUR: You stupid bastard. You havn't got any arms left.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
On Sa, 05 Sep 2009, Ben Fritz wrote:
> What version of the patch are you looking at? I can't find the word
> "runtime" at all in the latest patch submitted on the thread.
Why are you looking for the word runtime? I have been talking about
patching tohtml.vim (which you'll also find in the patch). This file
exists in your VIMRUNTIME/plugin directory. But even if you do not
know where it is, you can always do:
#v+
$ find $VIMRUNTIME -type f -name "tohtml.vim"
/home/chrisbra/local/share/vim/vim72/plugin/tohtml.vim
#v-
So for me, I need to patch that particular file. So I do:
#v+
$ cd /home/chrisbra/local/share/vim/vim72/plugin
$ wget http://www.256bit.org/~chrisbra/patches/tohtml_diff2.diff
$ cat tohtml.vim
" Vim plugin for converting a syntax highlighted file to HTML.
" Maintainer: Bram Moolenaar <Br...@vim.org>
" 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(<line1>, <line2>)
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
runtime syntax/2html.vim
unlet g:html_start_line
unlet g:html_end_line
endfunc
endif
$ patch < tohtml_diff2.diff
patching file tohtml.vim
$ cat tohtml.diff
" Vim plugin for converting a syntax highlighted file to HTML.
" Maintainer: Bram Moolenaar <Br...@vim.org>
" 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(<line1>, <line2>)
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, '<html>')
call add(html, '<head>')
call add(html, '<title>diff</title>')
call add(html, '<meta name="Generator" content="Vim/7.2">')
call add(html, '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">')
call add(html, '</head>')
call add(html, '<body bgcolor="#333333" text="#ffffff"><font face="monospace">')
call add(html, '<table border="1" width="100%">')
call add(html, '<tr>')
for buf in a:vars
call add(html, '<th>'.bufname(buf).'</th>')
endfor
call add(html, '</tr><tr>')
for buf in bufnr
let temp=[]
exe ":" . bufwinnr(buf) . 'wincmd w'
1,/<body/d_
$
?</body>?,$d_
let temp=getline(1,'$')
call add(html, '<td nowrap valign="top">')
let html+=temp
call add(html, '</td>')
endfor
call add(html, '</tr>')
call add(html, '</table>')
call add(html, '</font>')
call add(html, '</body>')
call add(html, '</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
#v-
That's it. Now If you are running the :TOhtml command inside a diffed
window, it will automatically create a third buffer with the name
Diff<X>.html (where <X> is any number) and saving that file displays
your diff of all diffed files inside a html table.
It is really simple.
Of course, if you are syncing your $VIMRUNTIME directory, these
changes will get lost and you need to reapply the patch.
regards,
Christian
--
ARTHUR: What are you going to do. bleed on me?
This seems to pop up for time to time, a patch will fix a runtime, but
then the FTP site is not updated. For the Cream build, we always run
the patches, but then copy the FTP runtimes over any in the build
directory.
--
Steve Hall [ digitect dancingpaper com ]
That's very useful and great plugin.
Can we use TOhtml(prams) to do this: chose which file will be generated,
all, both, or only the diff[X].html
If the differed files have a little more lines, it will take long time to
generate.
I don't know wheatear only my slow system have this problem.
Thank you!
On Mo, 07 Sep 2009, Ricky wrote:
> That's very useful and great plugin.
> Can we use TOhtml(prams) to do this: chose which file will be generated,
> all, both, or only the diff[X].html
That does not make much sense, because generating the diff.html file
depends on generating the other html files. Well currently, the other
html files are not valid anymore, cause I remove the top and body part
in order to put the remaining stuff into a table. I should undo this
operation after copying.
> If the differed files have a little more lines, it will take long time to
> generate. I don't know wheatear only my slow system have this
> problem.
That's true, but I don't know a way around this.
regards,
Christian
Version 4 of the patch is available. Changelog:
- Added DTD Definition
- small html changes
- Added small Changelog on top
- Undos the stripping of top and body parts of
each diffed buffer, so they can be saved separately
as html files.
See http://www.256bit.org/~chrisbra/patches/Diff4.html for the result
of diffing tohtml.vim with the current version and
http://www.256bit.org/~chrisbra/patches/Diff4_3parts.html
for the result of diffing 3 Versions (original of tohtml.vim, Version
3 of the patch tohtml.vim.patched2, and the last version of th patch)
I am not sure, how useful this is, but it works ;)
Should I upload it to vim.org or send it for inclusion to Bram? Or do
you think, this isn't actually useful?
regards,
Christian
I notice that at the moment the "Release notes" icon at right of the
gvim-7.2.259.exe line at http://sourceforge.net/projects/cream/files/
links to a .txt file which is served with the MIME type in its
Content-Type header set to "application/octet-stream" instead of the
expected "text/plain". The result is that neither SeaMonkey 2.0pre nor
Konqueror 3.5.10 is willing to display the file. (I don't know what IE
would do, and I expect that Firefox would, like SeaMonkey, propose to
download the file rather than be willing to display it.)
Steve, I don't know if the problem is on your side or on SourceForge's
but if it is theirs, I think you might want to contact them. As a last
resort if they don't fix it and you can't, you might want to copy the
text to a <pre> section in an HTML page or some such.
Best regards,
Tony.
--
"The voters have spoken, the bastards ..."