scribble: add support for setting a document date
in Latex output, and also document and generalize the 'pretitle paragraph style
This commit is contained in:
parent
479e8cdc27
commit
66178570b6
|
@ -144,6 +144,12 @@
|
||||||
(style-properties (part-style d)))
|
(style-properties (part-style d)))
|
||||||
""))
|
""))
|
||||||
|
|
||||||
|
(define/public (extract-date d)
|
||||||
|
(ormap (lambda (v)
|
||||||
|
(and (document-date? v)
|
||||||
|
(document-date-text v)))
|
||||||
|
(style-properties (part-style d))))
|
||||||
|
|
||||||
(define/private (extract-pre-paras d sym)
|
(define/private (extract-pre-paras d sym)
|
||||||
(let loop ([l (part-blocks d)])
|
(let loop ([l (part-blocks d)])
|
||||||
(cond
|
(cond
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
(#:tag (or/c #f string? (listof string?))
|
(#:tag (or/c #f string? (listof string?))
|
||||||
#:tag-prefix (or/c #f string? module-path?)
|
#:tag-prefix (or/c #f string? module-path?)
|
||||||
#:style (or/c style? string? symbol? (listof symbol?) #f)
|
#:style (or/c style? string? symbol? (listof symbol?) #f)
|
||||||
#:version (or/c string? #f))
|
#:version (or/c string? #f)
|
||||||
|
#:date (or/c string? #f))
|
||||||
#:rest (listof pre-content?)
|
#:rest (listof pre-content?)
|
||||||
title-decl?)]
|
title-decl?)]
|
||||||
[section (title-like-contract)]
|
[section (title-like-contract)]
|
||||||
|
@ -60,12 +61,18 @@
|
||||||
[else (raise-type-error who "style, string, symbol, list of symbols, or #f" s)]))
|
[else (raise-type-error who "style, string, symbol, list of symbols, or #f" s)]))
|
||||||
|
|
||||||
(define (title #:tag [tag #f] #:tag-prefix [prefix #f] #:style [style plain]
|
(define (title #:tag [tag #f] #:tag-prefix [prefix #f] #:style [style plain]
|
||||||
#:version [version #f] . str)
|
#:version [version #f] #:date [date #f]
|
||||||
|
. str)
|
||||||
(let ([content (decode-content str)])
|
(let ([content (decode-content str)])
|
||||||
(make-title-decl (prefix->string prefix)
|
(make-title-decl (prefix->string prefix)
|
||||||
(convert-tag tag content)
|
(convert-tag tag content)
|
||||||
version
|
version
|
||||||
(convert-part-style 'title style)
|
(let ([s (convert-part-style 'title style)])
|
||||||
|
(if date
|
||||||
|
(make-style (style-name s)
|
||||||
|
(cons (make-document-date date)
|
||||||
|
(style-properties s)))
|
||||||
|
s))
|
||||||
content)))
|
content)))
|
||||||
|
|
||||||
(define (section #:tag [tag #f] #:tag-prefix [prefix #f] #:style [style plain]
|
(define (section #:tag [tag #f] #:tag-prefix [prefix #f] #:style [style plain]
|
||||||
|
|
|
@ -176,6 +176,7 @@
|
||||||
[properties list?])]
|
[properties list?])]
|
||||||
;; properties:
|
;; properties:
|
||||||
[document-version ([text (or/c string? false/c)])]
|
[document-version ([text (or/c string? false/c)])]
|
||||||
|
[document-date ([text (or/c string? false/c)])]
|
||||||
[target-url ([addr path-string?])]
|
[target-url ([addr path-string?])]
|
||||||
[color-property ([color (or/c string? (list/c byte? byte? byte?))])]
|
[color-property ([color (or/c string? (list/c byte? byte? byte?))])]
|
||||||
[background-color-property ([color (or/c string? (list/c byte? byte? byte?))])]
|
[background-color-property ([color (or/c string? (list/c byte? byte? byte?))])]
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
format-number
|
format-number
|
||||||
extract-part-style-files
|
extract-part-style-files
|
||||||
extract-version
|
extract-version
|
||||||
|
extract-date
|
||||||
extract-authors
|
extract-authors
|
||||||
extract-pretitle)
|
extract-pretitle)
|
||||||
|
|
||||||
|
@ -93,10 +94,13 @@
|
||||||
(printf "\\begin{document}\n\\preDoc\n")
|
(printf "\\begin{document}\n\\preDoc\n")
|
||||||
(when (part-title-content d)
|
(when (part-title-content d)
|
||||||
(let ([vers (extract-version d)]
|
(let ([vers (extract-version d)]
|
||||||
|
[date (extract-date d)]
|
||||||
[pres (extract-pretitle d)]
|
[pres (extract-pretitle d)]
|
||||||
[auths (extract-authors d)])
|
[auths (extract-authors d)])
|
||||||
(for ([pre (in-list pres)])
|
(for ([pre (in-list pres)])
|
||||||
|
(printf "\n\n")
|
||||||
(do-render-paragraph pre d ri #t))
|
(do-render-paragraph pre d ri #t))
|
||||||
|
(when date (printf "\\date{~a}\n" date))
|
||||||
(printf "\\titleAnd~aVersionAnd~aAuthors{"
|
(printf "\\titleAnd~aVersionAnd~aAuthors{"
|
||||||
(if (equal? vers "") "Empty" "")
|
(if (equal? vers "") "Empty" "")
|
||||||
(if (null? auths) "Empty" ""))
|
(if (null? auths) "Empty" ""))
|
||||||
|
@ -115,6 +119,10 @@
|
||||||
(when (and (part-title-content d) (pair? number))
|
(when (and (part-title-content d) (pair? number))
|
||||||
(when (eq? (style-name (part-style d)) 'index)
|
(when (eq? (style-name (part-style d)) 'index)
|
||||||
(printf "\\twocolumn\n\\parskip=0pt\n\\addcontentsline{toc}{section}{Index}\n"))
|
(printf "\\twocolumn\n\\parskip=0pt\n\\addcontentsline{toc}{section}{Index}\n"))
|
||||||
|
(let ([pres (extract-pretitle d)])
|
||||||
|
(for ([pre (in-list pres)])
|
||||||
|
(printf "\n\n")
|
||||||
|
(do-render-paragraph pre d ri #t)))
|
||||||
(let ([no-number? (and (pair? number)
|
(let ([no-number? (and (pair? number)
|
||||||
(or (not (car number))
|
(or (not (car number))
|
||||||
((length number) . > . 3)))])
|
((length number) . > . 3)))])
|
||||||
|
|
|
@ -65,6 +65,7 @@ have @racketmodname[scribble/manual]).
|
||||||
[#:tag-prefix tag-prefix (or/c false/c string? module-path?) #f]
|
[#:tag-prefix tag-prefix (or/c false/c string? module-path?) #f]
|
||||||
[#:style style (or/c style? #f string? symbol? (listof symbol?)) #f]
|
[#:style style (or/c style? #f string? symbol? (listof symbol?)) #f]
|
||||||
[#:version vers (or/c string? false/c) #f]
|
[#:version vers (or/c string? false/c) #f]
|
||||||
|
[#:date date (or/c string? false/c) #f]
|
||||||
[pre-content pre-content?] ...+)
|
[pre-content pre-content?] ...+)
|
||||||
title-decl?]{
|
title-decl?]{
|
||||||
|
|
||||||
|
@ -92,6 +93,11 @@ The @racket[vers] argument is propagated to the @racket[title-decl]
|
||||||
structure. Use @racket[""] as @racket[vers] to suppress version
|
structure. Use @racket[""] as @racket[vers] to suppress version
|
||||||
rendering in the output.
|
rendering in the output.
|
||||||
|
|
||||||
|
The @racket[date] argument is propagated to the @racket[title-decl]
|
||||||
|
structure via a @racket[document-date] @tech{style property}. Use
|
||||||
|
@racket[""] as @racket[date] to suppress date rendering in Latex
|
||||||
|
output.
|
||||||
|
|
||||||
The section title is automatically indexed by
|
The section title is automatically indexed by
|
||||||
@racket[decode-part]. For the index key, leading whitespace and a
|
@racket[decode-part]. For the index key, leading whitespace and a
|
||||||
leading ``A'', ``An'', or ``The'' (followed by more whitespace) is
|
leading ``A'', ``An'', or ``The'' (followed by more whitespace) is
|
||||||
|
|
|
@ -369,6 +369,13 @@ The recognized @tech{style properties} are as follows:
|
||||||
attached to a part representing the whole document. The default
|
attached to a part representing the whole document. The default
|
||||||
version for a document is @racket[(version)].}
|
version for a document is @racket[(version)].}
|
||||||
|
|
||||||
|
@item{@racket[document-date] structure --- A date for the part,
|
||||||
|
normally used on a document's main part for for Latex
|
||||||
|
output. The default date for a document is @racket[#f], which
|
||||||
|
avoids explicitly specifying a date at the Latex level, so that
|
||||||
|
the current date is used as the document date. Set the date to
|
||||||
|
@racket[""] to suppress a date in an output document.}
|
||||||
|
|
||||||
@item{@racket[body-id] structure --- Generated HTML uses the given
|
@item{@racket[body-id] structure --- Generated HTML uses the given
|
||||||
string @tt{id} attribute of the @tt{body} tag; this style can
|
string @tt{id} attribute of the @tt{body} tag; this style can
|
||||||
be set separately for parts that start different HTML pages,
|
be set separately for parts that start different HTML pages,
|
||||||
|
@ -408,6 +415,9 @@ recognized:
|
||||||
by the Latex renderer by moving the author information to the
|
by the Latex renderer by moving the author information to the
|
||||||
title.}
|
title.}
|
||||||
|
|
||||||
|
@item{@racket['pretitle] --- Typeset before the title of the
|
||||||
|
enclosing part.}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
The currently recognized @tech{style properties} are as follows:
|
The currently recognized @tech{style properties} are as follows:
|
||||||
|
@ -918,10 +928,16 @@ than a file path.}
|
||||||
|
|
||||||
@defstruct[document-version ([text (or/c string? false/c)])]{
|
@defstruct[document-version ([text (or/c string? false/c)])]{
|
||||||
|
|
||||||
Used as a @tech{style property} for a @racket[path] to indicate a
|
Used as a @tech{style property} for a @racket[part] to indicate a
|
||||||
version number.}
|
version number.}
|
||||||
|
|
||||||
|
|
||||||
|
@defstruct[document-date ([text (or/c string? false/c)])]{
|
||||||
|
|
||||||
|
Used as a @tech{style property} for a @racket[part] to indicate a
|
||||||
|
date (which is typically used for Latex output).}
|
||||||
|
|
||||||
|
|
||||||
@defstruct[color-property ([color (or/c string? (list/c byte? byte? byte?))])]{
|
@defstruct[color-property ([color (or/c string? (list/c byte? byte? byte?))])]{
|
||||||
|
|
||||||
Used as a @tech{style property} for an @racket[element] to set its
|
Used as a @tech{style property} for an @racket[element] to set its
|
||||||
|
|
Loading…
Reference in New Issue
Block a user