From cbca2f395bc2aa21a1c2c17667f10978b8cb43c3 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 19 Mar 2011 09:26:41 -0600 Subject: [PATCH] Scribble: add 'multicommand support to `nested-flow' --- collects/scribble/latex-render.rkt | 39 +++++++++++++--------- collects/scribblings/scribble/config.scrbl | 7 ++-- collects/scribblings/scribble/core.scrbl | 4 +++ 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt index 9fc955a379..993406f746 100644 --- a/collects/scribble/latex-render.rkt +++ b/collects/scribble/latex-render.rkt @@ -357,14 +357,19 @@ [else (format "x~x" (char->integer c))])) (string->list (format "~s" s))))) - (define/override (render-flow p part ri starting-item?) + (define/override (render-flow p part ri starting-item? [wrap-each? #f]) (if (null? p) null (begin + (when wrap-each? (printf "{")) (render-block (car p) part ri starting-item?) + (when wrap-each? (printf "}")) (for ([b (in-list (cdr p))]) - (printf "\n\n") - (render-block b part ri #f)) + (if wrap-each? + (printf "%\n{") + (printf "\n\n")) + (render-block b part ri #f) + (when wrap-each? (printf "}"))) null))) (define/override (render-table t part ri starting-item?) @@ -540,22 +545,26 @@ null)) (define/private (do-render-nested-flow t part ri single-column?) - (let ([kind (or (let ([s (style-name (nested-flow-style t))]) - (or (and (string? s) s) - (and (eq? s 'inset) "quote"))) - "Subflow")] - [command? (memq 'command (style-properties (nested-flow-style t)))]) - (if command? - (printf "\\~a{" kind) - (printf "\\begin{~a}" kind)) + (let* ([kind (or (let ([s (style-name (nested-flow-style t))]) + (or (and (string? s) s) + (and (eq? s 'inset) "quote"))) + "Subflow")] + [props (style-properties (nested-flow-style t))] + [command? (memq 'command props)] + [multicommand? (memq 'multicommand props)]) + (cond + [command? (printf "\\~a{" kind)] + [multicommand? (printf "\\~a" kind)] + [else (printf "\\begin{~a}" kind)]) (parameterize ([current-table-mode (if (or single-column? (not (current-table-mode))) (current-table-mode) (list "nested-flow" t))]) - (render-flow (nested-flow-blocks t) part ri #f)) - (if command? - (printf "}") - (printf "\\end{~a}" kind)) + (render-flow (nested-flow-blocks t) part ri #f multicommand?)) + (cond + [command? (printf "}")] + [multicommand? (void)] + [else (printf "\\end{~a}" kind)]) null)) (define/override (render-nested-flow t part ri) diff --git a/collects/scribblings/scribble/config.scrbl b/collects/scribblings/scribble/config.scrbl index fd94a42704..190e49adf6 100644 --- a/collects/scribblings/scribble/config.scrbl +++ b/collects/scribblings/scribble/config.scrbl @@ -49,10 +49,13 @@ a @racket[multiarg-element], @racket[paragraph], @racket[table], output or a Latex macro/environment for Latex output. In Latex output, the string is used as a command name for a @racket[paragraph] and an environment name for a @racket[table], @racket[itemization], -@racket[nested-flow], or @racket[compound-paragraph]; the if style has +@racket[nested-flow], or @racket[compound-paragraph]; if the style has a @racket['command] @tech{style property} for a @racket[nested-flow] or @racket[compound-paragraph], then the style name is used as a command -instead of an environment. In addition, for an itemization, the style +instead of an environment; and if the style has +a @racket['multicommand] @tech{style property} for a @racket[nested-flow], +then the style name is used as a command with multiple arguments. +In addition, for an itemization, the style string is suffixed with @racket["Item"] and used as a CSS class or Latex macro name to use for the itemization's items (in place of @tt{item} in the case of Latex). diff --git a/collects/scribblings/scribble/core.scrbl b/collects/scribblings/scribble/core.scrbl index 689431a684..9b072f0a4e 100644 --- a/collects/scribblings/scribble/core.scrbl +++ b/collects/scribblings/scribble/core.scrbl @@ -550,6 +550,10 @@ The following @tech{style properties} are currently recognized: name} is used as a command name instead of an environment name.} + @item{@racket['multicommand] --- For Latex output, a string + @tech{style name} is used as a command name with a separate + argument for each block in @racket[blocks].} + @item{@racket[attributes] structure --- Provides additional HTML attributes for the @tt{
} tag.}