Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions scribble-doc/scribblings/scribble/base.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,20 @@ 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.
structure via a @racket[document-date] @tech{style property}.
In HTML output, a nonempty date is shown in the version box.
In LaTeX output, a supplied date is passed to the @tt{\date} command.
If @racket[date] is @racket[#f] (the default), HTML omits the date
and LaTeX uses the document class's default, typically @tt{\today}.
Use @racket[""] as @racket[date] to suppress the date in both formats.

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
removed.}

@history[#:changed "1.70"
@elem{A nonempty @racket[#:date] is now displayed in HTML output.}]

@def-section-like[section part-start?]{ Like @racket[title], but
generates a @racket[part-start] of depth @racket[0] to be picked up by
Expand Down
2 changes: 1 addition & 1 deletion scribble-lib/info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

(define pkg-authors '(mflatt eli))

(define version "1.69")
(define version "1.70")

(define license
'((Apache-2.0 OR MIT)
Expand Down
34 changes: 21 additions & 13 deletions scribble-lib/scribble/html-render.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
quiet-table-of-contents
extract-part-style-files
extract-version
extract-date
extract-authors
extract-pretitle
extend-part-context
Expand Down Expand Up @@ -1132,19 +1133,26 @@
(render-one-part d ri fn null))

(define/public (render-version d ri)
(let ([v (current-version)])
(if (equal? v "")
;; don't show empty version:
null
;; show version:
`((div ([class "versionbox"])
,@(render-content
(list (make-element (if (include-navigation?)
"version"
"versionNoNav")
v))
d
ri))))))
(define v (current-version))
(define date (extract-date d))
(define show-version? (not (equal? v "")))
(define show-date? (and date (not (equal? date ""))))
(if (or show-version? show-date?)
`((div ([class "versionbox"])
,@(if show-version?
(render-content
(list (make-element (if (include-navigation?)
"version"
"versionNoNav")
v))
d
ri)
null)
,@(if (and show-version? show-date?) '(" ") null)
,@(if show-date?
`((div ([class "document-date"]) ,date))
null)))
null))

(define/private (render-language-family d ri)
(define show-fam? (extract-show-language-family d ri))
Expand Down
9 changes: 9 additions & 0 deletions scribble-lib/scribble/scribble.css
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ table td {
.version:before, .versionNoNav:before {
content: "Version ";
}
.versionbox .document-date {
display: block;
font-family: sans-serif;
font-size: small;
}
.versionNoNav + .document-date {
font-size: xx-small;
}


/* ---------------------------------------- */
/* Language Family */
Expand Down
26 changes: 16 additions & 10 deletions scribble-lib/scriblib/autobib.tex
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,23 @@
\ifnum\AutobibNeedlines>0
\Needspace{\AutobibNeedlines\baselineskip}%
\fi
\begingroup
\AutobibEntrySetup
\leftskip=\ABindent
\parindent=\AutobibParindent
\parskip=0pt
\noindent
\hspace*{-\ABindent}%
\ignorespaces
\begin{list}{}{%
\setlength{\leftmargin}{\ABindent}%
\setlength{\rightmargin}{0pt}%
\setlength{\itemindent}{-\ABindent}%
\setlength{\listparindent}{\AutobibParindent}%
\setlength{\labelwidth}{0pt}%
\setlength{\labelsep}{0pt}%
\setlength{\topsep}{0pt}%
\setlength{\partopsep}{0pt}%
\setlength{\parsep}{0pt}%
\setlength{\itemsep}{0pt}%
}%
\AutobibEntrySetup
\item\relax
\ignorespaces
}{%
\par
\endgroup
\end{list}%
\addvspace{1ex}%
}

Expand Down
40 changes: 39 additions & 1 deletion scribble-test/tests/scribble/html-render.rkt
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#lang racket/base

(require racket/class
racket/file
rackunit
scribble/base
scribble/base-render
scribble/core
(only-in scribble/decode decode)
scribble/html-properties
(prefix-in html: scribble/html-render))
(prefix-in html: scribble/html-render)
(only-in scribble/render render))

(define renderer
(new (html:render-mixin render%)
Expand Down Expand Up @@ -61,3 +64,38 @@
(check-equal?
(render-content (elem #:style "emph" "custom style"))
'((span ((class "emph")) "custom style"))))

(define (render-title version date)
(define dest (make-temporary-directory))
(dynamic-wind
void
(lambda ()
(define doc
(decode (list (title #:version version #:date date "Example"))))
(render (list doc) (list "example")
#:render-mixin html:render-mixin
#:dest-dir dest)
(file->string (build-path dest "example.html")))
(lambda () (delete-directory/files dest))))

(test-case "document date in the HTML version box"
(define date "2026-11-09")
(define date-element
#rx"<div class=\"document-date\">2026-11-09</div>")
(define version-class #rx"class=\"versionNoNav\"")
(define date-only (render-title "" date))

(check-true
(regexp-match?
#px"class=\"versionNoNav\">1\\.2\\.3</span>\\s*<div class=\"document-date\">2026-11-09</div>"
(render-title "1.2.3" date)))
(check-true (regexp-match? date-element date-only))
(check-false (regexp-match? version-class date-only))

(for ([absent-date (in-list (list #f ""))])
(define version-only (render-title "1.2.3" absent-date))
(check-true (regexp-match? version-class version-only))
(check-false (regexp-match? #rx"class=\"document-date\"" version-only)))

(check-false
(regexp-match? #rx"class=\"versionbox\"" (render-title "" ""))))
Loading