Extend special characters using a function rather than a dict.
Based on feedback from David Van Horn.
This commit is contained in:
parent
525b72ca4c
commit
cce1eff495
|
@ -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.
|
||||
}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user