Repository: Textualize/textual

Issue:
Code blocks in Markdown widget do not respect the "theme" setting.
When switching theme from "dark" to "light" by means of setting the `app.dark` attribute, code blocks within the `Markdown` do not adapt accordingly.

![Screenshot 2024-01-10 at 11 14 18](https://github.com/Textualize/textual/assets/183103/4d580b20-34e0-4021-9b6b-98521ad35502)
![Screenshot 2024-01-10 at 11 14 08](https://github.com/Textualize/textual/assets/183103/61659d34-8390-415c-b01c-f68e1425eb7a)

I *think* the culprit is `MarkdownFence`. Specifically in `compose()` ,
```
    def compose(self) -> ComposeResult:
        from rich.syntax import Syntax

        yield Static(
            Syntax(
                self.code,
                lexer=self.lexer,
                word_wrap=False,
                indent_guides=True,
                padding=(1, 2),
                theme="material",
            ),
            expand=True,
            shrink=False,
        )
 ```
 
 `Syntax` is used with a hardcoded "material" theme. 


Discussion:
We found the following entries in the [FAQ](https://textual.textualize.io/FAQ/) which you may find helpful:


- [How do I center a widget in a screen?](https://textual.textualize.io/FAQ/#how-do-i-center-a-widget-in-a-screen)
- [Why doesn't Textual look good on macOS?](https://textual.textualize.io/FAQ/#why-doesn't-textual-look-good-on-macos)
- [No widget called TextLog](https://textual.textualize.io/FAQ/#no-widget-called-textlog)

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by [FAQtory](https://github.com/willmcgugan/faqtory)

Resolving patch:
diff --git a/src/textual/widgets/_markdown.py b/src/textual/widgets/_markdown.py
--- a/src/textual/widgets/_markdown.py
+++ b/src/textual/widgets/_markdown.py
@@ -7,6 +7,7 @@
 from markdown_it.token import Token
 from rich import box
 from rich.style import Style
+from rich.syntax import Syntax
 from rich.table import Table
 from rich.text import Text
 from typing_extensions import TypeAlias
@@ -498,22 +499,41 @@ class MarkdownFence(MarkdownBlock):
     """
 
     def __init__(self, markdown: Markdown, code: str, lexer: str) -> None:
+        super().__init__(markdown)
         self.code = code
         self.lexer = lexer
-        super().__init__(markdown)
+        self.theme = (
+            self._markdown.code_dark_theme
+            if self.app.dark
+            else self._markdown.code_light_theme
+        )
 
-    def compose(self) -> ComposeResult:
-        from rich.syntax import Syntax
+    def _block(self) -> Syntax:
+        return Syntax(
+            self.code,
+            lexer=self.lexer,
+            word_wrap=False,
+            indent_guides=True,
+            padding=(1, 2),
+            theme=self.theme,
+        )
+
+    def _on_mount(self, _: Mount) -> None:
+        """Watch app theme switching."""
+        self.watch(self.app, "dark", self._retheme)
+
+    def _retheme(self) -> None:
+        """Rerender when the theme changes."""
+        self.theme = (
+            self._markdown.code_dark_theme
+            if self.app.dark
+            else self._markdown.code_light_theme
+        )
+        self.get_child_by_type(Static).update(self._block())
 
+    def compose(self) -> ComposeResult:
         yield Static(
-            Syntax(
-                self.code,
-                lexer=self.lexer,
-                word_wrap=False,
-                indent_guides=True,
-                padding=(1, 2),
-                theme="material",
-            ),
+            self._block(),
             expand=True,
             shrink=False,
         )
@@ -567,6 +587,12 @@ class Markdown(Widget):
 
     BULLETS = ["\u25CF ", "▪ ", "‣ ", "• ", "⭑ "]
 
+    code_dark_theme: reactive[str] = reactive("material")
+    """The theme to use for code blocks when in [dark mode][textual.app.App.dark]."""
+
+    code_light_theme: reactive[str] = reactive("material-light")
+    """The theme to use for code blocks when in [light mode][textual.app.App.dark]."""
+
     def __init__(
         self,
         markdown: str | None = None,
@@ -653,6 +679,18 @@ def _on_mount(self, _: Mount) -> None:
         if self._markdown is not None:
             self.update(self._markdown)
 
+    def _watch_code_dark_theme(self) -> None:
+        """React to the dark theme being changed."""
+        if self.app.dark:
+            for block in self.query(MarkdownFence):
+                block._retheme()
+
+    def _watch_code_light_theme(self) -> None:
+        """React to the light theme being changed."""
+        if not self.app.dark:
+            for block in self.query(MarkdownFence):
+                block._retheme()
+
     @staticmethod
     def sanitize_location(location: str) -> tuple[Path, str]:
         """Given a location, break out the path and any anchor.
@@ -858,11 +896,7 @@ def update(self, markdown: str) -> AwaitComplete:
                 stack[-1].set_content(content)
             elif token.type in ("fence", "code_block"):
                 (stack[-1]._blocks if stack else output).append(
-                    MarkdownFence(
-                        self,
-                        token.content.rstrip(),
-                        token.info,
-                    )
+                    MarkdownFence(self, token.content.rstrip(), token.info)
                 )
             else:
                 external = self.unhandled_token(token)


Test patch:
diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
--- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
+++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
@@ -22009,6 +22009,170 @@
   
   '''
 # ---
+# name: test_markdown_dark_theme_override
+  '''
+  <svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
+      <!-- Generated with Rich https://www.textualize.io -->
+      <style>
+  
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Regular"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
+          font-style: normal;
+          font-weight: 400;
+      }
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Bold"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
+          font-style: bold;
+          font-weight: 700;
+      }
+  
+      .terminal-2700004228-matrix {
+          font-family: Fira Code, monospace;
+          font-size: 20px;
+          line-height: 24.4px;
+          font-variant-east-asian: full-width;
+      }
+  
+      .terminal-2700004228-title {
+          font-size: 18px;
+          font-weight: bold;
+          font-family: arial;
+      }
+  
+      .terminal-2700004228-r1 { fill: #e1e1e1 }
+  .terminal-2700004228-r2 { fill: #121212 }
+  .terminal-2700004228-r3 { fill: #c5c8c6 }
+  .terminal-2700004228-r4 { fill: #0053aa }
+  .terminal-2700004228-r5 { fill: #dde8f3;font-weight: bold }
+  .terminal-2700004228-r6 { fill: #d2d2d2 }
+  .terminal-2700004228-r7 { fill: #859900 }
+  .terminal-2700004228-r8 { fill: #839496 }
+  .terminal-2700004228-r9 { fill: #268bd2 }
+  .terminal-2700004228-r10 { fill: #34535b;font-style: italic; }
+  .terminal-2700004228-r11 { fill: #2aa198 }
+      </style>
+  
+      <defs>
+      <clipPath id="terminal-2700004228-clip-terminal">
+        <rect x="0" y="0" width="975.0" height="584.5999999999999" />
+      </clipPath>
+      <clipPath id="terminal-2700004228-line-0">
+      <rect x="0" y="1.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-1">
+      <rect x="0" y="25.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-2">
+      <rect x="0" y="50.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-3">
+      <rect x="0" y="74.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-4">
+      <rect x="0" y="99.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-5">
+      <rect x="0" y="123.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-6">
+      <rect x="0" y="147.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-7">
+      <rect x="0" y="172.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-8">
+      <rect x="0" y="196.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-9">
+      <rect x="0" y="221.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-10">
+      <rect x="0" y="245.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-11">
+      <rect x="0" y="269.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-12">
+      <rect x="0" y="294.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-13">
+      <rect x="0" y="318.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-14">
+      <rect x="0" y="343.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-15">
+      <rect x="0" y="367.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-16">
+      <rect x="0" y="391.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-17">
+      <rect x="0" y="416.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-18">
+      <rect x="0" y="440.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-19">
+      <rect x="0" y="465.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-20">
+      <rect x="0" y="489.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-21">
+      <rect x="0" y="513.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2700004228-line-22">
+      <rect x="0" y="538.3" width="976" height="24.65"/>
+              </clipPath>
+      </defs>
+  
+      <rect fill="#292929" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="1" y="1" width="992" height="633.6" rx="8"/><text class="terminal-2700004228-title" fill="#c5c8c6" text-anchor="middle" x="496" y="27">MarkdownThemeSwitchertApp</text>
+              <g transform="translate(26,22)">
+              <circle cx="0" cy="0" r="7" fill="#ff5f57"/>
+              <circle cx="22" cy="0" r="7" fill="#febc2e"/>
+              <circle cx="44" cy="0" r="7" fill="#28c840"/>
+              </g>
+          
+      <g transform="translate(9, 41)" clip-path="url(#terminal-2700004228-clip-terminal)">
+      <rect fill="#1e1e1e" x="0" y="1.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="48.8" y="1.5" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="61" y="1.5" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="915" y="1.5" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="1.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="25.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="48.8" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="61" y="25.9" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#121212" x="915" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="25.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="50.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="48.8" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="61" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="73.2" y="50.3" width="341.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="414.8" y="50.3" width="146.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="561.2" y="50.3" width="341.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="902.8" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#121212" x="915" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="50.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="74.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="48.8" y="74.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="61" y="74.7" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#121212" x="915" y="74.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="74.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="99.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="48.8" y="99.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="61" y="99.1" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="915" y="99.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="99.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="123.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="48.8" y="123.5" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="123.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="147.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="48.8" y="147.9" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="147.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="172.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="48.8" y="172.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="73.2" y="172.3" width="36.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="109.8" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="122" y="172.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="170.8" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="183" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="195.2" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="207.4" y="172.3" width="695.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="902.8" y="172.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="172.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="196.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="48.8" y="196.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="73.2" y="196.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="122" y="196.7" width="61" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="183" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="195.2" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="207.4" y="196.7" width="146.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="353.8" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="366" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="378.2" y="196.7" width="524.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="902.8" y="196.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="196.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="221.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#002b36" x="48.8" y="221.1" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="221.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="245.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="48.8" y="245.5" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="927.2" y="245.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="269.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="294.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="318.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="343.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="367.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="391.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="416.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="440.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="465.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="489.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="513.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="538.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="562.7" width="976" height="24.65" shape-rendering="crispEdges"/>
+      <g class="terminal-2700004228-matrix">
+      <text class="terminal-2700004228-r2" x="48.8" y="20" textLength="12.2" clip-path="url(#terminal-2700004228-line-0)">▁</text><text class="terminal-2700004228-r2" x="61" y="20" textLength="854" clip-path="url(#terminal-2700004228-line-0)">▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁</text><text class="terminal-2700004228-r2" x="915" y="20" textLength="12.2" clip-path="url(#terminal-2700004228-line-0)">▁</text><text class="terminal-2700004228-r3" x="976" y="20" textLength="12.2" clip-path="url(#terminal-2700004228-line-0)">
+  </text><text class="terminal-2700004228-r2" x="48.8" y="44.4" textLength="12.2" clip-path="url(#terminal-2700004228-line-1)">▎</text><text class="terminal-2700004228-r4" x="915" y="44.4" textLength="12.2" clip-path="url(#terminal-2700004228-line-1)">▊</text><text class="terminal-2700004228-r3" x="976" y="44.4" textLength="12.2" clip-path="url(#terminal-2700004228-line-1)">
+  </text><text class="terminal-2700004228-r2" x="48.8" y="68.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-2)">▎</text><text class="terminal-2700004228-r5" x="414.8" y="68.8" textLength="146.4" clip-path="url(#terminal-2700004228-line-2)">This&#160;is&#160;a&#160;H1</text><text class="terminal-2700004228-r4" x="915" y="68.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-2)">▊</text><text class="terminal-2700004228-r3" x="976" y="68.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-2)">
+  </text><text class="terminal-2700004228-r2" x="48.8" y="93.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-3)">▎</text><text class="terminal-2700004228-r4" x="915" y="93.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-3)">▊</text><text class="terminal-2700004228-r3" x="976" y="93.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-3)">
+  </text><text class="terminal-2700004228-r2" x="48.8" y="117.6" textLength="12.2" clip-path="url(#terminal-2700004228-line-4)">▔</text><text class="terminal-2700004228-r2" x="61" y="117.6" textLength="854" clip-path="url(#terminal-2700004228-line-4)">▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔</text><text class="terminal-2700004228-r2" x="915" y="117.6" textLength="12.2" clip-path="url(#terminal-2700004228-line-4)">▔</text><text class="terminal-2700004228-r3" x="976" y="117.6" textLength="12.2" clip-path="url(#terminal-2700004228-line-4)">
+  </text><text class="terminal-2700004228-r3" x="976" y="142" textLength="12.2" clip-path="url(#terminal-2700004228-line-5)">
+  </text><text class="terminal-2700004228-r3" x="976" y="166.4" textLength="12.2" clip-path="url(#terminal-2700004228-line-6)">
+  </text><text class="terminal-2700004228-r7" x="73.2" y="190.8" textLength="36.6" clip-path="url(#terminal-2700004228-line-7)">def</text><text class="terminal-2700004228-r9" x="122" y="190.8" textLength="48.8" clip-path="url(#terminal-2700004228-line-7)">main</text><text class="terminal-2700004228-r8" x="170.8" y="190.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-7)">(</text><text class="terminal-2700004228-r8" x="183" y="190.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-7)">)</text><text class="terminal-2700004228-r8" x="195.2" y="190.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-7)">:</text><text class="terminal-2700004228-r3" x="976" y="190.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-7)">
+  </text><text class="terminal-2700004228-r10" x="73.2" y="215.2" textLength="48.8" clip-path="url(#terminal-2700004228-line-8)">│&#160;&#160;&#160;</text><text class="terminal-2700004228-r9" x="122" y="215.2" textLength="61" clip-path="url(#terminal-2700004228-line-8)">print</text><text class="terminal-2700004228-r8" x="183" y="215.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-8)">(</text><text class="terminal-2700004228-r11" x="195.2" y="215.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-8)">&quot;</text><text class="terminal-2700004228-r11" x="207.4" y="215.2" textLength="146.4" clip-path="url(#terminal-2700004228-line-8)">Hello&#160;world!</text><text class="terminal-2700004228-r11" x="353.8" y="215.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-8)">&quot;</text><text class="terminal-2700004228-r8" x="366" y="215.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-8)">)</text><text class="terminal-2700004228-r3" x="976" y="215.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-8)">
+  </text><text class="terminal-2700004228-r3" x="976" y="239.6" textLength="12.2" clip-path="url(#terminal-2700004228-line-9)">
+  </text><text class="terminal-2700004228-r3" x="976" y="264" textLength="12.2" clip-path="url(#terminal-2700004228-line-10)">
+  </text><text class="terminal-2700004228-r3" x="976" y="288.4" textLength="12.2" clip-path="url(#terminal-2700004228-line-11)">
+  </text><text class="terminal-2700004228-r3" x="976" y="312.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-12)">
+  </text><text class="terminal-2700004228-r3" x="976" y="337.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-13)">
+  </text><text class="terminal-2700004228-r3" x="976" y="361.6" textLength="12.2" clip-path="url(#terminal-2700004228-line-14)">
+  </text><text class="terminal-2700004228-r3" x="976" y="386" textLength="12.2" clip-path="url(#terminal-2700004228-line-15)">
+  </text><text class="terminal-2700004228-r3" x="976" y="410.4" textLength="12.2" clip-path="url(#terminal-2700004228-line-16)">
+  </text><text class="terminal-2700004228-r3" x="976" y="434.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-17)">
+  </text><text class="terminal-2700004228-r3" x="976" y="459.2" textLength="12.2" clip-path="url(#terminal-2700004228-line-18)">
+  </text><text class="terminal-2700004228-r3" x="976" y="483.6" textLength="12.2" clip-path="url(#terminal-2700004228-line-19)">
+  </text><text class="terminal-2700004228-r3" x="976" y="508" textLength="12.2" clip-path="url(#terminal-2700004228-line-20)">
+  </text><text class="terminal-2700004228-r3" x="976" y="532.4" textLength="12.2" clip-path="url(#terminal-2700004228-line-21)">
+  </text><text class="terminal-2700004228-r3" x="976" y="556.8" textLength="12.2" clip-path="url(#terminal-2700004228-line-22)">
+  </text>
+      </g>
+      </g>
+  </svg>
+  
+  '''
+# ---
 # name: test_markdown_example
   '''
   <svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
@@ -22173,6 +22337,335 @@
   
   '''
 # ---
+# name: test_markdown_light_theme_override
+  '''
+  <svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
+      <!-- Generated with Rich https://www.textualize.io -->
+      <style>
+  
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Regular"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
+          font-style: normal;
+          font-weight: 400;
+      }
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Bold"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
+          font-style: bold;
+          font-weight: 700;
+      }
+  
+      .terminal-3405842733-matrix {
+          font-family: Fira Code, monospace;
+          font-size: 20px;
+          line-height: 24.4px;
+          font-variant-east-asian: full-width;
+      }
+  
+      .terminal-3405842733-title {
+          font-size: 18px;
+          font-weight: bold;
+          font-family: arial;
+      }
+  
+      .terminal-3405842733-r1 { fill: #1f1f1f }
+  .terminal-3405842733-r2 { fill: #efefef }
+  .terminal-3405842733-r3 { fill: #c5c8c6 }
+  .terminal-3405842733-r4 { fill: #0053aa }
+  .terminal-3405842733-r5 { fill: #dde8f3;font-weight: bold }
+  .terminal-3405842733-r6 { fill: #d2d2d2 }
+  .terminal-3405842733-r7 { fill: #859900 }
+  .terminal-3405842733-r8 { fill: #657b83 }
+  .terminal-3405842733-r9 { fill: #268bd2 }
+  .terminal-3405842733-r10 { fill: #bdc3bb;font-style: italic; }
+  .terminal-3405842733-r11 { fill: #2aa198 }
+      </style>
+  
+      <defs>
+      <clipPath id="terminal-3405842733-clip-terminal">
+        <rect x="0" y="0" width="975.0" height="584.5999999999999" />
+      </clipPath>
+      <clipPath id="terminal-3405842733-line-0">
+      <rect x="0" y="1.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-1">
+      <rect x="0" y="25.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-2">
+      <rect x="0" y="50.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-3">
+      <rect x="0" y="74.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-4">
+      <rect x="0" y="99.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-5">
+      <rect x="0" y="123.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-6">
+      <rect x="0" y="147.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-7">
+      <rect x="0" y="172.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-8">
+      <rect x="0" y="196.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-9">
+      <rect x="0" y="221.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-10">
+      <rect x="0" y="245.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-11">
+      <rect x="0" y="269.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-12">
+      <rect x="0" y="294.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-13">
+      <rect x="0" y="318.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-14">
+      <rect x="0" y="343.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-15">
+      <rect x="0" y="367.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-16">
+      <rect x="0" y="391.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-17">
+      <rect x="0" y="416.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-18">
+      <rect x="0" y="440.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-19">
+      <rect x="0" y="465.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-20">
+      <rect x="0" y="489.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-21">
+      <rect x="0" y="513.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-3405842733-line-22">
+      <rect x="0" y="538.3" width="976" height="24.65"/>
+              </clipPath>
+      </defs>
+  
+      <rect fill="#292929" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="1" y="1" width="992" height="633.6" rx="8"/><text class="terminal-3405842733-title" fill="#c5c8c6" text-anchor="middle" x="496" y="27">MarkdownThemeSwitchertApp</text>
+              <g transform="translate(26,22)">
+              <circle cx="0" cy="0" r="7" fill="#ff5f57"/>
+              <circle cx="22" cy="0" r="7" fill="#febc2e"/>
+              <circle cx="44" cy="0" r="7" fill="#28c840"/>
+              </g>
+          
+      <g transform="translate(9, 41)" clip-path="url(#terminal-3405842733-clip-terminal)">
+      <rect fill="#f5f5f5" x="0" y="1.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="48.8" y="1.5" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="61" y="1.5" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="915" y="1.5" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="1.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="25.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="48.8" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="61" y="25.9" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#efefef" x="915" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="25.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="50.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="48.8" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="61" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="73.2" y="50.3" width="341.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="414.8" y="50.3" width="146.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="561.2" y="50.3" width="341.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="902.8" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#efefef" x="915" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="50.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="74.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="48.8" y="74.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="61" y="74.7" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#efefef" x="915" y="74.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="74.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="99.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="48.8" y="99.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="61" y="99.1" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="915" y="99.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="99.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="123.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="48.8" y="123.5" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="123.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="147.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="48.8" y="147.9" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="147.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="172.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="48.8" y="172.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="73.2" y="172.3" width="36.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="109.8" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="122" y="172.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="170.8" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="183" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="195.2" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="207.4" y="172.3" width="695.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="902.8" y="172.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="172.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="196.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="48.8" y="196.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="73.2" y="196.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="122" y="196.7" width="61" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="183" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="195.2" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="207.4" y="196.7" width="146.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="353.8" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="366" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="378.2" y="196.7" width="524.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="902.8" y="196.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="196.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="221.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#fdf6e3" x="48.8" y="221.1" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="221.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="245.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="48.8" y="245.5" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="245.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="269.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="294.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="318.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="343.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="367.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="391.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="416.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="440.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="465.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="489.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="513.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="538.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="562.7" width="976" height="24.65" shape-rendering="crispEdges"/>
+      <g class="terminal-3405842733-matrix">
+      <text class="terminal-3405842733-r2" x="48.8" y="20" textLength="12.2" clip-path="url(#terminal-3405842733-line-0)">▁</text><text class="terminal-3405842733-r2" x="61" y="20" textLength="854" clip-path="url(#terminal-3405842733-line-0)">▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁</text><text class="terminal-3405842733-r2" x="915" y="20" textLength="12.2" clip-path="url(#terminal-3405842733-line-0)">▁</text><text class="terminal-3405842733-r3" x="976" y="20" textLength="12.2" clip-path="url(#terminal-3405842733-line-0)">
+  </text><text class="terminal-3405842733-r2" x="48.8" y="44.4" textLength="12.2" clip-path="url(#terminal-3405842733-line-1)">▎</text><text class="terminal-3405842733-r4" x="915" y="44.4" textLength="12.2" clip-path="url(#terminal-3405842733-line-1)">▊</text><text class="terminal-3405842733-r3" x="976" y="44.4" textLength="12.2" clip-path="url(#terminal-3405842733-line-1)">
+  </text><text class="terminal-3405842733-r2" x="48.8" y="68.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-2)">▎</text><text class="terminal-3405842733-r5" x="414.8" y="68.8" textLength="146.4" clip-path="url(#terminal-3405842733-line-2)">This&#160;is&#160;a&#160;H1</text><text class="terminal-3405842733-r4" x="915" y="68.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-2)">▊</text><text class="terminal-3405842733-r3" x="976" y="68.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-2)">
+  </text><text class="terminal-3405842733-r2" x="48.8" y="93.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-3)">▎</text><text class="terminal-3405842733-r4" x="915" y="93.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-3)">▊</text><text class="terminal-3405842733-r3" x="976" y="93.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-3)">
+  </text><text class="terminal-3405842733-r2" x="48.8" y="117.6" textLength="12.2" clip-path="url(#terminal-3405842733-line-4)">▔</text><text class="terminal-3405842733-r2" x="61" y="117.6" textLength="854" clip-path="url(#terminal-3405842733-line-4)">▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔</text><text class="terminal-3405842733-r2" x="915" y="117.6" textLength="12.2" clip-path="url(#terminal-3405842733-line-4)">▔</text><text class="terminal-3405842733-r3" x="976" y="117.6" textLength="12.2" clip-path="url(#terminal-3405842733-line-4)">
+  </text><text class="terminal-3405842733-r3" x="976" y="142" textLength="12.2" clip-path="url(#terminal-3405842733-line-5)">
+  </text><text class="terminal-3405842733-r3" x="976" y="166.4" textLength="12.2" clip-path="url(#terminal-3405842733-line-6)">
+  </text><text class="terminal-3405842733-r7" x="73.2" y="190.8" textLength="36.6" clip-path="url(#terminal-3405842733-line-7)">def</text><text class="terminal-3405842733-r9" x="122" y="190.8" textLength="48.8" clip-path="url(#terminal-3405842733-line-7)">main</text><text class="terminal-3405842733-r8" x="170.8" y="190.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-7)">(</text><text class="terminal-3405842733-r8" x="183" y="190.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-7)">)</text><text class="terminal-3405842733-r8" x="195.2" y="190.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-7)">:</text><text class="terminal-3405842733-r3" x="976" y="190.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-7)">
+  </text><text class="terminal-3405842733-r10" x="73.2" y="215.2" textLength="48.8" clip-path="url(#terminal-3405842733-line-8)">│&#160;&#160;&#160;</text><text class="terminal-3405842733-r9" x="122" y="215.2" textLength="61" clip-path="url(#terminal-3405842733-line-8)">print</text><text class="terminal-3405842733-r8" x="183" y="215.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-8)">(</text><text class="terminal-3405842733-r11" x="195.2" y="215.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-8)">&quot;</text><text class="terminal-3405842733-r11" x="207.4" y="215.2" textLength="146.4" clip-path="url(#terminal-3405842733-line-8)">Hello&#160;world!</text><text class="terminal-3405842733-r11" x="353.8" y="215.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-8)">&quot;</text><text class="terminal-3405842733-r8" x="366" y="215.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-8)">)</text><text class="terminal-3405842733-r3" x="976" y="215.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-8)">
+  </text><text class="terminal-3405842733-r3" x="976" y="239.6" textLength="12.2" clip-path="url(#terminal-3405842733-line-9)">
+  </text><text class="terminal-3405842733-r3" x="976" y="264" textLength="12.2" clip-path="url(#terminal-3405842733-line-10)">
+  </text><text class="terminal-3405842733-r3" x="976" y="288.4" textLength="12.2" clip-path="url(#terminal-3405842733-line-11)">
+  </text><text class="terminal-3405842733-r3" x="976" y="312.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-12)">
+  </text><text class="terminal-3405842733-r3" x="976" y="337.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-13)">
+  </text><text class="terminal-3405842733-r3" x="976" y="361.6" textLength="12.2" clip-path="url(#terminal-3405842733-line-14)">
+  </text><text class="terminal-3405842733-r3" x="976" y="386" textLength="12.2" clip-path="url(#terminal-3405842733-line-15)">
+  </text><text class="terminal-3405842733-r3" x="976" y="410.4" textLength="12.2" clip-path="url(#terminal-3405842733-line-16)">
+  </text><text class="terminal-3405842733-r3" x="976" y="434.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-17)">
+  </text><text class="terminal-3405842733-r3" x="976" y="459.2" textLength="12.2" clip-path="url(#terminal-3405842733-line-18)">
+  </text><text class="terminal-3405842733-r3" x="976" y="483.6" textLength="12.2" clip-path="url(#terminal-3405842733-line-19)">
+  </text><text class="terminal-3405842733-r3" x="976" y="508" textLength="12.2" clip-path="url(#terminal-3405842733-line-20)">
+  </text><text class="terminal-3405842733-r3" x="976" y="532.4" textLength="12.2" clip-path="url(#terminal-3405842733-line-21)">
+  </text><text class="terminal-3405842733-r3" x="976" y="556.8" textLength="12.2" clip-path="url(#terminal-3405842733-line-22)">
+  </text>
+      </g>
+      </g>
+  </svg>
+  
+  '''
+# ---
+# name: test_markdown_theme_switching
+  '''
+  <svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
+      <!-- Generated with Rich https://www.textualize.io -->
+      <style>
+  
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Regular"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
+          font-style: normal;
+          font-weight: 400;
+      }
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Bold"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
+          font-style: bold;
+          font-weight: 700;
+      }
+  
+      .terminal-2184772309-matrix {
+          font-family: Fira Code, monospace;
+          font-size: 20px;
+          line-height: 24.4px;
+          font-variant-east-asian: full-width;
+      }
+  
+      .terminal-2184772309-title {
+          font-size: 18px;
+          font-weight: bold;
+          font-family: arial;
+      }
+  
+      .terminal-2184772309-r1 { fill: #1f1f1f }
+  .terminal-2184772309-r2 { fill: #efefef }
+  .terminal-2184772309-r3 { fill: #c5c8c6 }
+  .terminal-2184772309-r4 { fill: #0053aa }
+  .terminal-2184772309-r5 { fill: #dde8f3;font-weight: bold }
+  .terminal-2184772309-r6 { fill: #d2d2d2 }
+  .terminal-2184772309-r7 { fill: #008000;font-weight: bold }
+  .terminal-2184772309-r8 { fill: #000000 }
+  .terminal-2184772309-r9 { fill: #0000ff }
+  .terminal-2184772309-r10 { fill: #87adad;font-style: italic; }
+  .terminal-2184772309-r11 { fill: #008000 }
+  .terminal-2184772309-r12 { fill: #ba2121 }
+      </style>
+  
+      <defs>
+      <clipPath id="terminal-2184772309-clip-terminal">
+        <rect x="0" y="0" width="975.0" height="584.5999999999999" />
+      </clipPath>
+      <clipPath id="terminal-2184772309-line-0">
+      <rect x="0" y="1.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-1">
+      <rect x="0" y="25.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-2">
+      <rect x="0" y="50.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-3">
+      <rect x="0" y="74.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-4">
+      <rect x="0" y="99.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-5">
+      <rect x="0" y="123.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-6">
+      <rect x="0" y="147.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-7">
+      <rect x="0" y="172.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-8">
+      <rect x="0" y="196.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-9">
+      <rect x="0" y="221.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-10">
+      <rect x="0" y="245.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-11">
+      <rect x="0" y="269.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-12">
+      <rect x="0" y="294.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-13">
+      <rect x="0" y="318.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-14">
+      <rect x="0" y="343.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-15">
+      <rect x="0" y="367.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-16">
+      <rect x="0" y="391.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-17">
+      <rect x="0" y="416.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-18">
+      <rect x="0" y="440.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-19">
+      <rect x="0" y="465.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-20">
+      <rect x="0" y="489.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-21">
+      <rect x="0" y="513.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-2184772309-line-22">
+      <rect x="0" y="538.3" width="976" height="24.65"/>
+              </clipPath>
+      </defs>
+  
+      <rect fill="#292929" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="1" y="1" width="992" height="633.6" rx="8"/><text class="terminal-2184772309-title" fill="#c5c8c6" text-anchor="middle" x="496" y="27">MarkdownThemeSwitchertApp</text>
+              <g transform="translate(26,22)">
+              <circle cx="0" cy="0" r="7" fill="#ff5f57"/>
+              <circle cx="22" cy="0" r="7" fill="#febc2e"/>
+              <circle cx="44" cy="0" r="7" fill="#28c840"/>
+              </g>
+          
+      <g transform="translate(9, 41)" clip-path="url(#terminal-2184772309-clip-terminal)">
+      <rect fill="#f5f5f5" x="0" y="1.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="48.8" y="1.5" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="61" y="1.5" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="915" y="1.5" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="1.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="25.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="48.8" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="61" y="25.9" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#efefef" x="915" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="25.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="50.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="48.8" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="61" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="73.2" y="50.3" width="341.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="414.8" y="50.3" width="146.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="561.2" y="50.3" width="341.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="902.8" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#efefef" x="915" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="50.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="74.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="48.8" y="74.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="61" y="74.7" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#efefef" x="915" y="74.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="74.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="99.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="48.8" y="99.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="61" y="99.1" width="854" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="915" y="99.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="99.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="123.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="48.8" y="123.5" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="123.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="147.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="48.8" y="147.9" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="147.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="172.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="48.8" y="172.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="73.2" y="172.3" width="36.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="109.8" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="122" y="172.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="170.8" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="183" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="195.2" y="172.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="207.4" y="172.3" width="695.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="902.8" y="172.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="172.3" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="196.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="48.8" y="196.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="73.2" y="196.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="122" y="196.7" width="61" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="183" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="195.2" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="207.4" y="196.7" width="146.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="353.8" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="366" y="196.7" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="378.2" y="196.7" width="524.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="902.8" y="196.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="196.7" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="221.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f8f8f8" x="48.8" y="221.1" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="221.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="245.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="48.8" y="245.5" width="878.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="927.2" y="245.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="269.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="294.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="318.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="343.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="367.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="391.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="416.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="440.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="465.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="489.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="513.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="538.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#f5f5f5" x="0" y="562.7" width="976" height="24.65" shape-rendering="crispEdges"/>
+      <g class="terminal-2184772309-matrix">
+      <text class="terminal-2184772309-r2" x="48.8" y="20" textLength="12.2" clip-path="url(#terminal-2184772309-line-0)">▁</text><text class="terminal-2184772309-r2" x="61" y="20" textLength="854" clip-path="url(#terminal-2184772309-line-0)">▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁</text><text class="terminal-2184772309-r2" x="915" y="20" textLength="12.2" clip-path="url(#terminal-2184772309-line-0)">▁</text><text class="terminal-2184772309-r3" x="976" y="20" textLength="12.2" clip-path="url(#terminal-2184772309-line-0)">
+  </text><text class="terminal-2184772309-r2" x="48.8" y="44.4" textLength="12.2" clip-path="url(#terminal-2184772309-line-1)">▎</text><text class="terminal-2184772309-r4" x="915" y="44.4" textLength="12.2" clip-path="url(#terminal-2184772309-line-1)">▊</text><text class="terminal-2184772309-r3" x="976" y="44.4" textLength="12.2" clip-path="url(#terminal-2184772309-line-1)">
+  </text><text class="terminal-2184772309-r2" x="48.8" y="68.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-2)">▎</text><text class="terminal-2184772309-r5" x="414.8" y="68.8" textLength="146.4" clip-path="url(#terminal-2184772309-line-2)">This&#160;is&#160;a&#160;H1</text><text class="terminal-2184772309-r4" x="915" y="68.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-2)">▊</text><text class="terminal-2184772309-r3" x="976" y="68.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-2)">
+  </text><text class="terminal-2184772309-r2" x="48.8" y="93.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-3)">▎</text><text class="terminal-2184772309-r4" x="915" y="93.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-3)">▊</text><text class="terminal-2184772309-r3" x="976" y="93.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-3)">
+  </text><text class="terminal-2184772309-r2" x="48.8" y="117.6" textLength="12.2" clip-path="url(#terminal-2184772309-line-4)">▔</text><text class="terminal-2184772309-r2" x="61" y="117.6" textLength="854" clip-path="url(#terminal-2184772309-line-4)">▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔</text><text class="terminal-2184772309-r2" x="915" y="117.6" textLength="12.2" clip-path="url(#terminal-2184772309-line-4)">▔</text><text class="terminal-2184772309-r3" x="976" y="117.6" textLength="12.2" clip-path="url(#terminal-2184772309-line-4)">
+  </text><text class="terminal-2184772309-r3" x="976" y="142" textLength="12.2" clip-path="url(#terminal-2184772309-line-5)">
+  </text><text class="terminal-2184772309-r3" x="976" y="166.4" textLength="12.2" clip-path="url(#terminal-2184772309-line-6)">
+  </text><text class="terminal-2184772309-r7" x="73.2" y="190.8" textLength="36.6" clip-path="url(#terminal-2184772309-line-7)">def</text><text class="terminal-2184772309-r9" x="122" y="190.8" textLength="48.8" clip-path="url(#terminal-2184772309-line-7)">main</text><text class="terminal-2184772309-r8" x="170.8" y="190.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-7)">(</text><text class="terminal-2184772309-r8" x="183" y="190.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-7)">)</text><text class="terminal-2184772309-r8" x="195.2" y="190.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-7)">:</text><text class="terminal-2184772309-r3" x="976" y="190.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-7)">
+  </text><text class="terminal-2184772309-r10" x="73.2" y="215.2" textLength="48.8" clip-path="url(#terminal-2184772309-line-8)">│&#160;&#160;&#160;</text><text class="terminal-2184772309-r11" x="122" y="215.2" textLength="61" clip-path="url(#terminal-2184772309-line-8)">print</text><text class="terminal-2184772309-r8" x="183" y="215.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-8)">(</text><text class="terminal-2184772309-r12" x="195.2" y="215.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-8)">&quot;</text><text class="terminal-2184772309-r12" x="207.4" y="215.2" textLength="146.4" clip-path="url(#terminal-2184772309-line-8)">Hello&#160;world!</text><text class="terminal-2184772309-r12" x="353.8" y="215.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-8)">&quot;</text><text class="terminal-2184772309-r8" x="366" y="215.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-8)">)</text><text class="terminal-2184772309-r3" x="976" y="215.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-8)">
+  </text><text class="terminal-2184772309-r3" x="976" y="239.6" textLength="12.2" clip-path="url(#terminal-2184772309-line-9)">
+  </text><text class="terminal-2184772309-r3" x="976" y="264" textLength="12.2" clip-path="url(#terminal-2184772309-line-10)">
+  </text><text class="terminal-2184772309-r3" x="976" y="288.4" textLength="12.2" clip-path="url(#terminal-2184772309-line-11)">
+  </text><text class="terminal-2184772309-r3" x="976" y="312.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-12)">
+  </text><text class="terminal-2184772309-r3" x="976" y="337.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-13)">
+  </text><text class="terminal-2184772309-r3" x="976" y="361.6" textLength="12.2" clip-path="url(#terminal-2184772309-line-14)">
+  </text><text class="terminal-2184772309-r3" x="976" y="386" textLength="12.2" clip-path="url(#terminal-2184772309-line-15)">
+  </text><text class="terminal-2184772309-r3" x="976" y="410.4" textLength="12.2" clip-path="url(#terminal-2184772309-line-16)">
+  </text><text class="terminal-2184772309-r3" x="976" y="434.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-17)">
+  </text><text class="terminal-2184772309-r3" x="976" y="459.2" textLength="12.2" clip-path="url(#terminal-2184772309-line-18)">
+  </text><text class="terminal-2184772309-r3" x="976" y="483.6" textLength="12.2" clip-path="url(#terminal-2184772309-line-19)">
+  </text><text class="terminal-2184772309-r3" x="976" y="508" textLength="12.2" clip-path="url(#terminal-2184772309-line-20)">
+  </text><text class="terminal-2184772309-r3" x="976" y="532.4" textLength="12.2" clip-path="url(#terminal-2184772309-line-21)">
+  </text><text class="terminal-2184772309-r3" x="976" y="556.8" textLength="12.2" clip-path="url(#terminal-2184772309-line-22)">
+  </text>
+      </g>
+      </g>
+  </svg>
+  
+  '''
+# ---
 # name: test_markdown_viewer_example
   '''
   <svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
diff --git a/tests/snapshot_tests/snapshot_apps/markdown_theme_switcher.py b/tests/snapshot_tests/snapshot_apps/markdown_theme_switcher.py
new file mode 100644
--- /dev/null
+++ b/tests/snapshot_tests/snapshot_apps/markdown_theme_switcher.py
@@ -0,0 +1,33 @@
+from textual.app import App, ComposeResult
+from textual.widgets import Markdown
+
+TEST_CODE_MARKDOWN = """
+# This is a H1
+```python
+def main():
+    print("Hello world!")
+```
+"""
+
+
+class MarkdownThemeSwitchertApp(App[None]):
+    BINDINGS = [
+        ("t", "toggle_dark"),
+        ("d", "switch_dark"),
+        ("l", "switch_light"),
+    ]
+
+    def action_switch_dark(self) -> None:
+        md = self.query_one(Markdown)
+        md.code_dark_theme = "solarized-dark"
+
+    def action_switch_light(self) -> None:
+        md = self.query_one(Markdown)
+        md.code_light_theme = "solarized-light"
+
+    def compose(self) -> ComposeResult:
+        yield Markdown(TEST_CODE_MARKDOWN)
+
+
+if __name__ == "__main__":
+    MarkdownThemeSwitchertApp().run()
diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py
--- a/tests/snapshot_tests/test_snapshots.py
+++ b/tests/snapshot_tests/test_snapshots.py
@@ -229,6 +229,22 @@ def test_markdown_viewer_example(snap_compare):
     assert snap_compare(WIDGET_EXAMPLES_DIR / "markdown_viewer.py")
 
 
+def test_markdown_theme_switching(snap_compare):
+    assert snap_compare(SNAPSHOT_APPS_DIR / "markdown_theme_switcher.py", press=["t"])
+
+
+def test_markdown_dark_theme_override(snap_compare):
+    assert snap_compare(
+        SNAPSHOT_APPS_DIR / "markdown_theme_switcher.py", press=["d", "wait:100"]
+    )
+
+
+def test_markdown_light_theme_override(snap_compare):
+    assert snap_compare(
+        SNAPSHOT_APPS_DIR / "markdown_theme_switcher.py", press=["l", "t", "wait:100"]
+    )
+
+
 def test_checkbox_example(snap_compare):
     assert snap_compare(WIDGET_EXAMPLES_DIR / "checkbox.py")