Skip to content

Commit 82cf341

Browse files
author
Mickael Campoy
committed
tipsy#225 clean up
1 parent 460fe86 commit 82cf341

File tree

1 file changed

+3
-18
lines changed
  • html-to-j2html/src/commonMain/kotlin/com/html/to/j2html/common

1 file changed

+3
-18
lines changed

html-to-j2html/src/commonMain/kotlin/com/html/to/j2html/common/Converter.kt

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fun sanitizeWhitespace(text: String): String{
125125

126126
// If we don't detect any newlines we assume unformatted input and leave any excess whitespace in
127127
if ( ! text.contains("\n")){
128-
return text;
128+
return text
129129
}
130130
else {
131131
// if we detect newlines, we strip out the unnecessary whitespace from the inputs
@@ -141,12 +141,10 @@ fun sanitizeWhitespace(text: String): String{
141141

142142
var sanitized = text
143143

144-
// meant to keep " text" as is but change "\n text" into "text"
145144
if(startsWithReturn){
146145
sanitized = sanitized.trimStart('\n', ' ')
147146
}
148147

149-
// meant to keep "text " as is but change "text\n " into "text"
150148
if(endsWithReturnAndMaybeSpace){
151149
sanitized = sanitized.trimEnd('\n', ' ')
152150
}
@@ -160,7 +158,6 @@ fun sanitizeWhitespace(text: String): String{
160158
// pre or pre-wrap set. (Or in XHTML, the xml:space="preserve" attribute.)
161159
sanitized = sanitized.replace("\\s+".toRegex(), " ")
162160

163-
164161
return sanitized
165162

166163
}
@@ -171,10 +168,6 @@ fun printRawHtmlReturnsAndIndents() : Boolean {
171168
return true
172169
}
173170

174-
fun maxCharactersBeforeSwitchingToMultiline(): Int {
175-
return 150
176-
}
177-
178171
fun outputTag(tag: Tag, indentationLevel : Int, tab : String) : String {
179172
var output = ""
180173
if ("comment" == tag.name) {
@@ -396,16 +389,8 @@ private fun outputStringValue(singleTextValue: Boolean, tab: String, indentation
396389
if (!singleTextValue || inWithBlock) {
397390
output += "text("
398391
}
399-
if (false && childString.contains("\n") || childString.length >= maxCharactersBeforeSwitchingToMultiline()) {
400-
// triple quotes if long or several lines
401-
output += "\n"
402-
output += tab.repeat(indentationLevel) + "\"\"\"\n"
403-
output += tab.repeat(indentationLevel)
404-
output += "${escapeSoThatJavaPrintsItLikeItIsInTheInput(childString)}\n"
405-
output += tab.repeat(indentationLevel) + "\"\"\""
406-
} else {
407-
output += "\"${escapeSoThatJavaPrintsItLikeItIsInTheInput(childString)}\""
408-
}
392+
output += "\"${escapeSoThatJavaPrintsItLikeItIsInTheInput(childString)}\""
393+
409394
// closing the text()
410395
if (!singleTextValue || inWithBlock) {
411396
output += ")"

0 commit comments

Comments
 (0)