summaryrefslogtreecommitdiff
path: root/src/lib/libremessages
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libremessages')
-rwxr-xr-xsrc/lib/libremessages11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/libremessages b/src/lib/libremessages
index 10b1818..f6deac8 100755
--- a/src/lib/libremessages
+++ b/src/lib/libremessages
@@ -60,11 +60,14 @@ print() {
# Usage: _libremessages_html_whitespace_collapse <<<STRING
#
-# Do HTML-style whitespace collapsing on standard IO. It considers
-# newline, tab, and space to be whitespace.
-_libremessages_html_whitespace_collapse() {
+# Collapses whitespace on stadard I/O, similar to HTML whitespace
+# collapsing, with the exception that it puts two spaces between
+# sentences. It considers newline, tab, and space to be whitespace.
[[ $# == 0 ]] || panic
- tr '\n' ' ' | sed -r -e 's/\t/ /g' -e 's/ +/ /g'
+
+ tr '\n' '\r' | sed -r \
+ -e 's/\r/ /g' -e 's/\t/ /g' \
+ -e 's/(^|[^.!? ]) +/\1 /g' -e 's/([.!?]) +/\1 /g'
}