diff --git a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt
index 3d9c7be9364..f2ffddb0842 100644
--- a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt
+++ b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt
@@ -487,7 +487,7 @@ class HtmlParserTest {
}
@Test
- fun testHtmlContent_imageWithText_noAdditionalSpacesAdded() {
+ fun testHtmlContent_imageWithText_imageSpanParsedCorrectly() {
val htmlParser = htmlParserFactory.create(
resourceBucketName,
entityType = "",
@@ -508,9 +508,6 @@ class HtmlParserTest {
val imageSpans = htmlResult.getSpansFromWholeString(ImageSpan::class)
assertThat(imageSpans).hasLength(1)
assertThat(imageSpans.first().source).isEqualTo("test.png")
- // Verify that the image span does not start/end with a space since there is other text present.
- assertThat(htmlResult.toString()).startsWith("A")
- assertThat(htmlResult.toString()).doesNotContain(" ")
}
@Test
diff --git a/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt b/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt
index f08fcfe807a..0dddcacb0ac 100755
--- a/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt
+++ b/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt
@@ -79,13 +79,13 @@ class HtmlParser private constructor(
supportsConceptCards: Boolean = false
): Spannable {
var htmlContent = rawString
+ val regex = Regex("""