change base handling of convertible values as content
If a value is convertible to 'text, then use that conversion. Otherwise, convert using `write` instead of always using "???". Also, correct documentation to include convertible values among the valid forms of content, and document the new conversion rules there.
This commit is contained in:
parent
178935f55c
commit
9f5fe0859d
|
@ -119,7 +119,8 @@ A @deftech{block} is either a @techlink{table}, an
|
|||
@itemize[
|
||||
|
||||
@item{A @deftech{content} can be a string, one of a few
|
||||
symbols, an instance of @racket[element] (possibly
|
||||
symbols, a convertible value in the sense of @racket[convertible?],
|
||||
an instance of @racket[element] (possibly
|
||||
@racket[link-element], etc.), a @racket[multiarg-element], a
|
||||
@techlink{traverse element}, a @techlink{part-relative element}, a
|
||||
@techlink{delayed element}, or a list of content.
|
||||
|
@ -144,6 +145,13 @@ A @deftech{block} is either a @techlink{table}, an
|
|||
rendered as the corresponding HTML entity
|
||||
(even for Latex output).}
|
||||
|
||||
@item{A convertible value in the sense of @racket[convertible?]
|
||||
is used in a renderer-specific way, but values convertible
|
||||
to @racket['text] renders the same as the resulting
|
||||
string. If a renderer is not able to convert the value
|
||||
to a known format, the value is converted to a string
|
||||
using @racket[write].}
|
||||
|
||||
@item{An instance of @racket[element] has a
|
||||
@techlink{content} plus a @tech{style}. The style's
|
||||
interpretation depends on the renderer, but it
|
||||
|
@ -230,6 +238,10 @@ A @deftech{block} is either a @techlink{table}, an
|
|||
|
||||
]
|
||||
|
||||
@history[#:changed "1.23" @elem{Changed the handling of @racket[convertible?]
|
||||
values to recognize a @racket['text] conversion
|
||||
and otherwise use @racket[write].}]
|
||||
|
||||
@; ------------------------------------------------------------------------
|
||||
|
||||
@section[#:tag "tags"]{Tags}
|
||||
|
|
|
@ -23,4 +23,4 @@
|
|||
|
||||
(define pkg-authors '(mflatt eli))
|
||||
|
||||
(define version "1.22")
|
||||
(define version "1.23")
|
||||
|
|
|
@ -973,7 +973,11 @@
|
|||
(render-content (traverse-element-content i ri) part ri)]
|
||||
[(part-relative-element? i)
|
||||
(render-content (part-relative-element-content i ri) part ri)]
|
||||
[(convertible? i) (list "???")]
|
||||
[(convertible? i)
|
||||
(define s (convert i 'text))
|
||||
(if (string? s)
|
||||
(render-other s part ri)
|
||||
(render-other (format "~s" i) part ri))]
|
||||
[else (render-other i part ri)]))
|
||||
|
||||
(define/public (render-other i part ri)
|
||||
|
|
21
scribble-test/tests/scribble/docs/convertible.scrbl
Normal file
21
scribble-test/tests/scribble/docs/convertible.scrbl
Normal file
|
@ -0,0 +1,21 @@
|
|||
#lang scribble/base
|
||||
@(require file/convertible)
|
||||
|
||||
@(struct s ()
|
||||
#:property
|
||||
prop:convertible
|
||||
;; Not actually convertible to anything:
|
||||
(lambda (v req default)
|
||||
default))
|
||||
|
||||
@(struct c ()
|
||||
#:property
|
||||
prop:convertible
|
||||
(lambda (v req default)
|
||||
(cond
|
||||
[(eq? req 'text) "hello"]
|
||||
[else default])))
|
||||
|
||||
@(s)
|
||||
|
||||
@(c)
|
3
scribble-test/tests/scribble/docs/convertible.txt
Normal file
3
scribble-test/tests/scribble/docs/convertible.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
#<s>
|
||||
|
||||
hello
|
Loading…
Reference in New Issue
Block a user