diff --git a/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt b/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt index be46b4f..7301d70 100644 --- a/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt +++ b/app/src/main/java/dev/lowrespalmtree/comet/Gemtext.kt @@ -61,8 +61,7 @@ private fun parseLine(line: CharBuffer, isPreformatted: Boolean): Line = line.startsWith("##") -> TitleLine(2, getCharsFrom(line, 2)) line.startsWith("#") -> TitleLine(1, getCharsFrom(line, 1)) 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(">") -> BlockquoteLine(getCharsFrom(line, 1)) line.startsWith("=>") -> getCharsFrom(line, 2) .split(" ", "\t", limit = 2) .run { LinkLine(get(0), if (size == 2) get(1).trimStart() else "") } diff --git a/app/src/main/java/dev/lowrespalmtree/comet/PageAdapter.kt b/app/src/main/java/dev/lowrespalmtree/comet/PageAdapter.kt index 614154a..434a622 100644 --- a/app/src/main/java/dev/lowrespalmtree/comet/PageAdapter.kt +++ b/app/src/main/java/dev/lowrespalmtree/comet/PageAdapter.kt @@ -37,7 +37,7 @@ class PageAdapter(private val listener: ContentAdapterListener) : class Title(val text: String, val level: Int) : ContentBlock() class Link(val url: String, val label: String) : ContentBlock() class Pre(val caption: String, var content: String, var closed: Boolean) : ContentBlock() - class Blockquote(val text: String) : ContentBlock() + class Blockquote(var text: String) : ContentBlock() class ListItem(val text: String) : ContentBlock() } @@ -57,7 +57,6 @@ class PageAdapter(private val listener: ContentAdapterListener) : is EmptyLine -> blocks.add(ContentBlock.Empty) is ParagraphLine -> blocks.add(ContentBlock.Paragraph(line.text)) is LinkLine -> blocks.add(ContentBlock.Link(line.url, line.label)) - is BlockquoteLine -> blocks.add(ContentBlock.Blockquote(line.text)) is ListItemLine -> blocks.add(ContentBlock.ListItem(line.text)) is TitleLine -> blocks.add(ContentBlock.Title(line.text, line.level)) is PreFenceLine -> { @@ -78,6 +77,13 @@ class PageAdapter(private val listener: ContentAdapterListener) : lastBlock.content += line.text + "\n" else Log.e(TAG, "setLines: unexpected preformatted line") + } + } + is BlockquoteLine -> { + if (blocks.isNotEmpty() && blocks.last() is ContentBlock.Blockquote) + (blocks.last() as ContentBlock.Blockquote).text += "\n" + line.text + else + blocks.add(ContentBlock.Blockquote(line.text)) } } currentLine++ diff --git a/app/src/main/res/layout/gemtext_blockquote.xml b/app/src/main/res/layout/gemtext_blockquote.xml index 5ec7b94..30fa5a8 100644 --- a/app/src/main/res/layout/gemtext_blockquote.xml +++ b/app/src/main/res/layout/gemtext_blockquote.xml @@ -1,9 +1,15 @@ - \ No newline at end of file + android:paddingStart="16dp" + android:paddingEnd="16dp"> + +