Skip to content

Commit 8824fee

Browse files
committed
...
1 parent cef255f commit 8824fee

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ KotlinSample
44
.gradle/
55
.idea/
66
out/
7-
.DS_Store
7+
.DS_Store
8+
local.properties

src/main/kotlin/components/Extensions.kt

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package components
22

3-
import StringCare.*
3+
import StringCare.Configuration
4+
import StringCare.Extension
45
import groovy.json.StringEscapeUtils
56
import models.ResourceFile
6-
import org.apache.xerces.dom.DeferredElementImpl
77
import org.gradle.api.Project
88
import org.gradle.api.Task
9-
import org.gradle.api.internal.plugins.DslObject
109
import org.w3c.dom.Document
1110
import org.w3c.dom.Node
1211
import org.xml.sax.InputSource
@@ -202,9 +201,27 @@ fun Node.extractHtml(): String {
202201
val item = this.childNodes.item(i)
203202
val type = item.getType()
204203
when (type) {
205-
StringType.BR -> stringBuilder.append("<br>${item.textContent}</br>")
206-
StringType.I -> stringBuilder.append("<i>${item.textContent}</i>")
207-
StringType.STRONG -> stringBuilder.append("<strong>${item.textContent}</strong>")
204+
StringType.BR -> stringBuilder.append(
205+
"<br>${when {
206+
item.textContent.isNotEmpty() -> item.extractHtml()
207+
else -> ""
208+
}
209+
}</br>"
210+
)
211+
StringType.I -> stringBuilder.append(
212+
"<i>${when {
213+
item.textContent.isNotEmpty() -> item.extractHtml()
214+
else -> ""
215+
}
216+
}</i>"
217+
)
218+
StringType.STRONG -> stringBuilder.append(
219+
"<strong>${when {
220+
item.textContent.isNotEmpty() -> item.extractHtml()
221+
else -> ""
222+
}
223+
}</strong>"
224+
)
208225
StringType.TEXT -> stringBuilder.append(item.textContent)
209226
}
210227

@@ -228,6 +245,3 @@ fun Node.getType(): StringType {
228245
else -> StringType.TEXT
229246
}
230247
}
231-
232-
// [#text:
233-
// ]

0 commit comments

Comments
 (0)