bkyk8rc3zvpnsf5inmcqq4n3k98cv6hj-my-site-hyper-literate-git.test.suzanne.soy-0.0.1

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 65702bffbe8ae823b3684ffd413572e549f9bd21
parent f1072f827de0f081c7e6c7f4f11e195a3dcbf3ce
Author: Matthew Flatt <mflatt@racket-lang.org>
Date:   Thu, 13 Dec 2007 17:49:52 +0000

avoid all characters that have to be encoded in Scribble-generated HTML anchors

svn: r7994

original commit: 914a3ab7844733a169110e1c71fb6bf3514f6b83

Diffstat:
Mcollects/scribble/html-render.ss | 19++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss @@ -39,19 +39,28 @@ (main-collects-relative->path p)))) ;; HTML anchors are case-insenstive. To make them - ;; distinct, add a "^" in front of capital letters. + ;; distinct, add a "." in front of capital letters. + ;; Also clean up characters that give browers trouble + ;; (i.e., the ones that are not allowed as-in in URI + ;; codecs) by using "~" followed by a hex encoding. (define (anchor-name v) (let loop ([s (format "~a" v)]) (cond - [(regexp-match-positions #rx"[A-Z:]" s) + [(regexp-match-positions #rx"[A-Z.]" s) => (lambda (m) (string-append - (substring s 0 (caar m)) - ":" + (loop (substring s 0 (caar m))) + "." (substring s (caar m) (cdar m)) (loop (substring s (cdar m)))))] + [(regexp-match-positions #rx"[^-a-zA-Z0-9_!*'().]" s) + => (lambda (m) + (string-append + (substring s 0 (caar m)) + "~" + (format "~x" (char->integer (string-ref s (caar m)))) + (loop (substring s (cdar m)))))] [else s]))) - ;; ---------------------------------------- ;; main mixin