修改文档对比-条目对比高亮
This commit is contained in:
+33
-2
@@ -2229,8 +2229,33 @@ public class DiffUtils {
|
||||
}
|
||||
|
||||
public List<String> getHtmlDiffStr(String text1,String text2){
|
||||
text1 = text1.replaceAll("<img.*\\>", "");
|
||||
text2 = text2.replaceAll("<img.*\\>", "");
|
||||
Map<String,String> replaceMap1 = new HashMap<>();
|
||||
Map<String,String> replaceMap2 = new HashMap<>();
|
||||
//text1 = text1.replaceAll("<img.*\\>", "");
|
||||
int startIndex = text1.indexOf("<img");
|
||||
int index = 0;
|
||||
while (startIndex > -1) {
|
||||
int endIndex = text1.indexOf(">", startIndex);
|
||||
String subStr = text1.substring(startIndex, endIndex + 1);
|
||||
String repStr = "<replaceImg_" + index + ">";
|
||||
text1 = text1.replace(subStr, repStr);
|
||||
replaceMap1.put(repStr,subStr);
|
||||
index++;
|
||||
startIndex = text1.indexOf("<img");
|
||||
}
|
||||
|
||||
//text2 = text2.replaceAll("<img.*\\>", "");
|
||||
startIndex = text2.indexOf("<img");
|
||||
index = 0;
|
||||
while (startIndex > -1) {
|
||||
int endIndex = text2.indexOf(">", startIndex);
|
||||
String subStr = text2.substring(startIndex, endIndex + 1);
|
||||
String repStr = "<replaceImg_" + index + ">";
|
||||
text2 = text2.replace(subStr, repStr);
|
||||
replaceMap2.put(repStr,subStr);
|
||||
index++;
|
||||
startIndex = text2.indexOf("<img");
|
||||
}
|
||||
|
||||
LinkedList<Diff> diffs = diff_main(text1, text2);
|
||||
//定义输出结果
|
||||
@@ -2254,6 +2279,12 @@ public class DiffUtils {
|
||||
}
|
||||
}
|
||||
List<String> result =new ArrayList<>();
|
||||
for (String key:replaceMap1.keySet()) {
|
||||
LResultStr = LResultStr.replace(key,replaceMap1.get(key));
|
||||
}
|
||||
for (String key:replaceMap2.keySet()) {
|
||||
RResultStr = RResultStr.replace(key,replaceMap2.get(key));
|
||||
}
|
||||
result.add(LResultStr);
|
||||
result.add(RResultStr);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user