From 531baaccb3f927938b85b10c9a00e49ce3cfcadd Mon Sep 17 00:00:00 2001 From: fisher Date: Fri, 28 Feb 2020 20:44:35 +0800 Subject: [PATCH 1/3] fixed classical novel type --- app/src/main/assets/txtTocRule.json | 126 +++++++++++++++------------- 1 file changed, 66 insertions(+), 60 deletions(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index 4e93e04d7..1304059d0 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -1,62 +1,68 @@ [ - { - "enable": true, - "name": "数字 分隔符 标题名称", - "rule": "^[ \\t]{0,4}\\d{1,5}[\\,\\., 、\\-].{1,30}$", - "serialNumber": 0 - }, - { - "enable": true, - "name": "目录", - "rule": "^[ \\t]{0,4}(?:(?:内容|文章)?简介|前言|序章|楔子|正文(?!完)|[Cc]hapter|[Ss]ection|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": 1 - }, - { - "enable": false, - "name": "目录(不匹配行前空白)", - "rule": "^(?<=\\s)(?:(?:内容|文章)?简介|前言|序章|楔子|正文(?!完)|[Cc]hapter|[Ss]ection|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": 2 - }, - { - "enable": false, - "name": "目录(去简介)", - "rule": "^(?<=\\s)(?:前言|序章|楔子|正文(?!完)|[Cc]hapter|[Ss]ection|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": 3 - }, - { - "enable": false, - "name": "目录(古典小说备用)", - "rule": "^[ \\t]{0,4}(?:前言|序章|楔子|正文(?!完)|[Cc]hapter|[Ss]ection|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|场(?![和合比电是])|篇(?!张))).{0,30}$", - "serialNumber": 4 - }, - { - "enable": true, - "name": "Chapter/Section/Part 序号 标题", - "rule": "^[ \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art)\\s{0,4}\\d{1,4}.{0,30}$", - "serialNumber": 5 - }, - { - "enable": true, - "name": "正文 标题/序号", - "rule": "^[ \\t]{0,4}正文\\s{1,4}.{0,20}$", - "serialNumber": 6 - }, - { - "enable": true, - "name": "特殊符号 序号 标题", - "rule": "^[ \\t]{0,4}[〈〖〔【][第卷][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节][\\.:: \f\t].{0,30}$", - "serialNumber": 7 - }, - { - "enable": true, - "name": "特殊符号 标题", - "rule": "^[ \\t]{0,4}[〈〖〔【☆★].{1,30}[】〕〗〉]?\\s{0,4}$", - "serialNumber": 8 - }, - { - "enable":false, - "name": "特殊符号 标题(不匹配空白字符)", - "rule": "(?<=\\s)[〈〖〔【☆★].{1,30}[】〕〗〉]?\\s{0,4}$", - "serialNumber": 9 - } + { + "enable": true, + "name": "目录", + "rule": "^[ \\t]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", + "serialNumber": 0 + }, + { + "enable": false, + "name": "目录(不匹配行前空白)", + "rule": "^(?<=\\s)(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", + "serialNumber": 1 + }, + { + "enable": false, + "name": "目录(去简介)", + "rule": "^(?<=\\s)(?:前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", + "serialNumber": 2 + }, + { + "enable": false, + "name": "目录(古典、轻小说备用)", + "rule": "^[ \\t]{0,4}(?:前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", + "serialNumber": 3 + }, + { + "enable": true, + "name": "数字 分隔符 标题名称", + "rule": "^[ \\t]{0,4}\\d{1,5}[\\,\\., 、\\-].{1,30}$", + "serialNumber": 4 + }, + { + "enable": true, + "name": "正文 标题/序号", + "rule": "^[ \\t]{0,4}正文\\s{1,4}.{0,20}$", + "serialNumber": 5 + }, + { + "enable": true, + "name": "Chapter/Section/Part 序号 标题", + "rule": "^[ \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art)\\s{0,4}\\d{1,4}.{0,30}$", + "serialNumber": 6 + }, + { + "enable": true, + "name": "特殊符号 序号 标题", + "rule": "^[ \\t]{0,4}[〈〖〔【][第卷][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节][\\.:: \f\t].{0,30}$", + "serialNumber": 7 + }, + { + "enable": true, + "name": "特殊符号 标题", + "rule": "^[ \\t]{0,4}[\\[〈「『〖〔《(【\\(☆★].{1,30}[\\)】)》〕〗』」〉\\]]?\\s{0,4}$", + "serialNumber": 8 + }, + { + "enable":false, + "name": "特殊符号 标题(不匹配空白字符)", + "rule": "^(?<=\\s)[\\[〈「『〖〔《(【\\(☆★].{1,30}[\\)】)》〕〗』」〉\\]]?\\s{0,4}$", + "serialNumber": 9 + }, + { + "enable":false, + "name": "顶格标题", + "rule": "^\\S.{1,20}$", + "serialNumber": 10 + } ] From 39bac049d6d7297bfcc51be9478db312c4f8b3c6 Mon Sep 17 00:00:00 2001 From: fisher Date: Fri, 28 Feb 2020 21:03:47 +0800 Subject: [PATCH 2/3] fixed error text --- app/src/main/res/values/arrays.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index ff1fc875c..bdcdf57eb 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -155,6 +155,6 @@ 系统默认字体 系统衬线字体 - 系统等宽等宽 + 系统等宽字体 \ No newline at end of file From 99cb6ec8fee46f239348d14babd13037d965007c Mon Sep 17 00:00:00 2001 From: Celeter Date: Fri, 28 Feb 2020 23:56:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9UA=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=97=A7=E4=B9=A6=E6=BA=90=E8=BD=AC=E6=8D=A2=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/constant/AppConst.kt | 2 +- .../java/io/legado/app/help/storage/OldRule.kt | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index 3a5b42efe..96cc7567f 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -22,7 +22,7 @@ object AppConst { const val UA_NAME = "User-Agent" val userAgent: String by lazy { - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36" + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" } val SCRIPT_ENGINE: ScriptEngine by lazy { diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index c8036e559..7696bb383 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -100,15 +100,22 @@ object OldRule { if (oldRule.isNullOrBlank()) return null var newRule = oldRule var reverse = false + var allinone = false if (oldRule.startsWith("-")) { reverse = true newRule = oldRule.substring(1) } + if (newRule.startsWith("+")) { + allinone = true + newRule = newRule.substring(1) + } if (!newRule.startsWith("@CSS:", true) && !newRule.startsWith("@XPath:", true) && !newRule.startsWith("//") && !newRule.startsWith("##") && - !newRule.startsWith(":") + !newRule.startsWith(":") && + !newRule.contains("@js:",true) && + !newRule.contains("",true) ) { if (newRule.contains("#") && !newRule.contains("##")) { newRule = oldRule.replace("#", "##") @@ -134,8 +141,11 @@ object OldRule { newRule = newRule.replace("&", "&&") } } + if (allinone) { + newRule = "+" + newRule + } if (reverse) { - newRule += "-" + newRule = "-" + newRule } return newRule } @@ -145,7 +155,7 @@ object OldRule { if (!oldUrls.contains("\n") && !oldUrls.contains("&&")) return toNewUrl(oldUrls) - val urls = oldUrls.split("(&&|\n)+".toRegex()) + val urls = oldUrls.split("(&&|\r?\n)+".toRegex()) return urls.map { toNewUrl(it)?.replace("\n\\s*".toRegex(), "") }.joinToString("\n")