adjust Scribble para/div style handling

svn: r10910

original commit: 4092392e5a749eed5b0ef3158ce63ed6c3b34abc
This commit is contained in:
Matthew Flatt 2008-07-25 13:16:06 +00:00
parent 81004dcf38
commit bad192a1c6
4 changed files with 39 additions and 20 deletions

View File

@ -789,15 +789,13 @@
[style (if (with-attributes? raw-style) [style (if (with-attributes? raw-style)
(with-attributes-style raw-style) (with-attributes-style raw-style)
raw-style)]) raw-style)])
(if (and (pair? style) (eq? (car style) 'div-hack)) `((,(if (eq? style 'div) 'div 'p)
`((div ,(cdr style) ,@contents)) ,(append
`((,(if (string? style) 'div 'p) (if (string? style)
,(append `([class ,style])
(if (string? style) `())
`([class ,style]) (style->attribs raw-style))
`()) ,@contents))))
(style->attribs raw-style))
,@contents)))))
(define/override (render-element e part ri) (define/override (render-element e part ri)
(cond (cond

View File

@ -79,14 +79,24 @@
(define/override (render-paragraph p part ri) (define/override (render-paragraph p part ri)
(printf "\n\n") (printf "\n\n")
(let ([margin? (and (styled-paragraph? p) (let ([style (and (styled-paragraph? p)
(equal? "refpara" (styled-paragraph-style p)))]) (let ([s (flatten-style
(when margin? (styled-paragraph-style p))])
(printf "\\marginpar{\\footnotesize ")) (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) (if (toc-paragraph? p)
(printf "\\newpage \\tableofcontents \\newpage") (printf "\\newpage \\tableofcontents \\newpage")
(super render-paragraph p part ri)) (super render-paragraph p part ri))
(when margin? (printf "}"))) (when (string? style) (printf "}")))
(printf "\n\n") (printf "\n\n")
null) null)

View File

@ -68,6 +68,7 @@
\newcommand{\noborder}[1]{#1} \newcommand{\noborder}[1]{#1}
\newcommand{\imageleft}[1]{} % drop it \newcommand{\imageleft}[1]{} % drop it
\newcommand{\smaller}[1]{{\footnotesize #1}} \newcommand{\smaller}[1]{{\footnotesize #1}}
\newcommand{\refpara}[1]{\marginpar{\footnotesize #1}}
\newcommand{\titleAndVersion}[2]{\title{#1\\{\normalsize Version #2}}\maketitle} \newcommand{\titleAndVersion}[2]{\title{#1\\{\normalsize Version #2}}\maketitle}

View File

@ -330,12 +330,22 @@ A @techlink{paragraph} has a list of @tech{elements}.
@defstruct[(styled-paragraph paragraph) ([style any/c])]{ @defstruct[(styled-paragraph paragraph) ([style any/c])]{
The @scheme[style] is normally a string that corresponds to a CSS The @scheme[style] can be
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.
} @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] @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.} style with a set of additional HTML attributes.}
]} ]}