From d99a7f11d2675f8fc618151853a685731da9a136 Mon Sep 17 00:00:00 2001 From: Zoom Date: Mon, 23 Mar 2026 16:00:07 +0400 Subject: [PATCH] nimdoc: CSS: tighter on mobile; fix h1 print page break (#25607) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Small optimizations for mobile, makes code render slightly tighter. - `font-stretch: semi-condensed;` for pre works if the user's font provides such a face, shouldn’t change the rendering with the default. - Removes an excessive page break after the page header when printing. Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> (cherry picked from commit 446d903fc1f0330d4b273580c747945ffd7e1cc6) --- doc/nimdoc.css | 31 ++++++++++++++++++++++ nimdoc/testproject/expected/nimdoc.out.css | 31 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/doc/nimdoc.css b/doc/nimdoc.css index ff77a51cb8..f4ac27b28d 100644 --- a/doc/nimdoc.css +++ b/doc/nimdoc.css @@ -259,6 +259,8 @@ body { body { font-size: 1em; line-height: 1.35; + margin-left: 0.35em; + margin-right: 0.35em; } } @@ -417,6 +419,10 @@ img { h1.title { page-break-before: avoid; } + + .nine.columns h1:first-of-type { + page-break-before: avoid; + } p, h2, h3 { orphans: 3; @@ -484,6 +490,22 @@ h5 { h6 { font-size: 1.1em; } +@media screen and (max-width: 860px) { + h1.title { + font-size: 2em; + } + h1 { + font-size: 1.5em; + margin-top: 1.5em; + margin-bottom: 0.75em; + } + h2 { + margin-top: 1.3em; + } + h3 { + margin-top: 1.2em; + } +} ul, ol { padding: 0; @@ -667,6 +689,15 @@ pre { border-radius: 6px; } +@media screen and (max-width: 860px) { + pre { + font-stretch: semi-condensed; + letter-spacing: -0.25px; + line-height: 1.25; + padding: 0.33em; + } +} + .copyToClipBoardBtn { visibility: hidden; position: absolute; diff --git a/nimdoc/testproject/expected/nimdoc.out.css b/nimdoc/testproject/expected/nimdoc.out.css index ff77a51cb8..f4ac27b28d 100644 --- a/nimdoc/testproject/expected/nimdoc.out.css +++ b/nimdoc/testproject/expected/nimdoc.out.css @@ -259,6 +259,8 @@ body { body { font-size: 1em; line-height: 1.35; + margin-left: 0.35em; + margin-right: 0.35em; } } @@ -417,6 +419,10 @@ img { h1.title { page-break-before: avoid; } + + .nine.columns h1:first-of-type { + page-break-before: avoid; + } p, h2, h3 { orphans: 3; @@ -484,6 +490,22 @@ h5 { h6 { font-size: 1.1em; } +@media screen and (max-width: 860px) { + h1.title { + font-size: 2em; + } + h1 { + font-size: 1.5em; + margin-top: 1.5em; + margin-bottom: 0.75em; + } + h2 { + margin-top: 1.3em; + } + h3 { + margin-top: 1.2em; + } +} ul, ol { padding: 0; @@ -667,6 +689,15 @@ pre { border-radius: 6px; } +@media screen and (max-width: 860px) { + pre { + font-stretch: semi-condensed; + letter-spacing: -0.25px; + line-height: 1.25; + padding: 0.33em; + } +} + .copyToClipBoardBtn { visibility: hidden; position: absolute;