Skip to content

Commit

Permalink
cleanup : Removed Empty Lines from stripped html
Browse files Browse the repository at this point in the history
  • Loading branch information
neeldoshii committed Mar 19, 2024
1 parent f9536fc commit e2dcf2a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/libanki/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ object Utils {
var s = commentPattern.matcher(inputParam).replaceAll("")
s = stripHTMLScriptAndStyleTags(s)
s = tagPattern.matcher(s).replaceAll("")
return entsToTxt(s)
val cleanEmptyLines = cleanEmptyLines(s)
return entsToTxt(cleanEmptyLines)
}

/**
Expand Down Expand Up @@ -111,6 +112,9 @@ object Utils {
return sb.toString()
}

private fun cleanEmptyLines(input: String): String {
return input.replace(Regex("[\r\n]+"), "\n").trim() // Replace multiple line breaks with a single one and trim whitespace
}
/*
* IDs
* ***********************************************************************************************
Expand Down

0 comments on commit e2dcf2a

Please sign in to comment.