summaryrefslogtreecommitdiff
path: root/src/lib/libremessages
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-05-24 23:55:21 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-05-24 23:55:21 -0600
commitfdc6a869747edfc7f9ffa1603a36ee33bda0aa4f (patch)
tree4f8a47986da64d99c79d16a1178e113fb32bd0c5 /src/lib/libremessages
parent315b6b0a025abb1002e03932918da7dc749a4089 (diff)
libremessages/librexgettext: Preserve two spaces after a period.
Well, [.!?] really--this matches the behavior of `fmt -u`.
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'
}