From 217a144bbf2ecbab75fab66922ea39dc385b5b81 Mon Sep 17 00:00:00 2001 From: fisher Date: Wed, 30 Sep 2020 22:16:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=BC=98=E5=8C=96=20?= =?UTF-8?q?=E5=A4=A7=E5=86=99=E6=95=B0=E5=AD=97=E6=94=AF=E6=8C=81=E7=95=AA?= =?UTF-8?q?=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/txtTocRule.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index 127f5648f..832009b20 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -38,7 +38,7 @@ "id": -6, "enable": true, "name": "数字 分隔符 标题名称", - "rule": "^[  \\t]{0,4}\\d{1,5}[,., 、_—\\-].{1,30}$", + "rule": "^[  \\t]{0,4}\\d{1,5}[::,., 、_—\\-].{1,30}$", "serialNumber": 5 }, { From 2a0f52f1749427f59972ee934a49a1a0fdd29a52 Mon Sep 17 00:00:00 2001 From: fisher Date: Wed, 30 Sep 2020 22:19:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A4=A7=E5=86=99=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=95=AA=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/txtTocRule.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index 832009b20..4469235a2 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -45,7 +45,7 @@ "id": -7, "enable": true, "name": "大写数字 分隔符 标题名称", - "rule": "^[  \\t]{0,4}[零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}[ 、_—\\-].{1,30}$", + "rule": "^[  \\t]{0,4}(?:序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|[零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[ 、_—\\-].{1,30}$", "serialNumber": 6 }, { From b2d4352ab81f1ecaa7cf22ab05fe41d67e692acd Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 1 Oct 2020 07:46:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/model/analyzeRule/AnalyzeRule.kt | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 0086a6e57..8cd9937f5 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -447,46 +447,45 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { else -> rule = ruleStr } } - if (mode == Mode.Js) { - ruleType.add(defaultRuleType) - ruleParam.add(rule) - } else { - //分离put - rule = splitPutRule(rule, putMap) - //@get,{{ }}, 拆分 - var start = 0 - var tmp: String - val evalMatcher = evalPattern.matcher(rule) - while (evalMatcher.find()) { - if (evalMatcher.start() > start) { - tmp = rule.substring(start, evalMatcher.start()) - if (start == 0 && !tmp.contains("##")) { - mode = Mode.Regex - } - splitRegex(tmp) - } else if (evalMatcher.start() == 0) { + //分离put + rule = splitPutRule(rule, putMap) + //@get,{{ }}, 拆分 + var start = 0 + var tmp: String + val evalMatcher = evalPattern.matcher(rule) + while (evalMatcher.find()) { + if (evalMatcher.start() > start) { + tmp = rule.substring(start, evalMatcher.start()) + if (mode != Mode.Js && mode != Mode.Json && mode != Mode.Regex + && start == 0 && !tmp.contains("##") + ) { mode = Mode.Regex } - tmp = evalMatcher.group() - when { - tmp.startsWith("@get:", true) -> { - ruleType.add(getRuleType) - ruleParam.add(tmp.substring(6, tmp.lastIndex)) - } - tmp.startsWith("{{") -> { - ruleType.add(jsRuleType) - ruleParam.add(tmp.substring(2, tmp.length - 2)) - } - else -> { - splitRegex(tmp) - } - } - start = evalMatcher.end() - } - if (rule.length > start) { - tmp = rule.substring(start) splitRegex(tmp) + } else if (mode != Mode.Js && mode != Mode.Json && mode != Mode.Regex + && evalMatcher.start() == 0 + ) { + mode = Mode.Regex + } + tmp = evalMatcher.group() + when { + tmp.startsWith("@get:", true) -> { + ruleType.add(getRuleType) + ruleParam.add(tmp.substring(6, tmp.lastIndex)) + } + tmp.startsWith("{{") -> { + ruleType.add(jsRuleType) + ruleParam.add(tmp.substring(2, tmp.length - 2)) + } + else -> { + splitRegex(tmp) + } } + start = evalMatcher.end() + } + if (rule.length > start) { + tmp = rule.substring(start) + splitRegex(tmp) } } @@ -499,7 +498,9 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { val ruleStrArray = ruleStr.split("##") val regexMatcher = regexPattern.matcher(ruleStrArray[0]) while (regexMatcher.find()) { - mode = Mode.Regex + if (mode != Mode.Js && mode != Mode.Regex) { + mode = Mode.Regex + } if (regexMatcher.start() > start) { tmp = ruleStr.substring(start, regexMatcher.start()) ruleType.add(defaultRuleType)