better clean-up of index strings derved from body text
svn: r9886 original commit: 35d8fc32595922acbf91ddb89de13c95b163e1cc
This commit is contained in:
parent
5f941495b6
commit
449670964d
|
@ -161,15 +161,22 @@
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
||||||
(provide section-index index index* as-index index-section index-blocks)
|
(provide section-index index index* as-index index-section index-blocks
|
||||||
|
clean-up-index-string)
|
||||||
|
|
||||||
(define (section-index . elems)
|
(define (section-index . elems)
|
||||||
(make-part-index-decl (map element->string elems) elems))
|
(make-part-index-decl (map element->string elems) elems))
|
||||||
|
|
||||||
(define (clean-up s)
|
(define (clean-up-index-string s)
|
||||||
;; Remove leading spaces, which might appear there due to images or something
|
;; Remove leading spaces or trailing, which might appear there due
|
||||||
;; else that gets dropped in string form.
|
;; to images or something else that gets dropped in string form.
|
||||||
(regexp-replace #rx"^ +" s ""))
|
;; Then collapse whitespace.
|
||||||
|
(regexp-replace* #px"\\s+"
|
||||||
|
(regexp-replace #rx"^ +"
|
||||||
|
(regexp-replace #rx" +$"
|
||||||
|
s
|
||||||
|
""))
|
||||||
|
" "))
|
||||||
|
|
||||||
(define (record-index word-seq element-seq tag content)
|
(define (record-index word-seq element-seq tag content)
|
||||||
(make-index-element #f
|
(make-index-element #f
|
||||||
|
@ -190,7 +197,7 @@
|
||||||
(define (as-index . s)
|
(define (as-index . s)
|
||||||
(let ([key (make-generated-tag)]
|
(let ([key (make-generated-tag)]
|
||||||
[content (decode-content s)])
|
[content (decode-content s)])
|
||||||
(record-index (list (clean-up (content->string content)))
|
(record-index (list (clean-up-index-string (content->string content)))
|
||||||
(if (= 1 (length content))
|
(if (= 1 (length content))
|
||||||
content
|
content
|
||||||
(list (make-element #f content)))
|
(list (make-element #f content)))
|
||||||
|
|
|
@ -292,7 +292,9 @@
|
||||||
(define (indexed-file . str)
|
(define (indexed-file . str)
|
||||||
(let* ([f (apply filepath str)]
|
(let* ([f (apply filepath str)]
|
||||||
[s (element->string f)])
|
[s (element->string f)])
|
||||||
(index* (list (substring s 1 (sub1 (string-length s)))) (list f) f)))
|
(index* (list (clean-up-index-string (substring s 1 (sub1 (string-length s)))))
|
||||||
|
(list f)
|
||||||
|
f)))
|
||||||
(define (exec . str)
|
(define (exec . str)
|
||||||
(if (andmap string? str)
|
(if (andmap string? str)
|
||||||
(make-element 'tt str)
|
(make-element 'tt str)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user