From 6e5ce58ee15dc7dc12f9107353214079aaed5b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=98=B3?= <775517776@qq.com> Date: Thu, 11 Apr 2024 11:52:15 +0800 Subject: [PATCH] =?UTF-8?q?merlin=E6=96=87=E6=A1=A3=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BA=86yaml=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- merlin/src/main/java/Parse.java | 51 --------------------------------- 1 file changed, 51 deletions(-) diff --git a/merlin/src/main/java/Parse.java b/merlin/src/main/java/Parse.java index 860e2d4..12c4831 100644 --- a/merlin/src/main/java/Parse.java +++ b/merlin/src/main/java/Parse.java @@ -59,14 +59,6 @@ public static Map parse(File file) throws Exception { public static void parseDocsType(Map jsonMap, String fileContent, String fileName) { - String r = ""; - if (fileContent.contains("---")) { - fileContent = fileContent.substring(fileContent.indexOf("---") + 3); - if (fileContent.contains("---")) { - r = fileContent.substring(0, fileContent.indexOf("---")); - fileContent = fileContent.substring(fileContent.indexOf("---") + 3); - } - } Parser parser = Parser.builder().build(); HtmlRenderer renderer = HtmlRenderer.builder().build(); @@ -95,49 +87,6 @@ public static void parseDocsType(Map jsonMap, String fileContent jsonMap.put("h5", h5.text()); jsonMap.put("strong", strong.text()); - Yaml yaml = new Yaml(); - Map ret = yaml.load(r); - String key = ""; - Object value = ""; - - for (Map.Entry entry : ret.entrySet()) { - key = entry.getKey().toLowerCase(Locale.ROOT); - value = entry.getValue(); - if (key.equals("date")) { - //需要处理日期不标准导致的存入ES失败的问题。 - String dateString = ""; - if (value.getClass().getSimpleName().equals("Date")) { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - dateString = format.format(value); - } else { - dateString = value.toString(); - } - Pattern pattern = Pattern.compile("\\D"); //匹配所有非数字 - Matcher matcher = pattern.matcher(dateString); - dateString = matcher.replaceAll("-"); - if (dateString.length() < 10) { - StringBuilder stringBuilder = new StringBuilder(dateString); - if (stringBuilder.charAt(7) != '-') { - stringBuilder.insert(5, "0"); - } - if (stringBuilder.length() < 10) { - stringBuilder.insert(8, "0"); - } - dateString = stringBuilder.toString(); - } - value = dateString; - } - if (key.equals("author") && value instanceof String) { - value = new String[]{value.toString()}; - } - if (key.equals("head")) { - continue; - } - if (key.equals("title")) { - key = "specify"; - } - jsonMap.put(key, value); - } if (jsonMap.containsKey("date")) { jsonMap.put("archives", jsonMap.get("date").toString().substring(0, 7)); }