From 4911782b56954ab2c14a39599973e7af9ee204b8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 17 Feb 2026 23:55:38 +0100 Subject: [PATCH 1/2] book2: remove unused Pygments syntax highlighting CSS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These rules were introduced in 05cde2511 ("prepare for progit v2", 2014-10-23) when Scott Chacon copied the theme CSS verbatim from the progit/progit2 repository's `theme/html/html.css`. That CSS targeted Pygments syntax highlighting output (manni theme) with selectors like `pre code.go` and `pre[data-code-language="console"]`, matching the HTMLBook format that O'Reilly's Atlas platform produced. The Atlas pipeline was replaced by direct Asciidoctor rendering in bbe6cf17b ("Task for publishing progit2 books from git", 2016-12-30), and the Atlas-based `genbook2` task was dropped entirely in a0a189b64 ("book2.rake: drop "genbook2" task", 2018-09-20), which noted that "Atlas hasn't existed for a few years." Asciidoctor without a `source-highlighter` attribute — and one was never configured in this repository's history — does not produce Pygments token classes. Instead, it emits `` with plain text content (no per-token `` children, and `data-lang` rather than `data-code-language`). This can be verified by downloading the build artifact from the latest "Deploy to GitHub Pages" workflow run via the GitHub API, unpacking it, and searching for any matching HTML elements: # download the `pages` artifact (adjust the artifact ID) gh api repos/git/git-scm.com/actions/artifacts//zip > pages.zip unzip -q pages.zip -d pages-outer mkdir site && tar xzf pages-outer/pages.tar.gz -C site grep -rP 'data-code-language| --- assets/sass/book2.scss | 95 ------------------------------------------ 1 file changed, 95 deletions(-) diff --git a/assets/sass/book2.scss b/assets/sass/book2.scss index ac41e374f8..630b823bec 100644 --- a/assets/sass/book2.scss +++ b/assets/sass/book2.scss @@ -608,99 +608,4 @@ text-indent: 0; } } - - /* syntax highlighting and coloring text in general */ - - /* Pygments with manni theme */ - pre code.hll { background-color: #ffffcc } - pre code.c { color: #0099FF; font-style: italic } /* Comment */ - pre code.err { color: #AA0000 } /* Error */ - pre code.k { color: #006699; font-weight: bold } /* Keyword */ - pre code.o { color: #555555 } /* Operator */ - pre code.cm { color: #35586C; font-style: italic } /* Comment.Multiline */ - pre code.cp { color: #009999 } /* Comment.Preproc */ - pre code.c1 { color: #35586C; font-style: italic } /* Comment.Single */ - pre code.cs { color: #35586C; font-weight: bold; font-style: italic } /* Comment.Special */ - pre code.gd { background-color: #FFCCCC } /* Generic.Deleted */ - pre code.ge { font-style: italic } /* Generic.Emph */ - pre code.gr { color: #FF0000 } /* Generic.Error */ - pre code.gh { color: #003300; font-weight: bold } /* Generic.Heading */ - pre code.gi { background-color: #CCFFCC } /* Generic.Inserted */ - - /* Overriding default manni style of #AAAAAA gray for Generic Output with #000000 black, which is better suited to ORM terminal output */ - pre code.go { color: #000000 } /* Generic.Output */ - - pre code.gp { color: #000099; font-weight: bold } /* Generic.Prompt */ - pre code.gs { font-weight: bold } /* Generic.Strong */ - pre code.gu { color: #003300; font-weight: bold } /* Generic.Subheading */ - pre code.gt { color: #99CC66 } /* Generic.Traceback */ - pre code.kc { color: #006699; font-weight: bold } /* Keyword.Constant */ - pre code.kd { color: #006699; font-weight: bold } /* Keyword.Declaration */ - pre code.kn { color: #006699; font-weight: bold } /* Keyword.Namespace */ - pre code.kp { color: #006699 } /* Keyword.Pseudo */ - pre code.kr { color: #006699; font-weight: bold } /* Keyword.Reserved */ - pre code.kt { color: #007788; font-weight: bold } /* Keyword.Type */ - pre code.m { color: #FF6600 } /* Literal.Number */ - pre code.s { color: #CC3300 } /* Literal.String */ - pre code.na { color: #330099 } /* Name.Attribute */ - pre code.nb { color: #336666 } /* Name.Builtin */ - pre code.nc { color: #00AA88; font-weight: bold } /* Name.Class */ - pre code.no { color: #336600 } /* Name.Constant */ - pre code.nd { color: #9999FF } /* Name.Decorator */ - pre code.ni { color: #999999; font-weight: bold } /* Name.Entity */ - pre code.ne { color: #CC0000; font-weight: bold } /* Name.Exception */ - pre code.nf { color: #CC00FF } /* Name.Function */ - pre code.nl { color: #9999FF } /* Name.Label */ - pre code.nn { color: #00CCFF; font-weight: bold } /* Name.Namespace */ - pre code.nt { color: #330099; font-weight: bold } /* Name.Tag */ - pre code.nv { color: #003333 } /* Name.Variable */ - pre code.ow { color: #000000; font-weight: bold } /* Operator.Word */ - pre code.w { color: #bbbbbb } /* Text.Whitespace */ - pre code.mf { color: #FF6600 } /* Literal.Number.Float */ - pre code.mh { color: #FF6600 } /* Literal.Number.Hex */ - pre code.mi { color: #FF6600 } /* Literal.Number.Integer */ - pre code.mo { color: #FF6600 } /* Literal.Number.Oct */ - pre code.sb { color: #CC3300 } /* Literal.String.Backtick */ - pre code.sc { color: #CC3300 } /* Literal.String.Char */ - pre code.sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */ - pre code.s2 { color: #CC3300 } /* Literal.String.Double */ - pre code.se { color: #CC3300; font-weight: bold } /* Literal.String.Escape */ - pre code.sh { color: #CC3300 } /* Literal.String.Heredoc */ - pre code.si { color: #AA0000 } /* Literal.String.Interpol */ - pre code.sx { color: #CC3300 } /* Literal.String.Other */ - pre code.sr { color: #33AAAA } /* Literal.String.Regex */ - pre code.s1 { color: #CC3300 } /* Literal.String.Single */ - - /* Overriding manni default yellow #FFCC33 with brown #AA6600, which is easier to read */ - pre code.ss { color: #AA6600 } /* Literal.String.Symbol */ - - pre code.bp { color: #336666 } /* Name.Builtin.Pseudo */ - pre code.vc { color: #003333 } /* Name.Variable.Class */ - pre code.vg { color: #003333 } /* Name.Variable.Global */ - pre code.vi { color: #003333 } /* Name.Variable.Instance */ - pre code.il { color: #FF6600 } /* Literal.Number.Integer.Long */ - - /* Sanders's additions to manni */ - pre code.g { color: #005500 } /* Generic */ - pre code.l { color: #CC6600 } /* Literal */ - pre code.l { color: #FF9900 } /* Literal.Date */ - pre code.n { color: #000088 } /* Name */ - pre code.nx { color: #000088 } /* Name.Other */ - pre code.py { color: #9966FF } /* Name.Property */ - pre code.p { color: #000000 } /* Punctuation */ - pre code.x { color: #FF0066 } /* Other */ - - /* Chacon's additions to make command line look more like a command line */ - pre[data-code-language="console"] { - padding: 10px; - background: #eee; - } - pre[data-code-language="console"] code.go { - font-size: 1.0em; - color: #555; - } - pre[data-code-language="console"] code.gp { - font-weight: bold; - color: #009900; - } } From 706212a5ceb7f93cc33ebf84005ec251418715d7 Mon Sep 17 00:00:00 2001 From: Subhajit Date: Sun, 4 Jan 2026 19:13:13 +0530 Subject: [PATCH 2/2] book: fix code styling in dark mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Book pages used hard-coded colors for inline and block code (e.g. `#eee`, `#333`) in `book2.scss`, which prevented dark-mode styles from taking effect. As a result, code blocks in the Git Book did not adapt correctly when switching themes. This change replaces those hard-coded values with CSS variables (`--book-code-bg`, `--book-code-color`, `--book-code-border`), allowing dark mode to override Book code styling in the same way as other sections (e.g. man-pages). Not all `code.` color rules are adjusted here, as they relate to syntax highlighting rather than theme contrast and require a separate, more holistic approach. An alternative approach—overriding Book code styles directly in `dark-mode.scss` using more specific selectors—was considered but rejected, as it would further increase selector complexity instead of fixing the root cause. Fixes https://github.com/git/git-scm.com/issues/2120 Signed-off-by: Johannes Schindelin --- assets/sass/book2.scss | 16 ++++++++++------ assets/sass/dark-mode.scss | 7 +++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/assets/sass/book2.scss b/assets/sass/book2.scss index 630b823bec..f5ba3c4b7b 100644 --- a/assets/sass/book2.scss +++ b/assets/sass/book2.scss @@ -1,4 +1,8 @@ .edition2 { + /* Book code colors (light mode defaults) */ + --book-code-color: #333; + --book-code-bg: #eee; + --book-code-border: #f5f5f5; * { box-sizing: border-box; } @@ -474,11 +478,11 @@ } pre { - background: #eee; + background: var(--book-code-bg); code { display: inline; - background: #eee; + background: var(--book-code-bg); border: 0; } } @@ -488,14 +492,14 @@ overflow-x: auto; font-size: 0.9em; line-height: 120%; - color: #333; + color: var(--book-code-color); } code { /* inline code */ padding: 0; - color: #333; - background: #eee; - border: 1px solid #f5f5f5; + color: var(--book-code-color); + background: var(--book-code-bg); + border: 1px solid var(--book-code-border); } table pre { /* code blocks within tables */ diff --git a/assets/sass/dark-mode.scss b/assets/sass/dark-mode.scss index ff9d4eb6d7..b911ed3a26 100644 --- a/assets/sass/dark-mode.scss +++ b/assets/sass/dark-mode.scss @@ -83,6 +83,13 @@ z-index: -1; } + /* Book pages: code colors */ + .edition2 { + --book-code-color: #{$fixed-width-font-color}; + --book-code-bg: #{$no-changes-bg-color}; + --book-code-border: #{$pre-border}; + } + img { filter: brightness(.6) contrast(1.2); }