Skip to content

Commit e2ded04

Browse files
Fix #24 Line breaks ignored
1 parent a75e77b commit e2ded04

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

app/src/main/java/it/niedermann/owncloud/notes/util/NoteUtil.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,21 @@ public class NoteUtil {
1717
* @return Spannable
1818
*/
1919
public static CharSequence parseMarkDown(String s) {
20-
return bypass.markdownToSpannable(s);
20+
/*
21+
* Appends two spaces at the end of every line to force a line break.
22+
*
23+
* @see #24
24+
*/
25+
StringBuilder sb = new StringBuilder();
26+
for (String line : s.split("\n")) {
27+
sb.append(line);
28+
// If line is not a list item
29+
if (!line.trim().matches("^([\\-*]|[0-9]+\\.)(.)*")) {
30+
sb.append(" ");
31+
}
32+
sb.append("\n");
33+
}
34+
return bypass.markdownToSpannable(sb.toString());
2135
}
2236

2337
/**

0 commit comments

Comments
 (0)