avoid all characters that have to be encoded in Scribble-generated HTML anchors
svn: r7994
This commit is contained in:
parent
f281705054
commit
914a3ab784
|
@ -2198,7 +2198,7 @@ mimetype given the in HTML 4.0 specification. There are minor
|
|||
differences between the two encodings.
|
||||
|
||||
The URI encoding uses allows a few characters to be represented `as
|
||||
is': a-Z, A-Z, 0-9, -, _, ., !, ~, *, ', ( and ). The remaining
|
||||
is': a-z, A-Z, 0-9, -, _, ., !, ~, *, ', ( and ). The remaining
|
||||
characters are encoded as %xx, where xx is the hex representation
|
||||
of the integer value of the character (where the mapping
|
||||
character<->integer is determined by US-ASCII if the integer is
|
||||
|
|
|
@ -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
|
||||
(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))
|
||||
":"
|
||||
(substring s (caar m) (cdar m))
|
||||
"~"
|
||||
(format "~x" (char->integer (string-ref s (caar m))))
|
||||
(loop (substring s (cdar m)))))]
|
||||
[else s])))
|
||||
|
||||
|
||||
;; ----------------------------------------
|
||||
;; main mixin
|
||||
|
|
Loading…
Reference in New Issue
Block a user