scribble HTML: add head-extra' and support for attributes'

For a part that corresponds to an HTML page.

original commit: dc925d2d8cb4802281981cd3a271c07f74234c4d
This commit is contained in:
Matthew Flatt 2012-09-11 17:18:14 -06:00
parent 92b715cb96
commit f470e3c3a7
3 changed files with 26 additions and 6 deletions

View File

@ -1,6 +1,7 @@
#lang scheme/base #lang scheme/base
(require "private/provide-structs.rkt" (require "private/provide-structs.rkt"
racket/contract/base) racket/contract/base
xml/xexpr)
(provide-structs (provide-structs
[body-id ([value string?])] [body-id ([value string?])]
@ -15,4 +16,6 @@
[url-anchor ([name string?])] [url-anchor ([name string?])]
[alt-tag ([name (and/c string? #rx"^[a-zA-Z0-9]+$")])] [alt-tag ([name (and/c string? #rx"^[a-zA-Z0-9]+$")])]
[attributes ([assoc (listof (cons/c symbol? string?))])] [attributes ([assoc (listof (cons/c symbol? string?))])]
[column-attributes ([assoc (listof (cons/c symbol? string?))])]) [column-attributes ([assoc (listof (cons/c symbol? string?))])]
[head-extra ([xexpr xexpr/c])])

View File

@ -664,7 +664,7 @@
(copy-port in (current-output-port))))) (copy-port in (current-output-port)))))
(parameterize ([xml:empty-tag-shorthand xml:html-empty-tags]) (parameterize ([xml:empty-tag-shorthand xml:html-empty-tags])
(xml:write-xexpr (xml:write-xexpr
`(html () `(html ,(style->attribs (part-style d))
(head () (head ()
(meta ([http-equiv "content-type"] (meta ([http-equiv "content-type"]
[content "text-html; charset=utf-8"])) [content "text-html; charset=utf-8"]))
@ -686,7 +686,10 @@
(list style-file) (list style-file)
style-extra-files)) style-extra-files))
,(scribble-js-contents script-file (lookup-path script-file alt-paths)) ,(scribble-js-contents script-file (lookup-path script-file alt-paths))
,(xml:comment "[if IE 6]><style type=\"text/css\">.SIEHidden { overflow: hidden; }</style><![endif]")) ,(xml:comment "[if IE 6]><style type=\"text/css\">.SIEHidden { overflow: hidden; }</style><![endif]")
,@(for/list ([p (style-properties (part-style d))]
#:when (head-extra? p))
(head-extra-xexpr p)))
(body ([id ,(or (extract-part-body-id d ri) (body ([id ,(or (extract-part-body-id d ri)
"scribble-racket-lang-org")]) "scribble-racket-lang-org")])
,@(render-toc-view d ri) ,@(render-toc-view d ri)

View File

@ -4,7 +4,8 @@
(for-label scribble/manual-struct (for-label scribble/manual-struct
file/convertible file/convertible
setup/main-collects setup/main-collects
scriblib/render-cond)) scriblib/render-cond
xml/xexpr))
@title[#:tag "core"]{Structures And Processing} @title[#:tag "core"]{Structures And Processing}
@ -407,13 +408,21 @@ The recognized @tech{style properties} are as follows:
@racket[""] to suppress a date in an output document.} @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,
otherwise it is effectively inherited by sub-parts; the otherwise it is effectively inherited by sub-parts; the
default is @racket["scribble-racket-lang.org"], but default is @racket["scribble-racket-lang.org"], but
@exec{setup-plt} installs @racket["doc-racket-lang.org"] as the @exec{setup-plt} installs @racket["doc-racket-lang.org"] as the
@tt{id} for any document that it builds.} @tt{id} for any document that it builds.}
@item{@racket[attributes] structure --- Provides additional HTML
attributes for the @tt{<html>} tag when the part corresponds to
its own HTML page.}
@item{@racket[head-extra] structure --- Provides additional HTML
content for the @tt{<head>} tag when the part corresponds to
its own HTML page.}
] ]
The @racket[to-collect] field contains @techlink{content} that is The @racket[to-collect] field contains @techlink{content} that is
@ -1414,6 +1423,11 @@ Like @racket[latex-defaults], but use for the
@DFlag{htmls} modes.} @DFlag{htmls} modes.}
@defstruct[head-extra ([xexpr xexpr/c])]{
For a @racket[part] that corresponds to an HTML page, adds content to
the @tt{<head>} tag.}
@; ---------------------------------------- @; ----------------------------------------
@section{Latex Style Properties} @section{Latex Style Properties}