From 7cf4ad2a09e4153ef78b9c47801192bd1871484c Mon Sep 17 00:00:00 2001 From: wangzhijiang <1358525938@qq.com> Date: Thu, 21 Mar 2024 10:36:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E6=96=87=E5=AF=B9=E6=AF=94=E5=A4=84?= =?UTF-8?q?=E7=90=86=E8=A1=A8=E6=A0=BC=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jero/modules/compare/utils/DiffUtils.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/compare/utils/DiffUtils.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/compare/utils/DiffUtils.java index 3f2f2a7..a3f7773 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/compare/utils/DiffUtils.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/compare/utils/DiffUtils.java @@ -2231,6 +2231,8 @@ public class DiffUtils { public List getHtmlDiffStr(String text1,String text2){ Map replaceMap1 = new HashMap<>(); Map replaceMap2 = new HashMap<>(); + Map replaceMap3 = new HashMap<>(); + Map replaceMap4 = 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); + replaceMap3.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); + replaceMap4.put(repStr,subStr); + index++; + startIndex = text2.indexOf(" diffs = diff_main(text1, text2); //定义输出结果 String LResultStr=""; @@ -2285,6 +2312,12 @@ public class DiffUtils { for (String key:replaceMap2.keySet()) { RResultStr = RResultStr.replace(key,replaceMap2.get(key)); } + for (String key:replaceMap3.keySet()) { + LResultStr = LResultStr.replace(key,replaceMap3.get(key)); + } + for (String key:replaceMap4.keySet()) { + RResultStr = RResultStr.replace(key,replaceMap4.get(key)); + } result.add(LResultStr); result.add(RResultStr); return result;