1
1
package components
2
2
3
- import StringCare.*
3
+ import StringCare.Configuration
4
+ import StringCare.Extension
4
5
import groovy.json.StringEscapeUtils
5
6
import models.ResourceFile
6
- import org.apache.xerces.dom.DeferredElementImpl
7
7
import org.gradle.api.Project
8
8
import org.gradle.api.Task
9
- import org.gradle.api.internal.plugins.DslObject
10
9
import org.w3c.dom.Document
11
10
import org.w3c.dom.Node
12
11
import org.xml.sax.InputSource
@@ -202,9 +201,27 @@ fun Node.extractHtml(): String {
202
201
val item = this .childNodes.item(i)
203
202
val type = item.getType()
204
203
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
+ )
208
225
StringType .TEXT -> stringBuilder.append(item.textContent)
209
226
}
210
227
@@ -228,6 +245,3 @@ fun Node.getType(): StringType {
228
245
else -> StringType .TEXT
229
246
}
230
247
}
231
-
232
- // [#text:
233
- // ]
0 commit comments