From 8002d98e5d93683287dd03f09b024e689fb75eb8 Mon Sep 17 00:00:00 2001
From: Matthew Flatt <mflatt@racket-lang.org>
Date: Fri, 2 Nov 2012 07:39:33 -0600
Subject: [PATCH] scribble: more control over version formatting

Add "Version" in front of a version name via `.version:before' or
`.versionNoNav:before' and `\SVersionBefore', so that they can
be configured through overriding CSS or Latex macro declarations.

Also, improve the documentation for how the `#:version' argument
of `title' is propagated to a `part' style property.

Closes PR 13227

original commit: a830f77403a1f51de7359c7946b01ef10d401cee
---
 collects/scribble/html-render.rkt          |  2 +-
 collects/scribble/scribble.css             |  4 ++++
 collects/scribble/scribble.tex             |  5 +++--
 collects/scribblings/scribble/core.scrbl   |  7 ++++++-
 collects/scribblings/scribble/decode.scrbl | 10 ++++++----
 5 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/collects/scribble/html-render.rkt b/collects/scribble/html-render.rkt
index e8f8ad4d..016fb29d 100644
--- a/collects/scribble/html-render.rkt
+++ b/collects/scribble/html-render.rkt
@@ -890,7 +890,7 @@
                       (list (make-element (if (include-navigation?)
                                               "version"
                                               "versionNoNav")
-                                          (list "Version: " v)))
+                                          v))
                       d
                       ri))))))
 
diff --git a/collects/scribble/scribble.css b/collects/scribble/scribble.css
index 7f502cba..d521d28f 100644
--- a/collects/scribble/scribble.css
+++ b/collects/scribble/scribble.css
@@ -154,6 +154,10 @@ table td {
   font-size: xx-small; /* avoid overlap with author */
 }
 
+.version:before, .versionNoNav:before {
+  content: "Version ";
+}
+
 /* ---------------------------------------- */
 /* Margin notes */
 
diff --git a/collects/scribble/scribble.tex b/collects/scribble/scribble.tex
index e897e143..b7ec1d86 100644
--- a/collects/scribble/scribble.tex
+++ b/collects/scribble/scribble.tex
@@ -141,12 +141,13 @@
 \newenvironment{refcolumnleft}{\begin{refcolumn}}{\end{refcolumn}}
 
 % Macros used by `title' and `author':
-\newcommand{\titleAndVersionAndAuthors}[3]{\title{#1\\{\normalsize Version #2}}\author{#3}\maketitle}
-\newcommand{\titleAndVersionAndEmptyAuthors}[3]{\title{#1\\{\normalsize Version #2}}#3\maketitle}
+\newcommand{\titleAndVersionAndAuthors}[3]{\title{#1\\{\normalsize \SVersionBefore{}#2}}\author{#3}\maketitle}
+\newcommand{\titleAndVersionAndEmptyAuthors}[3]{\title{#1\\{\normalsize \SVersionBefore{}#2}}#3\maketitle}
 \newcommand{\titleAndEmptyVersionAndAuthors}[3]{\title{#1}\author{#3}\maketitle}
 \newcommand{\titleAndEmptyVersionAndEmptyAuthors}[3]{\title{#1}\maketitle}
 \newcommand{\SAuthor}[1]{#1}
 \newcommand{\SAuthorSep}[1]{\qquad}
+\newcommand{\SVersionBefore}[1]{Version }
 
 % Useful for some styles, such as sigalternate:
 \newcommand{\SNumberOfAuthors}[1]{}
diff --git a/collects/scribblings/scribble/core.scrbl b/collects/scribblings/scribble/core.scrbl
index 71cda871..7ded2d58 100644
--- a/collects/scribblings/scribble/core.scrbl
+++ b/collects/scribblings/scribble/core.scrbl
@@ -400,7 +400,12 @@ The recognized @tech{style properties} are as follows:
        not @racket[""] may be used when rendering a document; at a
        minimum, a non-@racket[""] version is rendered when it is
        attached to a part representing the whole document. The default
-       version for a document is @racket[(version)].}
+       version for a document is @racket[(version)]. In rendered form,
+       the version is normally prefixed with the word ``Version,'' but
+       this formatting can be controlled by overriding
+       @tt{.version:before} and/or @tt{.versionNoNav:before} in CSS
+       for HTML rendering or by redefining the @tt{\SVersionBefore}
+       macro for Latex rendering (see @secref["config"]).}
 
  @item{@racket[document-date] structure --- A date for the part,
        normally used on a document's main part for for Latex
diff --git a/collects/scribblings/scribble/decode.scrbl b/collects/scribblings/scribble/decode.scrbl
index 25e9cfaf..2b51d32f 100644
--- a/collects/scribblings/scribble/decode.scrbl
+++ b/collects/scribblings/scribble/decode.scrbl
@@ -168,18 +168,20 @@ otherwise.}
 @defstruct[title-decl ([tag-prefix (or/c #f string?)]
                        [tags (listof string?)]
                        [version (or/c string? #f)]
-                       [style any/c]
+                       [style style?]
                        [content content?])]{
 
-See @racket[decode] and @racket[decode-part]. The @racket[_tag-prefix]
-and @racket[_style] fields are propagated to the resulting
+See @racket[decode] and @racket[decode-part]. The @racket[tag-prefix]
+and @racketidfont{style} fields are propagated to the resulting
+@racket[part]. If the @racketidfont{version} field is not @racket[#f], 
+it is propagated as a @racket[document-version] style property on the
 @racket[part].}
 
 
 @defstruct[part-start ([depth integer?]
                        [tag-prefix (or/c #f string?)]
                        [tags (listof string?)]
-                       [style any/c]
+                       [style style?]
                        [title content?])]{
 
 Like @racket[title-decl], but for a sub-part.  See @racket[decode] and