diff --git a/scribble-doc/scribblings/scribble/core.scrbl b/scribble-doc/scribblings/scribble/core.scrbl index e928d2d244..e8ae765011 100644 --- a/scribble-doc/scribblings/scribble/core.scrbl +++ b/scribble-doc/scribblings/scribble/core.scrbl @@ -597,6 +597,9 @@ The recognized @tech{style properties} are as follows: multiple @litchar{,}-separated labels and generate a suitable set of references. See also @racketmodname[scriblib/book-index].} + @item{@racket[initial-scale] structure --- For HTML, adjusts the initial + scale for responsive views, such as on mobile devices.} + ] The @racket[to-collect] field contains @techlink{content} that is @@ -1984,6 +1987,14 @@ via @racket[head-addition] appear before additions via @racket[head-extra]. @history[#:added "1.38"]} +@defstruct[initial-scale ([value (real-in 0.0 10.0)])]{ + +Adjusts @litchar{initial-scale} in a @litchar{meta} tag with name +@litchar{viewport}. The default is @racket[1.0]. + +@history[#:added "1.61"]} + + @defstruct[render-convertible-as ([types (listof (or/c 'png-bytes 'svg-bytes 'gif-bytes))])]{ For a @racket[part] that corresponds to an HTML page, controls how objects that subscribe to the @racketmodname[file/convertible] diff --git a/scribble-doc/scribblings/scribble/manual.scrbl b/scribble-doc/scribblings/scribble/manual.scrbl index 02655cb5d3..653a4932d2 100644 --- a/scribble-doc/scribblings/scribble/manual.scrbl +++ b/scribble-doc/scribblings/scribble/manual.scrbl @@ -4,7 +4,9 @@ (for-label scribble/manual-struct racket/list version/utils - syntax/quote)) + syntax/quote + (only-in scribble/html-properties + initial-scale))) @(define lit-ellipses (racket ...)) @(define lit-ellipses+ (racket ...+)) @@ -2500,6 +2502,9 @@ For HTML rendering: @filepath{scribble} collection is added as a @racket[css-style-addition].} + @item{The document's initial scale (for responsive modes such as mobile + devices) via a @racket[(initial-scale "0.8")] style property.} + ] To obtain this configuration without using @racket[@#,hash-lang[] diff --git a/scribble-lib/scribble/html-properties.rkt b/scribble-lib/scribble/html-properties.rkt index 25382f6f3a..23ccbe3bc8 100644 --- a/scribble-lib/scribble/html-properties.rkt +++ b/scribble-lib/scribble/html-properties.rkt @@ -33,4 +33,5 @@ [head-extra ([xexpr xexpr/c])] [head-addition ([xexpr xexpr/c])] + [initial-scale ([value (real-in 0.0 10.0)])] [render-convertible-as ([types (listof (or/c 'png-bytes 'svg-bytes 'gif-bytes))])]) diff --git a/scribble-lib/scribble/html-render.rkt b/scribble-lib/scribble/html-render.rkt index 8403ebce69..b5ba0fe10c 100644 --- a/scribble-lib/scribble/html-render.rkt +++ b/scribble-lib/scribble/html-render.rkt @@ -828,6 +828,9 @@ (define/public (extract-show-language-family d ri) (extract-inherited d ri (lambda (v) (eq? v 'show-language-family)) values)) + (define/public (extract-part-initial-scale d ri) + (extract-inherited d ri initial-scale? initial-scale-value)) + (define/public (part-nesting-depth d ri) 0) @@ -883,12 +886,17 @@ (copy-port in (current-output-port))))) (parameterize ([xml:empty-tag-shorthand xml:html-empty-tags]) (xml:write-xexpr + ;; Adding newlines before `>` closers can make editing + ;; the generated HTML (for experiments) nicer: + ;; #:insert-newlines? #t `(html ,(style->attribs (part-style d)) (head () (meta ([http-equiv "content-type"] [content "text/html; charset=utf-8"])) (meta ([name "viewport"] - [content "width=device-width, initial-scale=0.8"])) + [content ,(format "width=device-width, initial-scale=~a" + (or (extract-part-initial-scale d ri) + "1.0"))])) ,title ,(scribble-css-contents scribble-css scribble-css-path diff --git a/scribble-lib/scribble/manual-style.css b/scribble-lib/scribble/manual-style.css index e30c4da1ed..752137225d 100644 --- a/scribble-lib/scribble/manual-style.css +++ b/scribble-lib/scribble/manual-style.css @@ -318,6 +318,7 @@ a:hover { position: sticky; top: 0; left: 100%; + width: 13em; margin-top: -4.75em; margin-right: -15em; font-size: 70%; diff --git a/scribble-lib/scribble/private/manual-defaults.rkt b/scribble-lib/scribble/private/manual-defaults.rkt index ce68f6507f..fae41c34ec 100644 --- a/scribble-lib/scribble/private/manual-defaults.rkt +++ b/scribble-lib/scribble/private/manual-defaults.rkt @@ -20,7 +20,8 @@ (css-style-addition (scribble-file "manual-racket.css")) (js-style-addition - (scribble-file "manual-racket.js"))) + (scribble-file "manual-racket.js")) + (initial-scale 0.8)) #t)) (define-on-demand manual-doc-style diff --git a/scribble-lib/scribble/scribble.css b/scribble-lib/scribble/scribble.css index d465c2032d..28ae1d5faa 100644 --- a/scribble-lib/scribble/scribble.css +++ b/scribble-lib/scribble/scribble.css @@ -218,8 +218,8 @@ table td { white-space: nowrap; left: 2em; height: 0em; - width: 13em; - margin: 0em -13em 0em 0em; + width: 10.5em; + margin: 1.5em -13em 0em 0em; font-size: small; } @@ -282,6 +282,15 @@ table td { margin: 0 0 0 0; } +/* narrow display => inline right-hand margin notes */ +@media screen and (max-width: 55em) { + .refpara, .refelem, .reffootnote { + all: unset !important; + display: block !important; + margin: 1em 0 !important; + padding: 0.75em !important; + } +} /* ---------------------------------------- */ /* Table of contents, inline */