scribble/reader: allow escape character to be non-ASCII
This commit is contained in:
parent
b7f17b389a
commit
96c5521196
|
@ -15,7 +15,7 @@
|
|||
[args (map (lambda (x)
|
||||
(cond [(bytes? x) x]
|
||||
[(string? x) (string->bytes/utf-8 x)]
|
||||
[(char? x) (regexp-quote (bytes (char->integer x)))]
|
||||
[(char? x) (regexp-quote (string->bytes/utf-8 (string x)))]
|
||||
[(not x) #""]
|
||||
[else (internal-error 'px)]))
|
||||
args)])
|
||||
|
|
|
@ -198,7 +198,7 @@ Useful for implementing languages that are textual by default (see
|
|||
|
||||
@defproc[(make-at-readtable
|
||||
[#:readtable readtable readtable? (current-readtable)]
|
||||
[#:command-char command-char character? #\@]
|
||||
[#:command-char command-char char? #\@]
|
||||
[#:datum-readtable datum-readtable
|
||||
(or/c readtable? boolean?
|
||||
(readtable? . -> . readtable?))
|
||||
|
|
15
collects/tests/scribble/docs/diamond.rkt
Normal file
15
collects/tests/scribble/docs/diamond.rkt
Normal file
|
@ -0,0 +1,15 @@
|
|||
#lang racket/base
|
||||
(require (only-in scribble/reader make-at-readtable))
|
||||
|
||||
(provide (rename-out [diamond-read read]
|
||||
[diamond-read-syntax read-syntax]))
|
||||
|
||||
(define diamond-readtable (make-at-readtable #:command-char #\◇))
|
||||
|
||||
(define (diamond-read p)
|
||||
(parameterize ([current-readtable diamond-readtable])
|
||||
(read p)))
|
||||
|
||||
(define (diamond-read-syntax name p)
|
||||
(parameterize ([current-readtable diamond-readtable])
|
||||
(read-syntax name p)))
|
14
collects/tests/scribble/docs/diamond.scrbl
Normal file
14
collects/tests/scribble/docs/diamond.scrbl
Normal file
|
@ -0,0 +1,14 @@
|
|||
#lang scribble/base
|
||||
@#reader "diamond.rkt"
|
||||
|
||||
◇begin{
|
||||
|
||||
This example checks that @ is not an escape character
|
||||
if we make a reader that uses a different escape character.
|
||||
|
||||
◇(define ch "diamond")
|
||||
|
||||
It also makes sure that a non-ASCII character like ◇ch
|
||||
is ok as an escape character.
|
||||
|
||||
}
|
5
collects/tests/scribble/docs/diamond.txt
Normal file
5
collects/tests/scribble/docs/diamond.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
This example checks that @ is not an escape character if we make a
|
||||
reader that uses a different escape character.
|
||||
|
||||
It also makes sure that a non-ASCII character like diamond is ok as an
|
||||
escape character.
|
Loading…
Reference in New Issue
Block a user