commit bad192a1c64457270a021fc18405865b0e00c025
parent 81004dcf38a44f571e19f387b0fe3c55db5be94a
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Fri, 25 Jul 2008 13:16:06 +0000
adjust Scribble para/div style handling
svn: r10910
original commit: 4092392e5a749eed5b0ef3158ce63ed6c3b34abc
Diffstat:
4 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss
@@ -789,15 +789,13 @@
[style (if (with-attributes? raw-style)
(with-attributes-style raw-style)
raw-style)])
- (if (and (pair? style) (eq? (car style) 'div-hack))
- `((div ,(cdr style) ,@contents))
- `((,(if (string? style) 'div 'p)
- ,(append
- (if (string? style)
- `([class ,style])
- `())
- (style->attribs raw-style))
- ,@contents)))))
+ `((,(if (eq? style 'div) 'div 'p)
+ ,(append
+ (if (string? style)
+ `([class ,style])
+ `())
+ (style->attribs raw-style))
+ ,@contents))))
(define/override (render-element e part ri)
(cond
diff --git a/collects/scribble/latex-render.ss b/collects/scribble/latex-render.ss
@@ -79,14 +79,24 @@
(define/override (render-paragraph p part ri)
(printf "\n\n")
- (let ([margin? (and (styled-paragraph? p)
- (equal? "refpara" (styled-paragraph-style p)))])
- (when margin?
- (printf "\\marginpar{\\footnotesize "))
+ (let ([style (and (styled-paragraph? p)
+ (let ([s (flatten-style
+ (styled-paragraph-style p))])
+ (if (with-attributes? s)
+ (let ([base (with-attributes-style s)])
+ (if (eq? base 'div)
+ (let ([a (assq 'class (with-attributes-assoc s))])
+ (if a
+ (cdr a)
+ base))
+ base))
+ s)))])
+ (when (string? style)
+ (printf "\\~a{" style))
(if (toc-paragraph? p)
(printf "\\newpage \\tableofcontents \\newpage")
(super render-paragraph p part ri))
- (when margin? (printf "}")))
+ (when (string? style) (printf "}")))
(printf "\n\n")
null)
diff --git a/collects/scribble/scribble.tex b/collects/scribble/scribble.tex
@@ -68,6 +68,7 @@
\newcommand{\noborder}[1]{#1}
\newcommand{\imageleft}[1]{} % drop it
\newcommand{\smaller}[1]{{\footnotesize #1}}
+\newcommand{\refpara}[1]{\marginpar{\footnotesize #1}}
\newcommand{\titleAndVersion}[2]{\title{#1\\{\normalsize Version #2}}\maketitle}
diff --git a/collects/scribblings/scribble/struct.scrbl b/collects/scribblings/scribble/struct.scrbl
@@ -330,12 +330,22 @@ A @techlink{paragraph} has a list of @tech{elements}.
@defstruct[(styled-paragraph paragraph) ([style any/c])]{
-The @scheme[style] is normally a string that corresponds to a CSS
-class for HTML output, in which case a @tt{<div>} block is generated
-instead of a @tt{<p>} block. A base style can also be a
-@scheme[with-attributes] instance to add arbitrary HTML attributes.
+The @scheme[style] can be
-}
+@itemize[
+
+ @item{A string that corresponds to a CSS class for HTML output or a
+ macro for Latex output.}
+
+ @item{An instance of @scheme[with-attributes], which combines a base
+ style with a set of additional HTML attributes.}
+
+ @item{The symbol @scheme['div], which generates @tt{<div>} HTML
+ output instead of @tt{<p>}. For Latex output, a string for a
+ macro name is extracted from the @scheme['class] mapping of a
+ @scheme[with-attributes] wrapper, if one is present.}
+
+]}
@defstruct[table ([style any/c]
@@ -379,7 +389,7 @@ The @scheme[style] can be any of the following:
]}
- @item{an instance of @scheme[with-attributes], which combines a base
+ @item{An instance of @scheme[with-attributes], which combines a base
style with a set of additional HTML attributes.}
]}