You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2026/04/16 15:27:10 UTC

(airflow-site) branch fix-code-block-syntax-highlighting created (now ec060d8a9f)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a change to branch fix-code-block-syntax-highlighting
in repository https://gitbox.apache.org/repos/asf/airflow-site.git


      at ec060d8a9f Fix code block syntax highlighting broken by #1421

This branch includes the following new commits:

     new ec060d8a9f Fix code block syntax highlighting broken by #1421

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(airflow-site) 01/01: Fix code block syntax highlighting broken by #1421

Posted by ka...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch fix-code-block-syntax-highlighting
in repository https://gitbox.apache.org/repos/asf/airflow-site.git

commit ec060d8a9fa632d99cccc387ac72fc615560999c
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Thu Apr 16 16:26:56 2026 +0100

    Fix code block syntax highlighting broken by #1421
    
    PR #1421 replaced `pre span { @extend .monotext--brownish-grey }` with
    `pre span { color: var(--bs-body-color) }`, which broke CSS inheritance
    for Pygments tokens without explicit class rules — they got
    --bs-body-color instead of inheriting from .highlight's theme color.
    It also removed .nn (Name.Namespace) from the dark theme.
    
    This commit:
    - Removes the blanket `pre span { color }` rule so tokens properly
      inherit from `.highlight { color: ... }` via the CSS cascade
    - Adds .nn override in both light/dark themes to render namespace
      tokens (module paths in imports) as plain text color instead of
      keyword-colored, matching how GitHub.com actually renders Python
    - Adds explicit `color: #212529` to .highlight in the light theme
      for a stable default text color
    - Removes duplicate `@import "pygments/dark"` from _rst-content.scss
      that produced dead double-nested CSS selectors
    - Adds a richer Python code example to the demo playground for testing
---
 landing-pages/site/assets/scss/_highlights.scss       |  4 ----
 landing-pages/site/assets/scss/_rst-content.scss      |  6 +-----
 landing-pages/site/assets/scss/pygments/_dark.scss    |  4 ++++
 landing-pages/site/assets/scss/pygments/_light.scss   |  3 ++-
 sphinx_airflow_theme/.theme_files_hash                |  2 +-
 sphinx_airflow_theme/LATEST_VERSION.txt               |  2 +-
 sphinx_airflow_theme/demo/playground.rst              | 19 +++++++++++++++++++
 sphinx_airflow_theme/sphinx_airflow_theme/__init__.py |  2 +-
 8 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/landing-pages/site/assets/scss/_highlights.scss b/landing-pages/site/assets/scss/_highlights.scss
index f8186e63da..88288e769a 100644
--- a/landing-pages/site/assets/scss/_highlights.scss
+++ b/landing-pages/site/assets/scss/_highlights.scss
@@ -121,10 +121,6 @@ pre {
   border: solid 1px map-get($colors, very-light-pink);
   border-radius: 5px;
   width: 100%;
-
-  span {
-    color: var(--bs-body-color);
-  }
 }
 
 [data-bs-theme="dark"] {
diff --git a/landing-pages/site/assets/scss/_rst-content.scss b/landing-pages/site/assets/scss/_rst-content.scss
index f20d114f6c..2686873718 100644
--- a/landing-pages/site/assets/scss/_rst-content.scss
+++ b/landing-pages/site/assets/scss/_rst-content.scss
@@ -646,12 +646,8 @@ body {
       color: var(--bs-code-color);
     }
 
-            // Syntax highlighting for code blocks in dark mode
-            // Generated via: cd sphinx_airflow_theme/demo && uv run pygmentize -S github-dark -f html -a ".highlight" > ../../landing-pages/site/assets/scss/pygments/_dark.scss
-            // To change theme: replace "github-dark" with another Pygments style (run: uv run pygmentize -L styles)
-            @import "pygments/dark";
-
     // Override background to use Bootstrap variables for consistency
+    // (Pygments dark theme is imported via _highlights.scss)
     .highlight {
       background: var(--bs-secondary-bg) !important;
 
diff --git a/landing-pages/site/assets/scss/pygments/_dark.scss b/landing-pages/site/assets/scss/pygments/_dark.scss
index 50a1d41dff..26eb84fc10 100644
--- a/landing-pages/site/assets/scss/pygments/_dark.scss
+++ b/landing-pages/site/assets/scss/pygments/_dark.scss
@@ -235,6 +235,10 @@
       font-weight: bold;
     } /* Name.Label */
 
+    .highlight .nn {
+      color: #e6edf3;
+      font-weight: normal;
+    } /* Name.Namespace — match GitHub: plain text, not keyword-colored */
     .highlight .nx {
       color: #e6edf3;
     } /* Name.Other */
diff --git a/landing-pages/site/assets/scss/pygments/_light.scss b/landing-pages/site/assets/scss/pygments/_light.scss
index c57a955491..9d391faff7 100644
--- a/landing-pages/site/assets/scss/pygments/_light.scss
+++ b/landing-pages/site/assets/scss/pygments/_light.scss
@@ -44,7 +44,7 @@
   td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
   span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
   .highlight .hll { background-color: #ffffcc }
-  .highlight { background: #ffffff; }
+  .highlight { background: #ffffff; color: #212529; }
   .highlight .c { color: #008000 } /* Comment */
   .highlight .err { border: 1px solid #F00 } /* Error */
   .highlight .k { color: #00F } /* Keyword */
@@ -68,6 +68,7 @@
   .highlight .kt { color: #2B91AF } /* Keyword.Type */
   .highlight .s { color: #A31515 } /* Literal.String */
   .highlight .nc { color: #2B91AF } /* Name.Class */
+  .highlight .nn { color: #212529; font-weight: normal } /* Name.Namespace — match GitHub: plain text, not keyword-colored */
   .highlight .ow { color: #00F } /* Operator.Word */
   .highlight .sa { color: #A31515 } /* Literal.String.Affix */
   .highlight .sb { color: #A31515 } /* Literal.String.Backtick */
diff --git a/sphinx_airflow_theme/.theme_files_hash b/sphinx_airflow_theme/.theme_files_hash
index 769bd07882..6230a61de3 100644
--- a/sphinx_airflow_theme/.theme_files_hash
+++ b/sphinx_airflow_theme/.theme_files_hash
@@ -1 +1 @@
-f46dbcb27d4a704f9be5ce49eec3ec283353e17a0f233b0e4f5945a012b0b38f
+4345a53e36a58c393d6db74876bbdbab814e22b399046866a0926c3b1adad1bd
diff --git a/sphinx_airflow_theme/LATEST_VERSION.txt b/sphinx_airflow_theme/LATEST_VERSION.txt
index 0f82685331..6678432209 100644
--- a/sphinx_airflow_theme/LATEST_VERSION.txt
+++ b/sphinx_airflow_theme/LATEST_VERSION.txt
@@ -1 +1 @@
-0.3.7
+0.3.8
diff --git a/sphinx_airflow_theme/demo/playground.rst b/sphinx_airflow_theme/demo/playground.rst
index 27d251d991..f3d8b4e136 100644
--- a/sphinx_airflow_theme/demo/playground.rst
+++ b/sphinx_airflow_theme/demo/playground.rst
@@ -319,6 +319,25 @@ Sidebar
 Code
 """"
 
+.. code-block:: python
+
+  from datetime import datetime
+
+  from airflow.sdk import DAG, task
+  from airflow.providers.standard.operators.bash import BashOperator
+
+  # A DAG represents a workflow, a collection of tasks
+  with DAG(dag_id="demo", start_date=datetime(2022, 1, 1), schedule="0 0 * * *") as dag:
+      # Tasks are represented as operators
+      hello = BashOperator(task_id="hello", bash_command="echo hello")
+
+      @task()
+      def airflow():
+          print("airflow")
+
+      # Set dependencies between tasks
+      hello >> airflow()
+
 .. code:: python
 
   def my_function():
diff --git a/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py b/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
index 5b4336f16f..52f973197c 100644
--- a/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
+++ b/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
@@ -18,7 +18,7 @@
 from os import path
 from sphinx.application import Sphinx
 
-__version__ = '0.3.7'
+__version__ = '0.3.8'
 __version_full__ = __version__