Skip to content
Snippets Groups Projects
Commit 94126062 authored by Peter Eisentraut's avatar Peter Eisentraut
Browse files

Normalize whitespace in the arguments of <indexterm>

Strip leading and trailing whitespace and replace interior whitespace
by a single space.  This avoids problems with the index generator
producing duplicate index entries for terms that differ only in
whitespace.

Commit dca30da3 actually fixed all the
indexterm elements that would cause this problem at the moment, but in
case it sneaks in again, we're set.
parent e6a30a8c
No related branches found
No related tags found
No related merge requests found
......@@ -163,6 +163,22 @@
;; Add more here if needed...
;; Replace a sequence of whitespace in a string by a single space
(define (normalize-whitespace str #!optional (whitespace '(#\space #\U-000D)))
(let loop ((characters (string->list str))
(result '())
(prev-was-space #f))
(if (null? characters)
(list->string (reverse result))
(let ((c (car characters))
(rest (cdr characters)))
(if (member c whitespace)
(if prev-was-space
(loop rest result #t)
(loop rest (cons #\space result) #t))
(loop rest (cons c result) #f))))))
<!-- HTML output customization ..................................... -->
<![ %output-html; [
......@@ -414,6 +430,26 @@
(literal "")))))
;; Changed to strip and normalize index term content (overrides
;; dbindex.dsl)
(define (htmlindexterm)
(let* ((attr (gi (current-node)))
(content (data (current-node)))
(string (strip (normalize-whitespace content))) ;; changed
(sortas (attribute-string (normalize "sortas"))))
(make sequence
(make formatting-instruction data: attr)
(if sortas
(make sequence
(make formatting-instruction data: "[")
(make formatting-instruction data: sortas)
(make formatting-instruction data: "]"))
(empty-sosofo))
(make formatting-instruction data: " ")
(make formatting-instruction data: string)
(htmlnewline))))
]]> <!-- %output-html -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment