diff 到 html (diff2html) 程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/641055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 23:26:11  来源:igfitidea点击:

diff to html (diff2html) program

htmldiff

提问by blueyed

I'm looking for a "diff to html" program, which would generate a static html page from a given diff/patch file.

我正在寻找一个“diff to html”程序,它可以从给定的 diff/patch 文件生成一个静态 html 页面。

I've googled for it of course, but apart from some scripts I've found there's no "real project" (e.g. no package in Debian/Ubuntu).

我当然用谷歌搜索过它,但除了我发现的一些脚本之外,没有“真正的项目”(例如 Debian/Ubuntu 中没有包)。

Have I missed something? Can you recommend anything?

我错过了什么吗?你能推荐什么吗?

回答by zer0

You can use diff2html.pythat is able to create a side-by-side diff in a static html page, from an unified diff input. The script is written in python.

您可以使用diff2html.py,它能够从统一的差异输入在静态 html 页面中创建并排差异。该脚本是用python编写的。

cat foo.diff | python diff2html.py > foo.html

回答by puetzk

pygmentshas syntax highlighting for diff (and for lots of other languages), and can be used as a library or a command-line program. Is that the sort of thing you're looking for? If not please clarify the question...

pygments具有针对 diff(以及许多其他语言)的语法高亮显示,并且可以用作库或命令行程序。这就是你要找的东西吗?如果不是,请澄清问题...

回答by Daniel Zinn

Something along the lines of:

类似的东西:

vim test.diff -c TOhtml -c ":saveas test.html" -c ":q" -c ":q"

works well, and you can change the color-scheme of the diff by changing the color scheme in vi.

效果很好,您可以通过在 vi 中更改配色方案来更改差异的配色方案。

回答by austin cheney

Have you tried http://prettydiff.com/as it ignores differences in white space and comments.

您是否尝试过http://prettydiff.com/,因为它忽略了空白和注释的差异。

[Disclaimer: this is my site]

[免责声明:这是我的网站]

回答by Daniel Hershcovich

There's also 2htmlin Vim, which works very well, and it's built-in: it takes a file that Vim knows how to highlight its syntax, and creates an HTML with the correct formatting. To use it, just open the wanted file with Vim, and source the 2html script. It will open the converted file in a new buffer, which can be saved. Here:

Vim 中还有2html,它工作得很好,而且它是内置的:它需要一个 Vim 知道如何突出显示其语法的文件,并创建一个具有正确格式的 HTML。要使用它,只需用 Vim 打开想要的文件,并获取 2html 脚本。它将在可以保存的新缓冲区中打开转换后的文件。这里:

vim example.diff

and then in Vim,

然后在 Vim 中,

:so /usr/share/vim/vim72/syntax/2html.vim
:wqa

回答by ashawley

I use htmlizein Emacs. Doesn't come with Emacs, and assumes you're using Emacs. Relies on the syntax highlighting of Emacs's Diff mode. Only good for doing one file at a time. Does the right thingfor me.

我在 Emacs 中使用htmlize。不随 Emacs 一起提供,并假设您使用的是 Emacs。依赖于 Emacs 的 Diff 模式的语法高亮。只适合一次处理一个文件。 为我做正确的事

回答by Andy Longwill

The best I've found that produces nice side-by-side diffs is this script:

我发现产生很好的并排差异的最好的是这个脚本:

http://tools.ietf.org/tools/rfcdiff/

http://tools.ietf.org/tools/rfcdiff/

Although it's designed to be used on RFCs it works with any text file.

尽管它被设计用于 RFC,但它适用于任何文本文件。

This project also has nice output, but I'm not sure if it can be used without subversion: http://code.google.com/p/coderev/

这个项目也有很好的输出,但我不确定它是否可以在没有颠覆的情况下使用:http: //code.google.com/p/coderev/

回答by ren

I found coderev, demo looks nice

我找到了coderev,演示看起来不错