Don't think of mangadex chapter names as markdown (#18434)
* fix an edge case on chapter name cleaner maybe closes https://github.com/tachiyomiorg/tachiyomi-extensions/issues/18407 * forgot about alt titles * update javadoc to match the function usage
This commit is contained in:
parent
1d28b6dc89
commit
1c8478fcca
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'MangaDex'
|
extName = 'MangaDex'
|
||||||
pkgNameSuffix = 'all.mangadex'
|
pkgNameSuffix = 'all.mangadex'
|
||||||
extClass = '.MangaDexFactory'
|
extClass = '.MangaDexFactory'
|
||||||
extVersionCode = 188
|
extVersionCode = 189
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,12 +143,19 @@ class MangaDexHelper(lang: String) {
|
||||||
(MDConstants.latestChapterLimit * (page - 1)).toString()
|
(MDConstants.latestChapterLimit * (page - 1)).toString()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove any HTML characters in description or chapter name to actual
|
* Remove any HTML characters in manga or chapter name to actual
|
||||||
* characters. For example ♥ will show ♥. It also removes
|
* characters. For example ♥ will show ♥.
|
||||||
* Markdown syntax for links, italic and bold.
|
*/
|
||||||
|
private fun String.removeEntities(): String {
|
||||||
|
return Parser.unescapeEntities(this, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove any HTML characters in description to actual characters.
|
||||||
|
* It also removes Markdown syntax for links, italic and bold.
|
||||||
*/
|
*/
|
||||||
private fun String.removeEntitiesAndMarkdown(): String {
|
private fun String.removeEntitiesAndMarkdown(): String {
|
||||||
return Parser.unescapeEntities(this, false)
|
return removeEntities()
|
||||||
.substringBefore("---")
|
.substringBefore("---")
|
||||||
.replace(markdownLinksRegex, "$1")
|
.replace(markdownLinksRegex, "$1")
|
||||||
.replace(markdownItalicBoldRegex, "$1")
|
.replace(markdownItalicBoldRegex, "$1")
|
||||||
|
@ -284,7 +291,7 @@ class MangaDexHelper(lang: String) {
|
||||||
?: mangaDataDto.attributes.altTitles
|
?: mangaDataDto.attributes.altTitles
|
||||||
.find { (it[lang] ?: it["en"]) !== null }
|
.find { (it[lang] ?: it["en"]) !== null }
|
||||||
?.values?.singleOrNull() // find something else from alt titles
|
?.values?.singleOrNull() // find something else from alt titles
|
||||||
title = dirtyTitle?.removeEntitiesAndMarkdown().orEmpty()
|
title = dirtyTitle?.removeEntities().orEmpty()
|
||||||
|
|
||||||
coverFileName?.let {
|
coverFileName?.let {
|
||||||
thumbnail_url = when (!coverSuffix.isNullOrEmpty()) {
|
thumbnail_url = when (!coverSuffix.isNullOrEmpty()) {
|
||||||
|
@ -359,7 +366,7 @@ class MangaDexHelper(lang: String) {
|
||||||
if (altTitles.isNotEmpty()) {
|
if (altTitles.isNotEmpty()) {
|
||||||
val altTitlesDesc = altTitles
|
val altTitlesDesc = altTitles
|
||||||
.joinToString("\n", "${intl["alternative_titles"]}\n") { "• $it" }
|
.joinToString("\n", "${intl["alternative_titles"]}\n") { "• $it" }
|
||||||
desc += (if (desc.isBlank()) "" else "\n\n") + altTitlesDesc.removeEntitiesAndMarkdown()
|
desc += (if (desc.isBlank()) "" else "\n\n") + altTitlesDesc.removeEntities()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +434,7 @@ class MangaDexHelper(lang: String) {
|
||||||
|
|
||||||
return SChapter.create().apply {
|
return SChapter.create().apply {
|
||||||
url = "/chapter/${chapterDataDto.id}"
|
url = "/chapter/${chapterDataDto.id}"
|
||||||
name = chapterName.joinToString(" ").removeEntitiesAndMarkdown()
|
name = chapterName.joinToString(" ").removeEntities()
|
||||||
date_upload = parseDate(attr.publishAt)
|
date_upload = parseDate(attr.publishAt)
|
||||||
scanlator = groups
|
scanlator = groups
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue