生成文本视图';Python中的修订历史

生成文本视图';Python中的修订历史,python,diff,history,revision,Python,Diff,History,Revision,我有一段文本的两个版本,我想生成一个类似于GoogleDocs或StackOverflow显示的版本的HTML视图。我需要用Python来做这件事。我不知道这项技术叫什么,但我假设它有一个名称,希望有一个Python库可以做到这一点 第1版: 威廉·亨利“比尔”盖茨三世(生于 1955年10月28日[2]是美国人 商业巨头、慈善家和 微软公司董事长[3],该软件 他和保罗·艾伦共同创立的公司 第2版: 威廉·亨利“比尔”盖茨三世(生于 1955年10月28日)[2]是一家企业 大亨、慈善家和 微

我有一段文本的两个版本,我想生成一个类似于GoogleDocs或StackOverflow显示的版本的HTML视图。我需要用Python来做这件事。我不知道这项技术叫什么,但我假设它有一个名称,希望有一个Python库可以做到这一点

第1版:

威廉·亨利“比尔”盖茨三世(生于 1955年10月28日[2]是美国人 商业巨头、慈善家和 微软公司董事长[3],该软件 他和保罗·艾伦共同创立的公司

第2版:

威廉·亨利“比尔”盖茨三世(生于 1955年10月28日)[2]是一家企业 大亨、慈善家和 微软公司董事长[3],该软件 他和保罗·艾伦共同创立的公司。 他是美国人

所需输出:

威廉·亨利“比尔”盖茨三世(生于 1955年10月28日[2]是一家美国企业 大亨、慈善家和 微软公司董事长[3],该软件 他和保罗·艾伦共同创立的公司。 他是美国人

使用diff命令不起作用,因为它告诉我哪些行不同,而不是哪些列/字不同

$ echo 'William Henry "Bill" Gates III (born October 28, 1955)[2] is an American business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen.' > oldfile
$ echo 'William Henry "Bill" Gates III (born October 28, 1955)[2] is a business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen.  He is American.' > newfile
$ diff -u oldfile newfile
--- oldfile 2010-04-30 13:32:43.000000000 -0700
+++ newfile 2010-04-30 13:33:09.000000000 -0700
@@ -1 +1 @@
-William Henry "Bill" Gates III (born October 28, 1955)[2] is an American business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen.
+William Henry "Bill" Gates III (born October 28, 1955)[2] is a business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen.  He is American.' > oldfile
你可以用。我不知道是否有Python实现:

$ wdiff oldfile newfile
William Henry "Bill" Gates III (born October 28, 1955)[2] is [-an American-] {+a+} business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen.  {+He is American.+}
在纯python中有一个相当好的diff实现。

该模块可能有助于解决此问题