From 89f33e0b1c56c2c315110fba27e1e5de96076f1a Mon Sep 17 00:00:00 2001 From: gaosong Date: Thu, 8 Sep 2022 20:42:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3=E5=AF=B9?= =?UTF-8?q?=E6=AF=94-=E6=9D=A1=E7=9B=AE=E5=AF=B9=E6=AF=94=E9=AB=98?= =?UTF-8?q?=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jero/modules/compare/utils/DiffUtils.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/utils/DiffUtils.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/utils/DiffUtils.java index 586f01ee6..3f2f2a77c 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/utils/DiffUtils.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/utils/DiffUtils.java @@ -2229,8 +2229,33 @@ public class DiffUtils { } public List getHtmlDiffStr(String text1,String text2){ - text1 = text1.replaceAll("", ""); - text2 = text2.replaceAll("", ""); + Map replaceMap1 = new HashMap<>(); + Map replaceMap2 = new HashMap<>(); + //text1 = text1.replaceAll("", ""); + int startIndex = text1.indexOf(" -1) { + int endIndex = text1.indexOf(">", startIndex); + String subStr = text1.substring(startIndex, endIndex + 1); + String repStr = ""; + text1 = text1.replace(subStr, repStr); + replaceMap1.put(repStr,subStr); + index++; + startIndex = text1.indexOf("", ""); + startIndex = text2.indexOf(" -1) { + int endIndex = text2.indexOf(">", startIndex); + String subStr = text2.substring(startIndex, endIndex + 1); + String repStr = ""; + text2 = text2.replace(subStr, repStr); + replaceMap2.put(repStr,subStr); + index++; + startIndex = text2.indexOf(" diffs = diff_main(text1, text2); //定义输出结果 @@ -2254,6 +2279,12 @@ public class DiffUtils { } } List 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;