mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 06:51:37 -04:00
LineBreaker removes multiple line breaks
This commit is contained in:
parent
7d7f2630f2
commit
4b9b437dc1
@ -70,7 +70,6 @@ public class LineBreaker {
|
||||
if (preserveLineBreaks) {
|
||||
addWord(word);
|
||||
lineBreak();
|
||||
isFirst = true;
|
||||
break;
|
||||
}
|
||||
case '\r':
|
||||
@ -108,11 +107,14 @@ public class LineBreaker {
|
||||
}
|
||||
|
||||
private void lineBreak() {
|
||||
if (!isFirst) {
|
||||
outText.append('\n');
|
||||
for (int j = 0; j < indent; j++)
|
||||
outText.append(" ");
|
||||
pos = indent;
|
||||
containsLineBreak = true;
|
||||
isFirst = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,8 @@ public class LineBreakerTest extends TestCase {
|
||||
|
||||
public void testBreakLinesPreserve() throws Exception {
|
||||
assertEquals("this is a\ntest string", new LineBreaker(60).preserveContainedLineBreaks().breakLines("this is a\ntest string"));
|
||||
assertEquals("this is a\ntest string", new LineBreaker(60).preserveContainedLineBreaks().breakLines("this is a \n test string"));
|
||||
assertEquals("this is a\ntest string\n", new LineBreaker(60).preserveContainedLineBreaks().breakLines("\n\nthis is a\n\ntest string\n\n\n"));
|
||||
assertEquals("this is a\ntest string. This is\na test string.", new LineBreaker(20).preserveContainedLineBreaks().breakLines("this is a\n test string. This is a test string."));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user