0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00

[Kotlin Migration] HtmlUtils

Package: com.ichi2.utils
This commit is contained in:
codingtosh 2021-11-07 01:42:52 +05:30 committed by Mike Hardy
parent 527131bb96
commit c55b5d9cb4
2 changed files with 14 additions and 19 deletions

View File

@ -43,7 +43,7 @@ permission notice:
// Example of class name: "/com/ichi2/anki/UIUtils.kt"
// Ensure that it starts with '/' (slash)
def source = Source.MAIN
def className = "/com/ichi2/utils/HtmlUtils.kt"
def className = ""
enum Source {
MAIN("/src/main/java"),

View File

@ -13,29 +13,24 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ichi2.utils
package com.ichi2.utils;
import android.text.TextUtils
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class HtmlUtils {
//#5188 - compat.fromHtml converts newlines into spaces.
@Nullable
public static String convertNewlinesToHtml(@Nullable String html) {
object HtmlUtils {
// #5188 - compat.fromHtml converts newlines into spaces.
@JvmStatic
fun convertNewlinesToHtml(html: String?): String? {
if (html == null) {
return null;
return null
}
String withoutWindowsLineEndings = html.replace("\r\n", "<br/>");
//replace unix line endings
return withoutWindowsLineEndings.replace("\n", "<br/>");
val withoutWindowsLineEndings = html.replace("\r\n", "<br/>")
// replace unix line endings
return withoutWindowsLineEndings.replace("\n", "<br/>")
}
@NonNull
public static String escape(@NonNull String html) {
return TextUtils.htmlEncode(html);
@JvmStatic
fun escape(html: String): String {
return TextUtils.htmlEncode(html)
}
}