Skip to content

Commit

Permalink
fixes #140 - Do not suppress multiple consecutive spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippSalvisberg committed Jan 6, 2022
1 parent 155f3d7 commit dde8e11
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,13 @@ private String getLinkedAndFormattedText(final String text) {
localText = localText.substring(0, start) + title + localText.substring(end);
m = p3.matcher(localText);
}
// replaces two consecutive spaces with two non-breaking spaces to fix #140
// assume that consecutive spaces do not conflict with previous replacements
// using CSS "white-space: pre-wrap;" does not work within Swing, it's simply ignored.
// See https://docs.oracle.com/javase/8/docs/api/javax/swing/text/html/CSS.html
// putting text in pre tags is not an option, because this suppresses wrap.
localText = localText.replaceAll(" ", "  ");
// add paragraph for each line to preserve line breaks
StringBuilder sb = new StringBuilder();
for (final String p : localText.split("\n")) {
sb.append("<p>");
Expand Down

0 comments on commit dde8e11

Please sign in to comment.