Skip to content

Commit be7f70e

Browse files
committed
Gutenberg: don't trim spaces around html tags
1 parent 0e0add0 commit be7f70e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
11371137
val parser = AztecParser(plugins)
11381138

11391139
var cleanSource = CleaningUtils.cleanNestedBoldTags(source)
1140-
cleanSource = Format.removeSourceEditorFormatting(cleanSource, isInCalypsoMode)
1140+
cleanSource = Format.removeSourceEditorFormatting(cleanSource, isInCalypsoMode, isInGutenbergMode)
11411141
builder.append(parser.fromHtml(cleanSource, context))
11421142

11431143
Format.preProcessSpannedText(builder, isInCalypsoMode)
@@ -1547,7 +1547,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
15471547
}
15481548
}
15491549

1550-
val html = Format.removeSourceEditorFormatting(parser.toHtml(output), isInCalypsoMode)
1550+
val html = Format.removeSourceEditorFormatting(parser.toHtml(output), isInCalypsoMode, isInGutenbergMode)
15511551

15521552
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
15531553
clipboard.primaryClip = ClipData.newHtmlText("aztec", output.toString(), html)

aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ object Format {
5050
}
5151

5252
@JvmStatic
53-
fun removeSourceEditorFormatting(html: String, isCalypsoFormat: Boolean = false): String {
53+
fun removeSourceEditorFormatting(html: String, isCalypsoFormat: Boolean = false, isGutenbergMode: Boolean = false): String {
5454
if (isCalypsoFormat) {
5555
val htmlWithoutSourceFormatting = toCalypsoHtml(html)
5656
val doc = Jsoup.parseBodyFragment(htmlWithoutSourceFormatting.replace("\n", "")).outputSettings(Document.OutputSettings().prettyPrint(false))
5757
return doc.body().html()
5858
} else {
59-
return replaceAll(html, "\\s*<(/?($block)(.*?))>\\s*", "<$1>")
59+
return if (isGutenbergMode) { html } else { replaceAll(html, "\\s*<(/?($block)(.*?))>\\s*", "<$1>") }
6060
}
6161
}
6262

0 commit comments

Comments
 (0)