Skip to content

Commit

Permalink
fix: customDeliverLine blank line after content
Browse files Browse the repository at this point in the history
Signed-off-by: qwq233 <[email protected]>
  • Loading branch information
qwq233 committed Apr 2, 2022
1 parent 5ce1ae9 commit f5aeb9f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ plugins {
}

group = "top.qwq2333"
version = "1.0.6"
version = "1.0.7"

repositories {
mavenCentral()
Expand All @@ -49,7 +49,7 @@ dependencies {
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
kotlinOptions.jvmTarget = "1.8"
}

application {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/top/qwq2333/generate/HTMLContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ object HTMLContent {
html.docType = type
html.rootElement.addNamespace("epub", "http://www.idpf.org/2007/ops")
html.rootElement.addNamespace("xml", "http://www.w3.org/XML/1998/namespace")
html.rootElement.element("body").element("div").elements().forEach { it ->
html.rootElement.element("body").element("div").elements().forEach {
it.elements().forEach { element ->
if (element.name == "img") {
if (Utils.isURL(element.attribute("src").value)) {
Expand Down Expand Up @@ -216,13 +216,13 @@ object HTMLContent {
target = String(result.toByteArray())

if (cfg.metadata.customDeliverLine.enable) {
if (cfg.metadata.customDeliverLine.type == Defines.image) {
target = target.replace(
target = if (cfg.metadata.customDeliverLine.type == Defines.image) {
target.replace(
"<hr/>",
Defines.deliverLineImage(Utils.fileExtension(cfg.metadata.customDeliverLine.content))
)
} else {
target = target.replace("<hr/>", Defines.textHTML(cfg.metadata.customDeliverLine.content))
target.replace("<hr/>", Defines.textHTML(cfg.metadata.customDeliverLine.content))
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/top/qwq2333/generate/XMLContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ object XMLContent {
}
}


if (cfg.metadata.customDeliverLine.enable && cfg.metadata.customDeliverLine.type == Defines.image) {
val extension = Utils.fileExtension(cfg.metadata.customDeliverLine.content)

val item = manifest.addElement("item")
item.addAttribute("id", "deliverLine")
.addAttribute("href", "Images/deliverLine.$extension")
}

listOf("author.ttf", "KaiGenGothicTC-Heavy.ttf", "title.ttf").forEach {
manifest.addElement("item")
.addAttribute("id", it)
Expand Down Expand Up @@ -254,7 +263,7 @@ object XMLContent {
}
}

fun genManifestElement(manifest: Element, contents: List<Content>, itemList: MutableList<String>) {
private fun genManifestElement(manifest: Element, contents: List<Content>, itemList: MutableList<String>) {
contents.forEach {
if (it.type != Defines.subContent) {
val item = manifest.addElement("item")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/top/qwq2333/util/Defines.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ object Defines {
"</head><body><div> <p class=\"contents em12\">Table of Contents</p>$element</div></body></html>"

fun contentElement(href: String, title: String): String =
"<p class=\"content\"><a class=\"no-d co20 bold\" href=\"$href\">$title</a></p>"
"<p> </p><p class=\"content\"><a class=\"no-d co20 bold\" href=\"$href\">$title</a></p><p> </p>"

fun textHTML(str: String): String =
"<p>$str</p>"
"<p> </p><p>$str</p><p> </p>"

fun deliverLineImage(extension: String) = "<p><img src=\"../deliverLine.${extension}\" alt=\"\"/></p> "
}
Binary file added template.zip
Binary file not shown.
3 changes: 0 additions & 3 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
#### suppress inspection "SpellCheckingInspection" for whole file
#### suppress inspection "UnusedProperty" for whole file
version.com.charleskorn.kaml..kaml=0.43.0
## # available=0.43.0
version.com.vladsch.flexmark..flexmark-all=0.64.0
version.kotlin=1.6.20-M1
## # available=1.6.20-RC
## # available=1.6.20-RC2
version.org.dom4j..dom4j=2.1.3

0 comments on commit f5aeb9f

Please sign in to comment.