mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-29 07:50:29 -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) {
|
if (preserveLineBreaks) {
|
||||||
addWord(word);
|
addWord(word);
|
||||||
lineBreak();
|
lineBreak();
|
||||||
isFirst = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '\r':
|
case '\r':
|
||||||
@ -108,11 +107,14 @@ public class LineBreaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void lineBreak() {
|
private void lineBreak() {
|
||||||
|
if (!isFirst) {
|
||||||
outText.append('\n');
|
outText.append('\n');
|
||||||
for (int j = 0; j < indent; j++)
|
for (int j = 0; j < indent; j++)
|
||||||
outText.append(" ");
|
outText.append(" ");
|
||||||
pos = indent;
|
pos = indent;
|
||||||
containsLineBreak = true;
|
containsLineBreak = true;
|
||||||
|
isFirst = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +25,8 @@ public class LineBreakerTest extends TestCase {
|
|||||||
|
|
||||||
public void testBreakLinesPreserve() throws Exception {
|
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\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."));
|
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