slideshow-text-style:   a small library to improve text formatting in slideshow
with-text-style
7.7

slideshow-text-style: a small library to improve text formatting in slideshow

Asumu Takikawa <asumu@racket-lang.org>

 (require slideshow-text-style)
  package: slideshow-text-style

This module provides a single macro that’s intended for use with Scribble’s at-expression reader in a Slideshow document. It makes it easier to use fancy text formatting in code for slides.

syntax

(with-text-style maybe-defaults (style-spec ...) body ...)

 
maybe-defaults = 
  | #:defaults (style-spec-item ...)
     
style-spec = (name style-spec-item ...)
  | ((name parent) spec-item ...)
     
style-spec-item = #:face expr
  | #:bold? expr
  | #:italic? expr
  | #:color expr
  | #:size expr
  | #:line-sep expr
  | #:left-pad expr
  | #:transform expr
This form binds each name in the style-specs to functions which produce formatted text using Slideshow’s text function. Each function uses the style specifications indicated by the keywords.

If the second form with parent is used, the name function uses the style of the parent function but with optionally overriden styles.

If provided, maybe-defaults specifies the default style specifications that are shared by all of the styling functions.

The specifications have the following effects:

Examples:
> (with-text-style ([t] [b #:color "blue"])
    ; This uses at-exps, though you can't tell in the rendered docs
    ; It's supposed to look like @t{Hello @b{World}}
    (t "Hello "(b "World")))

image

> (define (do-fishy p)
    (hc-append
     10
     (standard-fish 30 20 #:color "PaleGreen")
     p
     (standard-fish 30 20 #:direction 'right #:color "PaleGreen")))
> (with-text-style ([t] [fishy #:transform do-fishy])
    ; @t{@fishy{One}, @fishy{Two}, @fishy{Three}}
    (t (fishy "One")", "(fishy "Two")", "(fishy "Three")))

image

> (with-text-style ([t]
                    [ti #:transform
                      (lambda (p) (t #:h-append hc-append #:left-pad 30  "• " p))])
    (ti "Like a bulleted list"))

image

Here is a more interesting example that you can try out:

#lang at-exp slideshow
 
(require slideshow-text-style)
 
(with-text-style
  #:defaults [#:face "Bitstream Vera Sans, Bold"
              #:size 27
              #:line-sep 7]
  ([a #:face "Bistream Vera Sans"
      #:color "DimGray"]
   [b #:color "CornflowerBlue"]
   [c #:color "Tomato"]
   ;; a kind of inheritance
   [(d c) #:face "Bitstream Vera Sans"])
 
  (slide
    @a{Whereas recognition of the @b{inherent dignity} and of the @b{equal}
       and @b{inalienable rights} of all members of the human family is
       the foundation of @c{freedom}, @c{justice} and @c{peace} in the world}))