From dd2fd3812dd0ac325977603e153222dc778d102e Mon Sep 17 00:00:00 2001 From: dece Date: Mon, 13 Dec 2021 15:06:17 +0100 Subject: [PATCH] Gemtext: fix issue with link parsing --- app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt b/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt index ca5c557..959401b 100644 --- a/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt +++ b/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt @@ -55,9 +55,10 @@ private fun parseLine(line: CharBuffer, isPreformatted: Boolean): Line = line.startsWith(">") -> BlockquoteLine(getCharsFrom(line, 1)) line.startsWith("```") -> PreFenceLine(getCharsFrom(line, 3)) line.startsWith("* ") -> ListItemLine(getCharsFrom(line, 2)) - line.startsWith("=>") -> getCharsFrom(line, 2).split(" ", limit = 2) + line.startsWith("=>") -> getCharsFrom(line, 2) + .split(" ", limit = 2) .run { LinkLine(get(0), if (size == 2) get(1) else "") } else -> if (isPreformatted) PreTextLine(line.toString()) else ParagraphLine(line.toString()) } -private fun getCharsFrom(line: CharBuffer, index: Int) = line.substring(index).removePrefix(" ") \ No newline at end of file +private fun getCharsFrom(line: CharBuffer, index: Int) = line.substring(index).trimStart() \ No newline at end of file