support and document itemization styles

svn: r13865

original commit: d22069347665bd25d38b3152d8c47414eede0691
This commit is contained in:
Matthew Flatt 2009-02-27 01:19:08 +00:00
parent b7ba65934d
commit d9edf185bf
4 changed files with 58 additions and 15 deletions

View File

@ -1120,12 +1120,21 @@
(blockquote-paragraphs t)))))
(define/override (render-itemization t part ri)
`((ul ,(if (and (styled-itemization? t)
(string? (styled-itemization-style t)))
`([class ,(styled-itemization-style t)])
`())
,@(map (lambda (flow) `(li ,@(render-flow flow part ri #t)))
(itemization-flows t)))))
(let ([style-str (and (styled-itemization? t)
(string? (styled-itemization-style t))
(styled-itemization-style t))])
`((,(if (and (styled-itemization? t)
(eq? (styled-itemization-style t) 'ordered))
'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)
(cond

View File

@ -365,12 +365,24 @@
null))
(define/override (render-itemization t part ri)
(printf "\n\n\\begin{itemize}\n")
(for ([flow (itemization-flows t)])
(printf "\n\n\\item ")
(render-flow flow part ri #t))
(printf "\n\n\\end{itemize}\n")
null)
(let* ([style-str (and (styled-itemization? t)
(string? (styled-itemization-style t))
(styled-itemization-style t))]
[mode (or style-str
(if (and (styled-itemization? t)
(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)
(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}
When a string is uses as a style in an @scheme[element],
@scheme[styled-paragraph], or @scheme[blockquote], it corresponds to a
CSS class for HTML output or a Tex macro (or Latex environment, in the
case of @scheme[blockquote]) for Latex output.
@scheme[styled-paragraph], @scheme[styled-itemization], or
@scheme[blockquote], it corresponds to a CSS class for HTML output or
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
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]
[paragraphs (listof flow-element?)])]{