fix HTML problems that affect Opera; add ++style to scribble executable; fix some Latex back-end issues

svn: r11997

original commit: 4fe97848b2af639c8c13b3a7d4593cad4db14360
This commit is contained in:
Matthew Flatt 2008-10-12 15:53:49 +00:00
parent 6d37b145df
commit 82b6b41ac3
8 changed files with 72 additions and 17 deletions

View File

@ -349,7 +349,7 @@
null
(append
(render-block (car (flow-paragraphs p))
part ri start-inline?)
part ri start-inline?)
(apply append
(map (lambda (p)
(render-block p part ri #f))

View File

@ -238,6 +238,7 @@
;; user start page)
[up-path #f]
[style-file #f]
[style-extra-files null]
[script-path #f]
[script-file #f])
@ -564,6 +565,7 @@
,(content->string c this d ri)))]
[else `(title)])])
(unless css-path (install-file style-file))
(for-each (lambda (f) (install-file f)) style-extra-files)
(unless script-path (install-file script-file))
(printf "<!DOCTYPE html PUBLIC ~s ~s>\n"
"-//W3C//DTD HTML 4.0 Transitional//EN"
@ -576,6 +578,9 @@
[content "text-html; charset=utf-8"]))
,title
,(scribble-css-contents style-file css-path)
,@(map (lambda (style-file)
(scribble-css-contents style-file css-path))
style-extra-files)
,(scribble-js-contents script-file script-path))
(body ()
,@(render-toc-view d ri)
@ -974,11 +979,12 @@
[as (cdr (or (t-style-get 'alignment)
(cons #f (map (lambda (x) #f) flows))))]
[vas (cdr (or (t-style-get 'valignment)
(cons #f (map (lambda (x) #f) flows))))])
(cons #f (map (lambda (x) #f) flows))))]
[first? #t])
(cond
[(null? ds) null]
[(eq? (car ds) 'cont)
(loop (cdr ds) (cdr as) (cdr vas))]
(loop (cdr ds) (cdr as) (cdr vas) first?)]
[else
(let ([d (car ds)] [a (car as)] [va (car vas)])
(cons
@ -1003,7 +1009,7 @@
[else n])))])
null))
,@(render-flow d part ri #f))
(loop (cdr ds) (cdr as) (cdr vas))))]))))
(loop (cdr ds) (cdr as) (cdr vas) #f)))]))))
`((table ([cellspacing "0"]
,@(if need-inline?
'([style "display: inline-table; vertical-align: text-top;"])
@ -1018,10 +1024,12 @@
(if (and a (string? (cadr a))) `([class ,(cadr a)]) null))
,@(if (string? t-style) `([class ,t-style]) null)
,@(style->attribs raw-style))
,@(map make-row
(table-flowss t)
(cdr (or (t-style-get 'row-styles)
(cons #f (map (lambda (x) #f) (table-flowss t)))))))))
,@(if (null? (table-flowss t))
`((tr (td)))
(map make-row
(table-flowss t)
(cdr (or (t-style-get 'row-styles)
(cons #f (map (lambda (x) #f) (table-flowss t))))))))))
(define/override (render-blockquote t part ri)
`((blockquote ,(if (string? (blockquote-style t))

View File

@ -19,7 +19,8 @@
(define (render-mixin %)
(class %
(init-field [style-file #f])
(init-field [style-file #f]
[style-extra-files null])
(define/override (get-suffix) #".tex")
@ -31,9 +32,12 @@
(define/override (render-one d ri fn)
(let ([style-file (or style-file scribble-tex)])
(with-input-from-file style-file
(lambda ()
(copy-port (current-input-port) (current-output-port))))
(for-each
(lambda (style-file)
(with-input-from-file style-file
(lambda ()
(copy-port (current-input-port) (current-output-port)))))
(cons style-file style-extra-files))
(printf "\\begin{document}\n\\preDoc\n")
(when (part-title-content d)
(let ([m (ormap (lambda (v)
@ -280,7 +284,7 @@
(loop (cdr flows) (add1 n))]
[else n]))])
(unless (= cnt 1) (printf "\\multicolumn{~a}{l}{" cnt))
(render-flow (car flows) part ri #f)
(render-table-flow (car flows) part ri)
(unless (= cnt 1) (printf "}"))
(unless (null? (list-tail flows cnt)) (printf " &\n"))))
(unless (null? (cdr flows)) (loop (cdr flows)))))
@ -295,6 +299,24 @@
tableform)))))
null)
(define/private (render-table-flow p part ri)
;; Emit a \\ between blocks:
(let loop ([ps (flow-paragraphs p)])
(cond
[(null? ps) (void)]
[else
(let ([minipage? (not (or (paragraph? (car ps))
(table? (car ps))))])
(when minipage?
(printf "\\begin{minipage}{\\linewidth}\n"))
(render-block (car ps) part ri #f)
(when minipage?
(printf " \\end{minipage}\n"))
(unless (null? (cdr ps))
(printf " \\\\\n")
(loop (cdr ps))))]))
null)
(define/override (render-itemization t part ri)
(printf "\n\n\\begin{itemize}\n")
(for ([flow (itemization-flows t)])

View File

@ -1912,7 +1912,7 @@
(make-a-bib-entry
key
(make-element
#f
"bibentry"
(append
(if author `(,@(decode-content (list author)) ", ") null)
(if is-book? null '(ldquo))

View File

@ -34,6 +34,8 @@
(make-parameter null))
(define current-style-file
(make-parameter #f))
(define current-style-extra-files
(make-parameter null))
(define current-redirect
(make-parameter #f))
@ -63,7 +65,7 @@
(current-dest-directory dir)]
[("--dest-name") name "write output as <name>"
(current-dest-name name)]
[("--style") file "use given .css/.tex file"
[("--style") file "use given base .css/.tex file"
(current-style-file file)]
[("--redirect") url "redirect external tag links to <url>"
(current-redirect url)]
@ -86,7 +88,9 @@
"bad procedure identifier for ++ref-in: ~s"
proc-id))
(current-xref-input-modules
(cons (cons mod id) (current-xref-input-modules))))]]
(cons (cons mod id) (current-xref-input-modules))))]
[("++style") file "add given .css/.tex file"
(current-style-extra-files (cons file (current-style-extra-files)))]]
[args (file . another-file) (cons file another-file)]))
(define (build-docs-files files)
@ -102,7 +106,8 @@
(let ([renderer (new ((current-render-mixin) render%)
[dest-dir dir]
[style-file (current-style-file)])])
[style-file (current-style-file)]
[style-extra-files (reverse (current-style-extra-files))])])
(when (current-redirect)
(send renderer set-external-tag-path (current-redirect)))
(send renderer report-output!)

View File

@ -32,6 +32,14 @@ h3, h4, h5, h6, h7, h8 {
margin-bottom: 0.5em;
}
/* Needed for browsers like Opera, and eventually for HTML 4 conformance.
This means that multiple paragraphs in a table element do not have a space
between them. */
table p {
margin-top: 0;
margin-bottom: 0;
}
/* ---------------------------------------- */
/* Main */

View File

@ -82,6 +82,8 @@
\newenvironment{leftindent}{\begin{quote}}{\end{quote}}
\newenvironment{insetpara}{\begin{quote}}{\end{quote}}
\newenvironment{bibentry}[1]{\parbox[t]{0.8\linewidth}{#1}}
\newenvironment{bigtabular}{\begin{longtable}}{\end{longtable}\vspace{-3ex}}
\newcommand{\bigtabline}{\vspace{-2ex}}

View File

@ -362,6 +362,16 @@ the table can span multiple columns by using @scheme['cont] instead of
a flow in the following columns (i.e., for all but the first in a set
of cells that contain a single flow).
When a table cell's flow has multiple paragraphs, the rendered output
starts each paragraph on its own line, but generally doesn't insert
space between the paragraphs (as it would at the top level). For Latex
output, individual paragraphs are not automatically line-wrapped; to
get a line-wrapped paragraph, use an element with a string style and
define a corresponding Latex macro in terms of @tt{parbox}. For Latex
output of blocks in the flow that are @scheme[blockquote]s,
@scheme[itemization]s, or @scheme[delayed-block]s, the block is
wrapped with @tt{minipage} using @tt{linewidth} as the width.
The @scheme[style] can be any of the following:
@itemize[