mirror of https://github.com/Textualize/rich.git
fix markdown on light
This commit is contained in:
parent
a972ca0552
commit
f6eca21a9b
|
@ -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"]
|
||||
|
|
|
@ -5,11 +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
|
||||
## [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
|
||||
|
||||
|
|
|
@ -278,6 +278,7 @@ class ConsoleRenderable(Protocol):
|
|||
|
||||
# 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]]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -379,7 +379,7 @@ class Syntax(JupyterMixin):
|
|||
str: The name of the Pygments lexer that best matches the supplied path/code.
|
||||
"""
|
||||
lexer: Optional[Lexer] = None
|
||||
lexer_name = "default"
|
||||
lexer_name = "text"
|
||||
if code:
|
||||
try:
|
||||
lexer = guess_lexer_for_filename(path, code)
|
||||
|
@ -421,7 +421,7 @@ class Syntax(JupyterMixin):
|
|||
return style.color
|
||||
|
||||
@property
|
||||
def lexer(self) -> Optional[Lexer]:
|
||||
def lexer(self) -> Lexer:
|
||||
"""The lexer for this syntax, or None if no lexer was found.
|
||||
|
||||
Tries to find the lexer by name if a string was passed to the constructor.
|
||||
|
@ -437,7 +437,12 @@ class Syntax(JupyterMixin):
|
|||
tabsize=self.tab_size,
|
||||
)
|
||||
except ClassNotFound:
|
||||
return None
|
||||
return get_lexer_by_name(
|
||||
"text",
|
||||
stripnl=False,
|
||||
ensurenl=True,
|
||||
tabsize=self.tab_size,
|
||||
)
|
||||
|
||||
def highlight(
|
||||
self,
|
||||
|
|
|
@ -38,6 +38,7 @@ DEFAULT_OVERFLOW: "OverflowMethod" = "fold"
|
|||
_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]]
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -333,7 +333,6 @@ def test_from_path_unknown_lexer():
|
|||
try:
|
||||
os.write(fh, b"import this\n")
|
||||
syntax = Syntax.from_path(path)
|
||||
assert syntax.lexer is None
|
||||
assert syntax.code == "import this\n"
|
||||
finally:
|
||||
os.remove(path)
|
||||
|
@ -357,7 +356,7 @@ def test_from_path_lexer_override_invalid_lexer():
|
|||
try:
|
||||
os.write(fh, b"import this\n")
|
||||
syntax = Syntax.from_path(path, lexer="blah")
|
||||
assert syntax.lexer is None
|
||||
assert syntax.lexer.name == "Text only"
|
||||
assert syntax.code == "import this\n"
|
||||
finally:
|
||||
os.remove(path)
|
||||
|
|
Loading…
Reference in New Issue