commit cce1eff495ef0af4c3ec2c93d2e376394f18a358
parent 525b72ca4c37a317f91798775ec412698f88fa82
Author: Vincent St-Amour <stamourv@racket-lang.org>
Date: Wed, 24 Aug 2016 16:13:37 -0500
Extend special characters using a function rather than a dict.
Based on feedback from David Van Horn.
Diffstat:
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/scribble-doc/scribblings/scribble/renderer.scrbl b/scribble-doc/scribblings/scribble/renderer.scrbl
@@ -2,7 +2,6 @@
@(require scribble/manual
"utils.rkt"
(for-label racket/class
- racket/dict
scribble/render
scribble/xref))
@@ -397,11 +396,14 @@ are own their own pages. A value of @racket[0] is treated the same as
Specializes a @racket[render<%>] class for generating Latex input.}}
-@defparam[extra-character-conversions convs (dictof char? string?)]{
-Maps (special) characters to strings corresponding to the Latex code that
-should be used to render them. Scribble already converts many special
-characters to the proper Latex commands. This parameter should be used in case
-you need characters it does not support yet.
+@defparam[extra-character-conversions convs (-> char? (or/c string? #f))]{
+Function that maps (special) characters to strings corresponding to the Latex
+code that should be used to render them. This function should return false for
+any character it does not know how to handle.
+
+Scribble already converts many special characters to the proper Latex
+commands. This parameter should be used in case you need characters it does not
+support yet.
}
@; ----------------------------------------
diff --git a/scribble-lib/scribble/latex-render.rkt b/scribble-lib/scribble/latex-render.rkt
@@ -3,7 +3,6 @@
"latex-properties.rkt"
"private/render-utils.rkt"
racket/class
- racket/dict
racket/runtime-path
racket/port
racket/string
@@ -49,7 +48,7 @@
(define-runtime-path skull-tex "scribble-skull.tex")
(define skull-style (make-style #f (list (tex-addition skull-tex))))
-(define extra-character-conversions (make-parameter (make-hash)))
+(define extra-character-conversions (make-parameter (λ (c) #f)))
(define (render-mixin % #:image-mode [image-mode #f])
(class %
@@ -1001,7 +1000,7 @@
[else
(if ((char->integer c) . > . 127)
;; first, try user-defined conversions
- (or (dict-ref convs c #f)
+ (or (convs c)
;; latex-prefix.rkt enables utf8 input, but this does not work for
;; all the characters below (e.g. ∞). Some parts of the table
;; below are therefore necessary, but some parts probably are not.