diff --git a/collects/scribble/basic.ss b/collects/scribble/basic.ss index ddf67325..6f0b1902 100644 --- a/collects/scribble/basic.ss +++ b/collects/scribble/basic.ss @@ -79,6 +79,31 @@ ;; ---------------------------------------- +(provide author + author+email) +(define (author . auths) + (make-styled-paragraph + (let ([nl (make-element 'newline '("\n"))]) + (case (length auths) + [(1) auths] + [(2) (list (car auths) nl "and " (cadr auths))] + [else (let ([r (reverse auths)]) + (append (add-between (reverse (cdr r)) + (make-element #f (list "," nl))) + (list "," nl "and " (car r))))])) + "author")) +(define (author+email name email) + (make-element #f + (list + name + " <" + (regexp-replace* #rx"[.]" + (regexp-replace* #rx"@" email " at ") + " dot ") + ">"))) + +;; ---------------------------------------- + (provide intern-taglet module-path-index->taglet module-path-prefix->string) diff --git a/collects/scribble/latex-render.ss b/collects/scribble/latex-render.ss index 12ee2626..b52d1bb0 100644 --- a/collects/scribble/latex-render.ss +++ b/collects/scribble/latex-render.ss @@ -36,6 +36,13 @@ (copy-port (current-input-port) (current-output-port)))) (printf "\\begin{document}\n\\preDoc\n") (when (part-title-content d) + (let ([m (ormap (lambda (v) + (and (styled-paragraph? v) + (equal? "author" (styled-paragraph-style v)) + v)) + (flow-paragraphs (part-flow d)))]) + (when m + (do-render-paragraph m d ri #t))) (printf "\\titleAndVersion{") (render-content (part-title-content d) d ri) (printf "}{~a}\n" @@ -78,7 +85,9 @@ null)) (define/override (render-paragraph p part ri) - (printf "\n\n") + (do-render-paragraph p part ri #f)) + + (define/private (do-render-paragraph p part ri author?) (let ([style (and (styled-paragraph? p) (let ([s (flatten-style (styled-paragraph-style p))]) @@ -91,13 +100,16 @@ base)) base)) s)))]) - (when (string? style) - (printf "\\~a{" style)) - (if (toc-paragraph? p) - (printf "\\newpage \\tableofcontents \\newpage") - (super render-paragraph p part ri)) - (when (string? style) (printf "}"))) - (printf "\n\n") + (unless (and (not author?) + (equal? style "author")) + (printf "\n\n") + (when (string? style) + (printf "\\~a{" style)) + (if (toc-paragraph? p) + (printf "\\newpage \\tableofcontents \\newpage") + (super render-paragraph p part ri)) + (when (string? style) (printf "}")) + (printf "\n\n"))) null) (define/override (render-element e part ri) diff --git a/collects/scribble/scribble.css b/collects/scribble/scribble.css index 1232a896..9e484583 100644 --- a/collects/scribble/scribble.css +++ b/collects/scribble/scribble.css @@ -491,3 +491,17 @@ i { .noborder img { border: 0; } + +.author { + position: relative; + float: right; + left: 2em; + top: -3em; + height: 0em; + width: 23em; /* very wide to keep author names on separate lines */ + margin: 0em -23em 0em 0em; + font-size: 82%; +} +.author:before { + content: "by "; +} \ No newline at end of file diff --git a/collects/scribblings/scribble/basic.scrbl b/collects/scribblings/scribble/basic.scrbl index 0f55f83f..1cadefdb 100644 --- a/collects/scribblings/scribble/basic.scrbl +++ b/collects/scribblings/scribble/basic.scrbl @@ -127,6 +127,18 @@ Returns @scheme[#t] if @scheme[v] is an item produced by visible to the enclosing context). Since this form expands to @scheme[require], it must be used in a module or top-level context.} +@defproc[(author [author any/c] ...) block?]{ + +Generates a @scheme[styled-paragraph] to show the author(s) of a +document, where each author is represented by an +@tech{element}. Normally, this function is used after @scheme[title] +for the beginning of a document. See also @scheme[author+email].} + +@defproc[(author+email [author elem] [email string?]) element?]{ + +Combines an author name with an e-mail address, obscuring the e-mail +address slightly to avoid address-harvesting robots.} + @defproc[(module-path-prefix->string [mod-path module-path?]) string?]{ diff --git a/collects/scribblings/scribble/scribble.scrbl b/collects/scribblings/scribble/scribble.scrbl index 23ba5365..e6b999fc 100644 --- a/collects/scribblings/scribble/scribble.scrbl +++ b/collects/scribblings/scribble/scribble.scrbl @@ -5,6 +5,8 @@ @title{@bold{Scribble}: PLT Documentation Tool} +@author["Matthew Flatt" "Eli Barzilay"] + Scribble is a collection of tools for creating prose documents, especially those that document libraries, and especially for HTML and PDF (via LaTeX) output. More generally, it is useful for cases where