Custom scribble site design

Hi

I’d like to make a variant of #lang scribble/manual that has keeps the same site structure; table of contents page with individual chapter pages, but has a preamble followers by the table of contents as tiled images that link to the chapter/section pages. Like the plot cookbook but using scribble https://github.com/Racket-Cookbooks/Plot-cookbook#plots

Any suggestions appreciated

Stephen

2 Likes

It seems like you want something semantically similar to (table-of-contents), but rendered differently. The implementation in scribble/base is:

(define (table-of-contents)
  (make-delayed-block
   (lambda (renderer part ri)
     (send renderer table-of-contents part ri))))

… which is a bit obscure, especially because the table-of-contents method of render% is undocumented. Looking at its implementation, though:

it's not especially closely tied to being inside a render<%> class. The key piece is the call to part-collected-info (back in the documented API), which gives you numbering and grouping information. Other than that, it's just manipulating part structures.

I'd probably start with a template using cond-block like this:

(define (custom-table-of-contents)
  (cond-block
   [(not html)
    (table-of-contents)]
   [else
    (make-delayed-block
     (λ (renderer part ri)
       ??? (part-collected-info part ri) ???))]))

You could attach the images to the parts by defining a custom style property and using it with section, title, etc., something like this:

#lang scribble/manual
@(require scribble/core
          (only-in pict disk))
@(struct custom-toc-image (convertible)
   #:transparent)
@section[#:style (style #f (list (custom-toc-image (disk 100))))]{
 Disks
}