summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rwxr-xr-xsrc/lib/librelib4
-rwxr-xr-xsrc/lib/libremessages9
-rw-r--r--src/lib/libremessages.1.ronn6
3 files changed, 13 insertions, 6 deletions
diff --git a/src/lib/librelib b/src/lib/librelib
index e4c933a..bc5c5ed 100755
--- a/src/lib/librelib
+++ b/src/lib/librelib
@@ -34,14 +34,14 @@ print() {
printf -- "$mesg\n" "$@"
}
-_html_whitespace_collapse() {
+whitespace-collapse() {
tr '\n' '\r' | sed -r \
-e 's/\r/ /g' -e 's/\t/ /g' \
-e 's/(^|[^.!? ]) +/\1 /g' -e 's/([.!?]) +/\1 /g'
}
prose() {
- local mesg="$(_ "$(_html_whitespace_collapse <<<"$1")")"; shift
+ local mesg="$(_ "$(whitespace-collapse <<<"$1")")"; shift
printf -- "$mesg" "$@" | fmt -u
}
diff --git a/src/lib/libremessages b/src/lib/libremessages
index f6deac8..4bea486 100755
--- a/src/lib/libremessages
+++ b/src/lib/libremessages
@@ -58,11 +58,12 @@ print() {
printf -- "$mesg\n" "$@"
}
-# Usage: _libremessages_html_whitespace_collapse <<<STRING
+# Usage: whitespace-collapse <<<STRING
#
# 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.
+whitespace-collapse() {
[[ $# == 0 ]] || panic
tr '\n' '\r' | sed -r \
@@ -78,7 +79,7 @@ print() {
# printing a paragraph of prose in --help text.
prose() {
[[ $# -ge 1 ]] || panic
- local mesg="$(_ "$(_libremessages_html_whitespace_collapse <<<"$1")")"; shift
+ local mesg="$(_ "$(whitespace-collapse <<<"$1")")"; shift
printf -- "$mesg" "$@" | fmt -u
}
@@ -87,7 +88,7 @@ prose() {
# remaining lines.
bullet() {
[[ $# -ge 1 ]] || panic
- local mesg="$(_ "$(_libremessages_html_whitespace_collapse <<<"$1")")"; shift
+ local mesg="$(_ "$(whitespace-collapse <<<"$1")")"; shift
# Wrap the text to 71 columns; 75 (the default) minus a 4 column indent
printf -- "$mesg" "$@" | fmt -u -w 71 | sed -e '1s/^/ - /' -e '2,$s/^/ /'
}
@@ -140,7 +141,7 @@ flag() {
while [[ $# -gt 0 ]]; do
local flag=$1
- local desc="$(_ "$(_libremessages_html_whitespace_collapse <<<"$2")")"
+ local desc="$(_ "$(whitespace-collapse <<<"$2")")"
shift 2
local lines
diff --git a/src/lib/libremessages.1.ronn b/src/lib/libremessages.1.ronn
index 520837d..0cb1f71 100644
--- a/src/lib/libremessages.1.ronn
+++ b/src/lib/libremessages.1.ronn
@@ -74,6 +74,12 @@ Unless otherwise noted, these do not implicitly call `gettext`.
<MESSAGE> is a `printf`(1)-formatted string that is fed through
`gettext`, and <MESSAGE_ARGS> are its arguments.
+ * `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.
+
### PROSE ROUTINES
These routines print to standard output, and are useful for printing