perf(novel-crawl): 去除小说内容末尾的所有换行

This commit is contained in:
xiongxiaoyang 2025-06-21 12:32:11 +08:00
parent 24abe7714f
commit adc83db64e

View File

@ -238,6 +238,8 @@ public class CrawlParser {
}
}
}
// 去除小说内容末尾的所有换行
content = removeTrailingBrTags(content);
//插入章节目录和章节内容
BookIndex bookIndex = new BookIndex();
bookIndex.setIndexName(indexName);
@ -314,4 +316,12 @@ public class CrawlParser {
return false;
}
/**
* 删除字符串末尾的所有 <br> 类似标签允许各种空格
*/
public static String removeTrailingBrTags(String str) {
return str.replaceAll("(?i)(?:\\s*<\\s*br\\s*/?\\s*>)++(?:\\s|\\u3000)*$", "");
}
}