Gemtext: fix preformatted issue

This commit is contained in:
dece 2022-01-26 19:58:15 +01:00
parent 54db4e17a6
commit 2b694a0bc1

View file

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