From 2b694a0bc19b4e87338a88d0c601d86840d467bd Mon Sep 17 00:00:00 2001 From: dece Date: Wed, 26 Jan 2022 19:58:15 +0100 Subject: [PATCH] Gemtext: fix preformatted issue --- app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt | 4 ++-- 1 file changed, 2 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 5426541..be46b4f 100644 --- a/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt +++ b/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt @@ -55,17 +55,17 @@ fun parseData( /** Parse a single line into a Line object. */ private fun parseLine(line: CharBuffer, isPreformatted: Boolean): Line = when { + line.startsWith("```") -> PreFenceLine(getCharsFrom(line, 3)) + isPreformatted -> PreTextLine(line.toString()) line.startsWith("###") -> TitleLine(3, getCharsFrom(line, 3)) line.startsWith("##") -> TitleLine(2, getCharsFrom(line, 2)) line.startsWith("#") -> TitleLine(1, getCharsFrom(line, 1)) - line.startsWith("```") -> PreFenceLine(getCharsFrom(line, 3)) line.startsWith("* ") -> ListItemLine(getCharsFrom(line, 2)) line.startsWith(">") -> getCharsFrom(line, 1) // eh empty lines in quotes… .run { if (isBlank()) EmptyLine() else BlockquoteLine(this) } line.startsWith("=>") -> getCharsFrom(line, 2) .split(" ", "\t", limit = 2) .run { LinkLine(get(0), if (size == 2) get(1).trimStart() else "") } - isPreformatted -> PreTextLine(line.toString()) line.isEmpty() -> EmptyLine() else -> ParagraphLine(line.toString()) }