mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
texinfo: Add whitespace after periods.
* module/texinfo/string-utils.scm (end-of-sentence?): New procedure. (make-text-wrapper): Append an extra space after LINE when it matches `end-of-sentence?' and COLLAPSE-WHITESPACE? is false. * test-suite/tests/texinfo.serialize.test ("test-serialize"): Adjust accordingly. * test-suite/tests/texinfo.string-utils.test ("text wrapping")["two spaces after end of sentence"]: New test prefix.
This commit is contained in:
parent
c5c7c1146f
commit
43c2a48323
3 changed files with 23 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
;;;; (texinfo string-utils) -- text filling and wrapping
|
||||
;;;;
|
||||
;;;; Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 2009, 2013 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 2003 Richard Todd
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
|
@ -262,6 +262,13 @@ the default value for @var{num} is 1.
|
|||
;; did not find non-ws... only ws at end of the string...
|
||||
(reverse ans))))))
|
||||
|
||||
(define (end-of-sentence? str)
|
||||
"Return #t when STR likely denotes the end of sentence."
|
||||
(let ((len (string-length str)))
|
||||
(and (> len 1)
|
||||
(eqv? #\. (string-ref str (- len 1)))
|
||||
(not (eqv? #\. (string-ref str (- len 2)))))))
|
||||
|
||||
(define* (make-text-wrapper #:key
|
||||
(line-width 80)
|
||||
(expand-tabs? #t)
|
||||
|
@ -352,7 +359,11 @@ returns a list of strings, where each element of the list is one line."
|
|||
length-left)
|
||||
(loop ans
|
||||
(cdr words)
|
||||
(string-append line next-word)
|
||||
(if (and collapse-whitespace?
|
||||
(end-of-sentence? line))
|
||||
;; Add an extra space after the period.
|
||||
(string-append line " " next-word)
|
||||
(string-append line next-word))
|
||||
(+ count 1)))
|
||||
|
||||
;; ok, it didn't fit...is there already at least one word on the line?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;;; texinfo.serialize.test -*- scheme -*-
|
||||
;;;;
|
||||
;;;; Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 2010, 2013 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -103,7 +103,7 @@
|
|||
"@iftex
|
||||
This is only for tex.
|
||||
|
||||
Note. Foo.
|
||||
Note. Foo.
|
||||
|
||||
@end iftex
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;;; texinfo.string-utils.test -*- scheme -*-
|
||||
;;;;
|
||||
;;;; Copyright (C) 2003, 2009, 2010 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 2003, 2009, 2010, 2013 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This program is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU General Public License as
|
||||
|
@ -109,6 +109,13 @@ to using the function `set-language-environment'.
|
|||
variable should be set only with M-x customize, which is equivalent to using
|
||||
the function `set-language-environment'.")))
|
||||
|
||||
(with-test-prefix "two spaces after end of sentence"
|
||||
(pass-if-equal "This is a sentence. There should be two spaces before."
|
||||
(fill-string "This is a sentence. There should be two spaces before."))
|
||||
|
||||
(pass-if-equal "This is version 2.0..."
|
||||
(fill-string "This is version 2.0...")))
|
||||
|
||||
(with-test-prefix "test-no-word-break"
|
||||
(pass-if (equal? "thisisalongword
|
||||
blah
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue