mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Set br softbreak to html parser.
This commit is contained in:
parent
f24b593349
commit
bbc3dc0504
2 changed files with 14 additions and 10 deletions
|
@ -47,7 +47,7 @@ class MarkdownParserTest : InstrumentedTest {
|
||||||
*/
|
*/
|
||||||
private val markdownParser = MarkdownParser(
|
private val markdownParser = MarkdownParser(
|
||||||
Parser.builder().build(),
|
Parser.builder().build(),
|
||||||
HtmlRenderer.builder().build(),
|
HtmlRenderer.builder().softbreak("<br />").build(),
|
||||||
TextPillsUtils(MentionLinkSpecComparator())
|
TextPillsUtils(MentionLinkSpecComparator())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -147,12 +147,14 @@ class MarkdownParserTest : InstrumentedTest {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO. Improve testTypeNewLines function to cover <pre><code class="language-code">test</code></pre>
|
||||||
@Test
|
@Test
|
||||||
fun parseCodeNewLines() {
|
fun parseCodeNewLines_not_passing() {
|
||||||
testTypeNewLines(
|
testTypeNewLines(
|
||||||
name = "code",
|
name = "code",
|
||||||
markdownPattern = "`",
|
markdownPattern = "```",
|
||||||
htmlExpectedTag = "code"
|
htmlExpectedTag = "code",
|
||||||
|
softBreak = "\n"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +168,7 @@ class MarkdownParserTest : InstrumentedTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun parseCode2NewLines() {
|
fun parseCode2NewLines_not_passing() {
|
||||||
testTypeNewLines(
|
testTypeNewLines(
|
||||||
name = "code",
|
name = "code",
|
||||||
markdownPattern = "``",
|
markdownPattern = "``",
|
||||||
|
@ -184,7 +186,7 @@ class MarkdownParserTest : InstrumentedTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun parseCode3NewLines() {
|
fun parseCode3NewLines_not_passing() {
|
||||||
testTypeNewLines(
|
testTypeNewLines(
|
||||||
name = "code",
|
name = "code",
|
||||||
markdownPattern = "```",
|
markdownPattern = "```",
|
||||||
|
@ -246,7 +248,7 @@ class MarkdownParserTest : InstrumentedTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun parseBoldNewLines_not_passing() {
|
fun parseBoldNewLines2() {
|
||||||
"**bold**\nline2".let { markdownParser.parse(it).expect(it, "<strong>bold</strong><br />line2") }
|
"**bold**\nline2".let { markdownParser.parse(it).expect(it, "<strong>bold</strong><br />line2") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,13 +339,14 @@ class MarkdownParserTest : InstrumentedTest {
|
||||||
|
|
||||||
private fun testTypeNewLines(name: String,
|
private fun testTypeNewLines(name: String,
|
||||||
markdownPattern: String,
|
markdownPattern: String,
|
||||||
htmlExpectedTag: String) {
|
htmlExpectedTag: String,
|
||||||
|
softBreak: String = "<br />") {
|
||||||
// With new line inside the block
|
// With new line inside the block
|
||||||
"$markdownPattern$name\n$name$markdownPattern"
|
"$markdownPattern$name\n$name$markdownPattern"
|
||||||
.let {
|
.let {
|
||||||
markdownParser.parse(it)
|
markdownParser.parse(it)
|
||||||
.expect(expectedText = it,
|
.expect(expectedText = it,
|
||||||
expectedFormattedText = "<$htmlExpectedTag>$name<br />$name</$htmlExpectedTag>")
|
expectedFormattedText = "<$htmlExpectedTag>$name$softBreak$name</$htmlExpectedTag>")
|
||||||
}
|
}
|
||||||
|
|
||||||
// With new line between two blocks
|
// With new line between two blocks
|
||||||
|
@ -351,7 +354,7 @@ class MarkdownParserTest : InstrumentedTest {
|
||||||
.let {
|
.let {
|
||||||
markdownParser.parse(it)
|
markdownParser.parse(it)
|
||||||
.expect(expectedText = it,
|
.expect(expectedText = it,
|
||||||
expectedFormattedText = "<$htmlExpectedTag>$name</$htmlExpectedTag><$htmlExpectedTag>$name</$htmlExpectedTag>")
|
expectedFormattedText = "<$htmlExpectedTag>$name</$htmlExpectedTag><br /><$htmlExpectedTag>$name</$htmlExpectedTag>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ internal abstract class RoomModule {
|
||||||
fun providesHtmlRenderer(): HtmlRenderer {
|
fun providesHtmlRenderer(): HtmlRenderer {
|
||||||
return HtmlRenderer
|
return HtmlRenderer
|
||||||
.builder()
|
.builder()
|
||||||
|
.softbreak("<br />")
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue