Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed empty print ignoring the `end` parameter
- Fixed `Text.from_ansi` removing newlines https://github.com/Textualize/rich/pull/4076
- Fixed `FileProxy.isatty` not proxying https://github.com/Textualize/rich/pull/4077
- Fixed inline code in Markdown tables cells https://github.com/Textualize/rich/pull/4079

## [14.3.4] - 2026-04-11

Expand Down
7 changes: 4 additions & 3 deletions rich/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,10 @@ def __init__(self, justify: JustifyMethod) -> None:
self.justify = justify

def on_text(self, context: MarkdownContext, text: TextType) -> None:
text = Text(text) if isinstance(text, str) else text
text.stylize(context.current_style)
self.content.append_text(text)
if isinstance(text, str):
self.content.append(text, context.current_style)
else:
self.content.append_text(text)


class ListElement(MarkdownElement):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,22 @@ def test_table_with_empty_cells() -> None:
assert result == expected


def test_inline_code_in_table_cells() -> None:
"""Test inline code in table cells.

Regression test for https://github.com/Textualize/rich/issues/4038

"""
markdown = Markdown(
"| Col |\n|---|\n| `print('hello');` |\n",
inline_code_theme="monokai",
inline_code_lexer="python",
)
result = render(markdown)
expected = "\n\x1b[36m \x1b[0m\n\x1b[36m \x1b[0m\x1b[36mCol\x1b[0m\x1b[1m \x1b[0m\x1b[36m \x1b[0m\n\x1b[36m ─────────────── \x1b[0m\n\x1b[36m \x1b[0m\x1b[38;2;248;248;242;48;2;39;40;34mprint\x1b[0m\x1b[38;2;248;248;242;48;2;39;40;34m(\x1b[0m\x1b[38;2;230;219;116;48;2;39;40;34m'\x1b[0m\x1b[38;2;230;219;116;48;2;39;40;34mhello\x1b[0m\x1b[38;2;230;219;116;48;2;39;40;34m'\x1b[0m\x1b[38;2;248;248;242;48;2;39;40;34m)\x1b[0m\x1b[38;2;248;248;242;48;2;39;40;34m;\x1b[0m\x1b[36m \x1b[0m\n\x1b[36m \x1b[0m\n"
assert result == expected


if __name__ == "__main__":
markdown = Markdown(MARKDOWN)
rendered = render(markdown)
Expand Down
Loading