diff --git a/CHANGELOG.md b/CHANGELOG.md index 89843c0ae5..8e74f4b2a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Markdown table rendering issue with inline styles and links https://github.com/Textualize/rich/issues/3115 + ## [13.5.2] - 2023-08-01 ### Fixed diff --git a/rich/markdown.py b/rich/markdown.py index 704da3010b..729d8fd1d5 100644 --- a/rich/markdown.py +++ b/rich/markdown.py @@ -314,7 +314,7 @@ class TableDataElement(MarkdownElement): @classmethod def create(cls, markdown: "Markdown", token: Token) -> "MarkdownElement": - style = str(token.attrs.get("style" "")) or "" + style = str(token.attrs.get("style")) or "" justify: JustifyMethod if "text-align:right" in style: @@ -330,15 +330,18 @@ def create(cls, markdown: "Markdown", token: Token) -> "MarkdownElement": return cls(justify=justify) def __init__(self, justify: JustifyMethod) -> None: - self.content: TextType = "" + self.content: Text = Text("", justify=justify) self.justify = justify def on_text(self, context: "MarkdownContext", text: TextType) -> None: - plain = text.plain if isinstance(text, Text) else text - style = text.style if isinstance(text, Text) else "" - self.content = Text( + text = Text(text) if isinstance(text, str) else text + text.stylize(context.current_style) + self.content.append_text(text) + # plain = text.plain if isinstance(text, Text) else text + # self.content.append(plain, context.style_stack.current) + """ self.content += Text( plain, justify=self.justify, style=context.style_stack.current - ) + ) """ class ListElement(MarkdownElement):