scribble: add support for setting a document date
in Latex output, and also document and generalize the 'pretitle paragraph style original commit: 66178570b6f13fe2f6163d7b15e9e4118a4d0bad
This commit is contained in:
parent
dc3a4f59e8
commit
e4f618d24d
|
@ -139,11 +139,17 @@
|
|||
|
||||
(define/public (extract-version d)
|
||||
(or (ormap (lambda (v)
|
||||
(and (document-version? v)
|
||||
(document-version-text v)))
|
||||
(and (document-version? v)
|
||||
(document-version-text v)))
|
||||
(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)
|
||||
(let loop ([l (part-blocks d)])
|
||||
(cond
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
(#:tag (or/c #f string? (listof string?))
|
||||
#:tag-prefix (or/c #f string? module-path?)
|
||||
#: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?)
|
||||
title-decl?)]
|
||||
[section (title-like-contract)]
|
||||
|
@ -60,12 +61,18 @@
|
|||
[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]
|
||||
#:version [version #f] . str)
|
||||
#:version [version #f] #:date [date #f]
|
||||
. str)
|
||||
(let ([content (decode-content str)])
|
||||
(make-title-decl (prefix->string prefix)
|
||||
(convert-tag tag content)
|
||||
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)))
|
||||
|
||||
(define (section #:tag [tag #f] #:tag-prefix [prefix #f] #:style [style plain]
|
||||
|
|
|
@ -176,6 +176,7 @@
|
|||
[properties list?])]
|
||||
;; properties:
|
||||
[document-version ([text (or/c string? false/c)])]
|
||||
[document-date ([text (or/c string? false/c)])]
|
||||
[target-url ([addr path-string?])]
|
||||
[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
|
||||
extract-part-style-files
|
||||
extract-version
|
||||
extract-date
|
||||
extract-authors
|
||||
extract-pretitle)
|
||||
|
||||
|
@ -93,10 +94,13 @@
|
|||
(printf "\\begin{document}\n\\preDoc\n")
|
||||
(when (part-title-content d)
|
||||
(let ([vers (extract-version d)]
|
||||
[date (extract-date d)]
|
||||
[pres (extract-pretitle d)]
|
||||
[auths (extract-authors d)])
|
||||
(for ([pre (in-list pres)])
|
||||
(printf "\n\n")
|
||||
(do-render-paragraph pre d ri #t))
|
||||
(when date (printf "\\date{~a}\n" date))
|
||||
(printf "\\titleAnd~aVersionAnd~aAuthors{"
|
||||
(if (equal? vers "") "Empty" "")
|
||||
(if (null? auths) "Empty" ""))
|
||||
|
@ -115,6 +119,10 @@
|
|||
(when (and (part-title-content d) (pair? number))
|
||||
(when (eq? (style-name (part-style d)) 'index)
|
||||
(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)
|
||||
(or (not (car number))
|
||||
((length number) . > . 3)))])
|
||||
|
|
|
@ -65,6 +65,7 @@ have @racketmodname[scribble/manual]).
|
|||
[#:tag-prefix tag-prefix (or/c false/c string? module-path?) #f]
|
||||
[#:style style (or/c style? #f string? symbol? (listof symbol?)) #f]
|
||||
[#:version vers (or/c string? false/c) #f]
|
||||
[#:date date (or/c string? false/c) #f]
|
||||
[pre-content pre-content?] ...+)
|
||||
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
|
||||
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
|
||||
@racket[decode-part]. For the index key, leading whitespace and a
|
||||
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
|
||||
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
|
||||
string @tt{id} attribute of the @tt{body} tag; this style can
|
||||
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
|
||||
title.}
|
||||
|
||||
@item{@racket['pretitle] --- Typeset before the title of the
|
||||
enclosing part.}
|
||||
|
||||
]
|
||||
|
||||
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)])]{
|
||||
|
||||
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.}
|
||||
|
||||
|
||||
@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?))])]{
|
||||
|
||||
Used as a @tech{style property} for an @racket[element] to set its
|
||||
|
|
Loading…
Reference in New Issue
Block a user