From f3ae0d2467c0fbc363e55b365a668e5c230609b3 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Thu, 17 Jul 2025 12:11:22 +0100 Subject: [PATCH 1/3] drop reactives --- src/textual/widgets/_markdown.py | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/textual/widgets/_markdown.py b/src/textual/widgets/_markdown.py index 4e4eb9f994..af9bff7c7a 100644 --- a/src/textual/widgets/_markdown.py +++ b/src/textual/widgets/_markdown.py @@ -802,11 +802,6 @@ def __init__(self, markdown: Markdown, code: str, lexer: str) -> None: super().__init__(markdown) self.code = code self.lexer = lexer - self.theme = ( - self._markdown.code_dark_theme - if self.app.current_theme.dark - else self._markdown.code_light_theme - ) code_content = highlight(self.code, language=lexer) self.set_content(code_content) @@ -872,15 +867,6 @@ class Markdown(Widget): BULLETS = ["\u25cf ", "▪ ", "‣ ", "• ", "⭑ "] - code_dark_theme: reactive[str] = reactive("material") - """The theme to use for code blocks when the App theme is dark.""" - - code_light_theme: reactive[str] = reactive("material-light") - """The theme to use for code blocks when the App theme is light.""" - - code_indent_guides: reactive[bool] = reactive(True) - """Should code fences display indent guides?""" - def __init__( self, markdown: str | None = None, @@ -1033,18 +1019,6 @@ def on_markdown_link_clicked(self, event: LinkClicked) -> None: if self._open_links: self.app.open_url(event.href) - def _watch_code_dark_theme(self) -> None: - """React to the dark theme being changed.""" - if self.app.current_theme.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.current_theme.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. @@ -1436,8 +1410,6 @@ class MarkdownViewer(VerticalScroll, can_focus=False, can_focus_children=True): show_table_of_contents = reactive(True) """Show the table of contents?""" - code_indent_guides: reactive[bool] = reactive(True) - """Should code fences display indent guides?""" top_block = reactive("") navigator: var[Navigator] = var(Navigator) @@ -1521,7 +1493,7 @@ def compose(self) -> ComposeResult: parser_factory=self._parser_factory, open_links=self._open_links ) markdown.can_focus = True - yield markdown.data_bind(MarkdownViewer.code_indent_guides) + yield markdown yield MarkdownTableOfContents(markdown) def _on_markdown_table_of_contents_updated( From 01da1eb9ad10b6303d70117ab43bf713fbc51b7b Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Thu, 17 Jul 2025 12:13:07 +0100 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e554e03b9f..60410ae04a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Improved rendering of Markdown tables (replace Rich table with grid) which allows text selection https://github.com/Textualize/textual/pull/5962 - Change look of command palette, to drop accented borders https://github.com/Textualize/textual/pull/5966 +### Removed + +- Breaking change: Removed `Markdown.code_dark_theme`, `Markdown.code_light_theme`, `Markdown.code_indent_guides` which are no longer needed with the new code fence. + ## [4.0.0] - 2025-07-12 ### Fixed From e79bdf7c929fb82c737b5294a8377a83712d0835 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Thu, 17 Jul 2025 12:15:28 +0100 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60410ae04a..e087ec8eca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Removed -- Breaking change: Removed `Markdown.code_dark_theme`, `Markdown.code_light_theme`, `Markdown.code_indent_guides` which are no longer needed with the new code fence. +- Breaking change: Removed `Markdown.code_dark_theme`, `Markdown.code_light_theme`, `Markdown.code_indent_guides` which are no longer needed with the new code fence. https://github.com/Textualize/textual/pull/5967 ## [4.0.0] - 2025-07-12