add render-element structure, and use it in the search doc

svn: r10782

original commit: 1c6281111b21b6f38c356f7e3b4ea0343e683cef
This commit is contained in:
Matthew Flatt 2008-07-15 22:03:36 +00:00
commit 5ddbe502ff
5 changed files with 49 additions and 2 deletions

View File

@ -387,6 +387,8 @@
(render-content (strip-aux (car v)) part ri)
(render-content (list "[missing]") part ri)))]
[(element? i)
(when (render-element? i)
((render-element-render i) this part ri))
(render-content (element-content i) part ri)]
[(delayed-element? i)
(render-content (delayed-element-content i ri) part ri)]

View File

@ -816,7 +816,10 @@
,@(if (null? (element-content e))
`(,(format "~s" (tag-key (link-element-tag e) ri)))
(render-plain-element e part ri))))))))]
[else (render-plain-element e part ri)]))
[else
(when (render-element? e)
((render-element-render e) this part ri))
(render-plain-element e part ri)]))
(define/private (render-plain-element e part ri)
(let* ([raw-style (flatten-style (and (element? e) (element-style e)))]

View File

@ -91,6 +91,8 @@
null)
(define/override (render-element e part ri)
(when (render-element? e)
((render-element-render e) this part ri))
(let ([part-label? (and (link-element? e)
(pair? (link-element-tag e))
(eq? 'part (car (link-element-tag e)))

View File

@ -309,7 +309,9 @@
prop:serializable
(make-serialize-info
(lambda (d)
(vector (collect-element-collect d)))
(vector (make-element
(element-style d)
(element-content d))))
#'deserialize-collect-element
#f
(or (current-load-relative-directory) (current-directory))))
@ -325,6 +327,29 @@
;; ----------------------------------------
(define-struct (render-element element) (render)
#:property
prop:serializable
(make-serialize-info
(lambda (d)
(vector (make-element
(element-style d)
(element-content d))))
#'deserialize-render-element
#f
(or (current-load-relative-directory) (current-directory))))
(provide deserialize-render-element)
(define deserialize-render-element
(make-deserialize-info values values))
(provide/contract
[struct render-element ([style any/c]
[content list?]
[render (any/c part? resolve-info? . -> . any)])])
;; ----------------------------------------
(define-struct generated-tag ()
#:property
prop:serializable

View File

@ -155,6 +155,11 @@ A @deftech{block} is either a @techlink{table}, an
the browser, or for rendering to other
formats.}
@item{An instance of @scheme[render-element] has a
procedure that is called in the
@techlink{render pass} of document
processing.}
}}}}
@item{A @deftech{delayed block} is an instance of
@ -546,6 +551,16 @@ element remains intact (i.e., it is not replaced) by either the
}
@defstruct[(render-element element) ([render (any/c part? resolve-info? . -> . any)])]{
Like @scheme[delayed-element], but the @scheme[render] procedure is called
during the @techlink{render pass}.
If a @scheme[render-element] instance is serialized (such as when
saving collected info), it is reduced to a @scheme[element] instance.
}
@defstruct[with-attributes ([style any/c]
[assoc (listof (cons/c symbol? string?))])]{