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()) }