mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-26 06:47:03 +03:00
update
This commit is contained in:
parent
1ccd74e288
commit
44e585f828
2 changed files with 13 additions and 16 deletions
|
@ -752,19 +752,19 @@ public class MarkdownUtilTest extends TestCase {
|
|||
assertEquals("Foo_Test_Bar", MarkdownUtil.removeMarkdown("Foo_Test_Bar"));
|
||||
assertEquals("Foo__Test__Bar", MarkdownUtil.removeMarkdown("Foo__Test__Bar"));
|
||||
assertEquals("Foo___Test___Bar", MarkdownUtil.removeMarkdown("Foo___Test___Bar"));
|
||||
assertEquals("Foo\n\nHeader\n\nBar", MarkdownUtil.removeMarkdown("Foo\n# Header\nBar"));
|
||||
assertEquals("Foo\n\nHeader\n\nBar", MarkdownUtil.removeMarkdown("Foo\n### Header\nBar"));
|
||||
assertEquals("Foo\n\nHeader\n\nBar", MarkdownUtil.removeMarkdown("Foo\n# Header #\nBar"));
|
||||
assertEquals("Foo\n\nHeader\n\nBar", MarkdownUtil.removeMarkdown("Foo\n## Header ####\nBar"));
|
||||
assertEquals("Foo\nHeader\nBar", MarkdownUtil.removeMarkdown("Foo\n# Header\nBar"));
|
||||
assertEquals("Foo\nHeader\nBar", MarkdownUtil.removeMarkdown("Foo\n### Header\nBar"));
|
||||
assertEquals("Foo\nHeader\nBar", MarkdownUtil.removeMarkdown("Foo\n# Header #\nBar"));
|
||||
assertEquals("Foo\nHeader\nBar", MarkdownUtil.removeMarkdown("Foo\n## Header ####\nBar"));
|
||||
assertEquals("Foo\nNo Header #\nBar", MarkdownUtil.removeMarkdown("Foo\nNo Header #\nBar"));
|
||||
assertEquals("Foo\nHeader\n\nBar", MarkdownUtil.removeMarkdown("Foo\nHeader\n=\nBar"));
|
||||
assertEquals("Foo\nHeader\n\nBar", MarkdownUtil.removeMarkdown("Foo\nHeader\n-----\nBar"));
|
||||
assertEquals("Foo\nHeader\nBar", MarkdownUtil.removeMarkdown("Foo\nHeader\n=\nBar"));
|
||||
assertEquals("Foo\nHeader\nBar", MarkdownUtil.removeMarkdown("Foo\nHeader\n-----\nBar"));
|
||||
assertEquals("Foo\nHeader\n--=--\nBar", MarkdownUtil.removeMarkdown("Foo\nHeader\n--=--\nBar"));
|
||||
assertEquals("Foo\n\nAufzählung\nBar", MarkdownUtil.removeMarkdown("Foo\n* Aufzählung\nBar"));
|
||||
assertEquals("Foo\n\nAufzählung\nBar", MarkdownUtil.removeMarkdown("Foo\n+ Aufzählung\nBar"));
|
||||
assertEquals("Foo\n\nAufzählung\nBar", MarkdownUtil.removeMarkdown("Foo\n- Aufzählung\nBar"));
|
||||
assertEquals("Foo\nAufzählung\nBar", MarkdownUtil.removeMarkdown("Foo\n* Aufzählung\nBar"));
|
||||
assertEquals("Foo\nAufzählung\nBar", MarkdownUtil.removeMarkdown("Foo\n+ Aufzählung\nBar"));
|
||||
assertEquals("Foo\nAufzählung\nBar", MarkdownUtil.removeMarkdown("Foo\n- Aufzählung\nBar"));
|
||||
assertEquals("Foo\n- Aufzählung\nBar", MarkdownUtil.removeMarkdown("Foo\n - Aufzählung\nBar"));
|
||||
assertEquals("Foo\n\nAufzählung *\nBar", MarkdownUtil.removeMarkdown("Foo\n* Aufzählung *\nBar"));
|
||||
assertEquals("Foo\nAufzählung *\nBar", MarkdownUtil.removeMarkdown("Foo\n* Aufzählung *\nBar"));
|
||||
assertEquals("Title", MarkdownUtil.removeMarkdown("# Title"));
|
||||
assertEquals("Aufzählung", MarkdownUtil.removeMarkdown("* Aufzählung"));
|
||||
// assertEquals("Foo Link Bar", MarkdownUtil.removeMarkdown("Foo [Link](https://example.com) Bar"));
|
||||
|
|
|
@ -572,15 +572,12 @@ public class MarkdownUtil {
|
|||
return "";
|
||||
// Create HTML string from Markup
|
||||
String html = renderer.render(parser.parse(replaceCheckboxesWithEmojis(s)));
|
||||
html = html.replaceAll("\n", "");
|
||||
// Convert Spanned from HTML. Using HtmlCompat to convert has some problems, which is that sometimes the \n in the text would double.
|
||||
Spanned spanned = HtmlCompat.fromHtml(html, 0);
|
||||
//Maybe we could use Html to convert, it doesn't have such problems.
|
||||
//Spanned spanned = Html.fromHtml(html,Html.FROM_HTML_MODE_COMPACT);
|
||||
// Convert Spanned from HTML.
|
||||
Spanned spanned = HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_COMPACT);
|
||||
// Convert from spanned to string
|
||||
s = spanned.toString();
|
||||
// The default string has two additional \n in the end, the substring is used to delete this two \n.
|
||||
s = s.substring(0, s.length() - 2);
|
||||
s = s.substring(0, s.length() - 1);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue