diff --git a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/HtmlParser.kt b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/HtmlParser.kt index 1f132b3..e43ab24 100644 --- a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/HtmlParser.kt +++ b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/HtmlParser.kt @@ -99,6 +99,25 @@ internal class HtmlParser { exitTagCloseIndex } + "blockquote" -> { + if (tagContent.isNotEmpty() && nestingLevel < 3) { + var lastIndex = 0 + val trimmedTagContent = tagContent.trim() + builder.appendText("> ") + iterateSearchIndex { searchIndex -> + lastIndex = searchIndex + parseHtmlTags(trimmedTagContent, searchIndex, builder, nestingLevel = nestingLevel + 1) + } + + if (lastIndex < trimmedTagContent.length) { + builder.appendText(trimmedTagContent.substring(lastIndex)) + } + } + + builder.appendNewline() + exitTagCloseIndex + } + "p" -> { if (tagContent.isNotEmpty() && nestingLevel < 2) { var lastIndex = 0 diff --git a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/PartBuilder.kt b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/PartBuilder.kt index abc30ae..2cbf4e1 100644 --- a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/PartBuilder.kt +++ b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/message/PartBuilder.kt @@ -10,8 +10,6 @@ internal class PartBuilder { private val parts = mutableListOf() fun appendText(value: String) { - println("append text") - normalBuffer.append(value.cleanFirstTextLine()) } diff --git a/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RichMessageParserTest.kt b/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RichMessageParserTest.kt index 72b07a2..e910a07 100644 --- a/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RichMessageParserTest.kt +++ b/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RichMessageParserTest.kt @@ -84,6 +84,11 @@ class RichMessageParserTest { expected = RichText(listOf(Normal("Hello world!\nnext line\nanother line"))) ) + @Test + fun `parses blockquote tags`() = runParserTest( + input = "
\n

hello world

\n
\n", + expected = RichText(listOf(Normal("> "), Bold("hello"), Normal(" "), Italic("world"))) + ) @Test fun `parses lists`() = runParserTest(