Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Textualize/rich
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v13.5.2
Choose a base ref
...
head repository: Textualize/rich
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v13.5.3
Choose a head ref
  • 11 commits
  • 9 files changed
  • 2 contributors

Commits on Sep 13, 2023

  1. Copy the full SHA
    51603be View commit details
  2. Fix markdown table rendering issue.

    The table data elements were not interacting well with inline styles (in the rich sense) and the table data element would have its content overridden every time we found another excerpt of text with a different style.
    rodrigogiraoserrao committed Sep 13, 2023
    Copy the full SHA
    e30b822 View commit details

Commits on Sep 17, 2023

  1. Merge pull request #3130 from Textualize/fix-table-inline-styles

    Fix markdown table rendering issue with inline styles/links
    willmcgugan authored Sep 17, 2023
    Copy the full SHA
    bef0e50 View commit details
  2. changelog

    willmcgugan committed Sep 17, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a972ca0 View commit details
  3. fix markdown on light

    willmcgugan committed Sep 17, 2023
    Copy the full SHA
    f6eca21 View commit details
  4. fix test

    willmcgugan committed Sep 17, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    32ec768 View commit details
  5. Add default lexer

    willmcgugan committed Sep 17, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    44e36aa View commit details
  6. Restore text

    willmcgugan committed Sep 17, 2023
    Copy the full SHA
    db07a2a View commit details
  7. Merge pull request #3132 from Textualize/fix-markdown-on-light

    fix markdown on light
    willmcgugan authored Sep 17, 2023
    Copy the full SHA
    e0d3aee View commit details
  8. version bump

    willmcgugan committed Sep 17, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5360fe6 View commit details
  9. changelog

    willmcgugan committed Sep 17, 2023
    Copy the full SHA
    ec91917 View commit details
Showing with 67 additions and 17 deletions.
  1. +1 −2 .pre-commit-config.yaml
  2. +9 −1 CHANGELOG.md
  3. +1 −1 pyproject.toml
  4. +1 −0 rich/console.py
  5. +6 −8 rich/markdown.py
  6. +11 −1 rich/syntax.py
  7. +1 −0 rich/text.py
  8. +36 −3 tests/test_markdown.py
  9. +1 −1 tests/test_markdown_no_hyperlinks.py
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ repos:
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-json
- id: check-toml
@@ -40,5 +39,5 @@ repos:
hooks:
- id: isort
name: isort (python)
language_version: '3.11'
language_version: "3.11"
args: ["--profile", "black"]
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,11 +5,18 @@ 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).

## [13.5.3] - 2023-09-17

### Fixed

- Markdown table rendering issue with inline styles and links https://github.com/Textualize/rich/issues/3115
- Fix Markdown code blocks on a light background https://github.com/Textualize/rich/issues/3123

## [13.5.2] - 2023-08-01

### Fixed

- Fixed Text.expand_tab assertion error
- Fixed Text.expand_tabs assertion error

## [13.5.1] - 2023-07-31

@@ -1994,6 +2001,7 @@ Major version bump for a breaking change to `Text.stylize signature`, which corr

- First official release, API still to be stabilized

[13.5.3]: https://github.com/textualize/rich/compare/v13.5.2...v13.5.3
[13.5.2]: https://github.com/textualize/rich/compare/v13.5.1...v13.5.2
[13.5.1]: https://github.com/textualize/rich/compare/v13.5.0...v13.5.1
[13.5.0]: https://github.com/textualize/rich/compare/v13.4.2...v13.5.0
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
name = "rich"
homepage = "https://github.com/Textualize/rich"
documentation = "https://rich.readthedocs.io/en/latest/"
version = "13.5.2"
version = "13.5.3"
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
authors = ["Will McGugan <willmcgugan@gmail.com>"]
license = "MIT"
1 change: 1 addition & 0 deletions rich/console.py
Original file line number Diff line number Diff line change
@@ -278,6 +278,7 @@ def __rich_console__(

# A type that may be rendered by Console.
RenderableType = Union[ConsoleRenderable, RichCast, str]
"""A string or any object that may be rendered by Rich."""

# The result of calling a __rich_console__ method.
RenderResult = Iterable[Union[RenderableType, Segment]]
14 changes: 6 additions & 8 deletions rich/markdown.py
Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ class CodeBlock(TextElement):
def create(cls, markdown: "Markdown", token: Token) -> "CodeBlock":
node_info = token.info or ""
lexer_name = node_info.partition(" ")[0]
return cls(lexer_name or "default", markdown.code_theme)
return cls(lexer_name or "text", markdown.code_theme)

def __init__(self, lexer_name: str, theme: str) -> None:
self.lexer_name = lexer_name
@@ -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,13 @@ 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(
plain, justify=self.justify, style=context.style_stack.current
)
text = Text(text) if isinstance(text, str) else text
text.stylize(context.current_style)
self.content.append_text(text)


class ListElement(MarkdownElement):
12 changes: 11 additions & 1 deletion rich/syntax.py
Original file line number Diff line number Diff line change
@@ -439,6 +439,16 @@ def lexer(self) -> Optional[Lexer]:
except ClassNotFound:
return None

@property
def default_lexer(self) -> Lexer:
"""A Pygments Lexer to use if one is not specified or invalid."""
return get_lexer_by_name(
"text",
stripnl=False,
ensurenl=True,
tabsize=self.tab_size,
)

def highlight(
self,
code: str,
@@ -467,7 +477,7 @@ def highlight(
)
_get_theme_style = self._theme.get_style_for_token

lexer = self.lexer
lexer = self.lexer or self.default_lexer

if lexer is None:
text.append(code)
1 change: 1 addition & 0 deletions rich/text.py
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
_re_whitespace = re.compile(r"\s+$")

TextType = Union[str, "Text"]
"""A plain string or a [Text][rich.text.Text] instance."""

GetStyleCallable = Callable[[str], Optional[StyleType]]

Loading