diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-05-24 23:55:21 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-05-24 23:55:21 -0600 |
commit | fdc6a869747edfc7f9ffa1603a36ee33bda0aa4f (patch) | |
tree | 4f8a47986da64d99c79d16a1178e113fb32bd0c5 /src | |
parent | 315b6b0a025abb1002e03932918da7dc749a4089 (diff) |
libremessages/librexgettext: Preserve two spaces after a period.
Well, [.!?] really--this matches the behavior of `fmt -u`.
Diffstat (limited to 'src')
-rwxr-xr-x | src/lib/librelib | 4 | ||||
-rwxr-xr-x | src/lib/libremessages | 11 | ||||
-rwxr-xr-x | src/lib/librexgettext | 2 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/lib/librelib b/src/lib/librelib index 3d7795c..e4c933a 100755 --- a/src/lib/librelib +++ b/src/lib/librelib @@ -35,7 +35,9 @@ print() { } _html_whitespace_collapse() { - 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' } prose() { 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' } diff --git a/src/lib/librexgettext b/src/lib/librexgettext index 0732f81..aad79fa 100755 --- a/src/lib/librexgettext +++ b/src/lib/librexgettext @@ -102,7 +102,7 @@ main() { xgettext-sh "${simple[@]}" -- "${files[@]}" xgettext-sh "${prose[@]}" -- "${files[@]}" | # These are the raw strings given to prose functions tr '\n' '\r' | sed 's/"\r\s*"//g' | tr '\r' '\n' | # This removes the awkward word-wrapping done by xgettext - sed -r -e 's/(\\n|\\t|\t)/ /g' -e 's/ +/ /g' | # This collapses whitespace, HTML-style + sed -r -e 's/(\\n|\\t|\t)/ /g' -e 's/(^|[^.!? ]) +/\1 /g' -e 's/([.!?]) +/\1 /g' | # This collapses whitespace sed '/^\#, sh-format/d' } | msguniq -Fi } |