support and document itemization styles

svn: r13865
This commit is contained in:
Matthew Flatt 2009-02-27 01:19:08 +00:00
parent c221f41695
commit d220693476
4 changed files with 58 additions and 15 deletions

View File

@ -1120,12 +1120,21 @@
(blockquote-paragraphs t))))) (blockquote-paragraphs t)))))
(define/override (render-itemization t part ri) (define/override (render-itemization t part ri)
`((ul ,(if (and (styled-itemization? t) (let ([style-str (and (styled-itemization? t)
(string? (styled-itemization-style t))) (string? (styled-itemization-style t))
`([class ,(styled-itemization-style t)]) (styled-itemization-style t))])
`()) `((,(if (and (styled-itemization? t)
,@(map (lambda (flow) `(li ,@(render-flow flow part ri #t))) (eq? (styled-itemization-style t) 'ordered))
(itemization-flows t))))) 'ol
'ul)
,(if style-str
`([class ,style-str])
`())
,@(map (lambda (flow) `(li ,(if style-str
`([class ,(string-append style-str "Item")])
`())
,@(render-flow flow part ri #t)))
(itemization-flows t))))))
(define/override (render-other i part ri) (define/override (render-other i part ri)
(cond (cond

View File

@ -365,12 +365,24 @@
null)) null))
(define/override (render-itemization t part ri) (define/override (render-itemization t part ri)
(printf "\n\n\\begin{itemize}\n") (let* ([style-str (and (styled-itemization? t)
(for ([flow (itemization-flows t)]) (string? (styled-itemization-style t))
(printf "\n\n\\item ") (styled-itemization-style t))]
(render-flow flow part ri #t)) [mode (or style-str
(printf "\n\n\\end{itemize}\n") (if (and (styled-itemization? t)
null) (eq? (styled-itemization-style t) 'ordered))
"enumerate"
"itemize"))])
(printf "\n\n\\begin{~a}\n" mode)
(for ([flow (itemization-flows t)])
(printf "\n\n\\~a" (if style-str
(format "~aItem{" style-str)
"item "))
(render-flow flow part ri #t)
(when style-str
(printf "}")))
(printf "\n\n\\end{~a}\n" mode)
null))
(define/override (render-blockquote t part ri) (define/override (render-blockquote t part ri)
(let ([kind (or (blockquote-style t) "quote")]) (let ([kind (or (blockquote-style t) "quote")])

View File

@ -40,9 +40,14 @@ extend or configure Scribble fall into two groups:
#:style `((css "inbox.css") (tex "inbox.tex"))]{Adding a Style} #:style `((css "inbox.css") (tex "inbox.tex"))]{Adding a Style}
When a string is uses as a style in an @scheme[element], When a string is uses as a style in an @scheme[element],
@scheme[styled-paragraph], or @scheme[blockquote], it corresponds to a @scheme[styled-paragraph], @scheme[styled-itemization], or
CSS class for HTML output or a Tex macro (or Latex environment, in the @scheme[blockquote], it corresponds to a CSS class for HTML output or
case of @scheme[blockquote]) for Latex output. a Tex macro/environment for Latex output. In Latex output, the string
is used as a macro name for a @scheme[styled-paragraph] and an
environment name for a @scheme[itemization] or @scheme[blockquote]. In
addition, for an itemization, the style string is suffixed with
@scheme["Item"] and used as a CSS class or Tex macro name to use for
the itemization's items (in place of @tt{item} in the case of Latex).
Scribble includes a number of predefined styles that are used by the Scribble includes a number of predefined styles that are used by the
exports of @scheme[scribble/manual], but they are not generally exports of @scheme[scribble/manual], but they are not generally

View File

@ -443,6 +443,23 @@ A @techlink{itemization} has a list of flows.
} }
@defstruct[(styled-itemization itemization) ([style any/c])]{
The @scheme[style] can be
@itemize[
@item{A string that corresponds to a CSS class for HTML output or a
macro for Latex output (see @secref["extra-style"]).}
@item{The symbol @scheme['ordered], which generates @tt{<ol>} HTML
output instead of @tt{<li>} or an Latex enumeration instead of
an itemization.}
]}
@defstruct[blockquote ([style any/c] @defstruct[blockquote ([style any/c]
[paragraphs (listof flow-element?)])]{ [paragraphs (listof flow-element?)])]{