diff options
-rw-r--r-- | plugins/base/src/main/kotlin/translators/parseWithNormalisedSpaces.kt | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/plugins/base/src/main/kotlin/translators/parseWithNormalisedSpaces.kt b/plugins/base/src/main/kotlin/translators/parseWithNormalisedSpaces.kt index 4bb60f1a..7bda9d0b 100644 --- a/plugins/base/src/main/kotlin/translators/parseWithNormalisedSpaces.kt +++ b/plugins/base/src/main/kotlin/translators/parseWithNormalisedSpaces.kt @@ -44,7 +44,13 @@ internal fun String.parseHtmlEncodedWithNormalisedSpaces( */ internal fun String.parseWithNormalisedSpaces( renderWhiteCharactersAsSpaces: Boolean -): List<DocTag> = - //parsing it using jsoup is required to get codePoints, otherwise they are interpreted separately, as chars - //But we dont need to do it for java as it is already parsed with jsoup - Jsoup.parseBodyFragment(this).body().wholeText().parseHtmlEncodedWithNormalisedSpaces(renderWhiteCharactersAsSpaces)
\ No newline at end of file +): List<DocTag> { + if (!requiresHtmlEncoding()) { + return parseHtmlEncodedWithNormalisedSpaces(renderWhiteCharactersAsSpaces) + } + // parsing it using jsoup is required to get codePoints, otherwise they are interpreted separately, as chars + // But we dont need to do it for java as it is already parsed with jsoup + return Jsoup.parseBodyFragment(this).body().wholeText().parseHtmlEncodedWithNormalisedSpaces(renderWhiteCharactersAsSpaces) +} + +private fun String.requiresHtmlEncoding(): Boolean = indexOf('&') != -1 |