resolved RESOLVED UNSUBMITTED PASS · None tool calls · 0 s · Textualize/rich
Update to markdown styles Updates to Markdown styling
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
--- a/rich/default_styles.py
+++ b/rich/default_styles.py
@@ -149,20 +149,22 @@
"markdown.block_quote": Style(color="magenta"),
"markdown.list": Style(color="cyan"),
"markdown.item": Style(),
- "markdown.item.bullet": Style(color="yellow", bold=True),
- "markdown.item.number": Style(color="yellow", bold=True),
- "markdown.hr": Style(color="yellow"),
+ "markdown.item.bullet": Style(bold=True),
+ "markdown.item.number": Style(color="cyan"),
+ "markdown.hr": Style(dim=True),
"markdown.h1.border": Style(),
- "markdown.h1": Style(bold=True),
- "markdown.h2": Style(bold=True, underline=True),
- "markdown.h3": Style(bold=True),
- "markdown.h4": Style(bold=True, dim=True),
- "markdown.h5": Style(underline=True),
- "markdown.h6": Style(italic=True),
+ "markdown.h1": Style(bold=True, underline=True),
+ "markdown.h2": Style(color="magenta", underline=True),
+ "markdown.h3": Style(color="magenta", bold=True),
+ "markdown.h4": Style(color="magenta", italic=True),
+ "markdown.h5": Style(italic=True),
+ "markdown.h6": Style(dim=True),
"markdown.h7": Style(italic=True, dim=True),
"markdown.link": Style(color="bright_blue"),
"markdown.link_url": Style(color="blue", underline=True),
"markdown.s": Style(strike=True),
+ "markdown.table.border": Style(color="cyan"),
+ "markdown.table.header": Style(color="cyan", bold=False),
"iso8601.date": Style(color="blue"),
"iso8601.time": Style(color="magenta"),
"iso8601.timezone": Style(color="yellow"),
--- a/rich/markdown.py
+++ b/rich/markdown.py
@@ -1,6 +1,7 @@
from __future__ import annotations
import sys
+from dataclasses import dataclass
from typing import ClassVar, Iterable, get_args
from markdown_it import MarkdownIt
@@ -14,7 +15,6 @@
from .console import Console, ConsoleOptions, JustifyMethod, RenderResult
from .containers import Renderables
from .jupyter import JupyterMixin
-from .panel import Panel
from .rule import Rule
from .segment import Segment
from .style import Style, StyleStack
@@ -124,9 +124,24 @@ def __rich_console__(
yield self.text
+@dataclass
+class HeadingFormat:
+ justify: JustifyMethod = "left"
+ style: str = ""
+
+
class Heading(TextElement):
"""A heading."""
+ LEVEL_ALIGN: ClassVar[dict[str, JustifyMethod]] = {
+ "h1": "center",
+ "h2": "left",
+ "h3": "left",
+ "h4": "left",
+ "h5": "left",
+ "h6": "left",
+ }
+
@classmethod
def create(cls, markdown: Markdown, token: Token) -> Heading:
return cls(token.tag)
@@ -143,20 +158,10 @@ def __init__(self, tag: str) -> None:
def __rich_console__(
self, console: Console, options: ConsoleOptions
) -> RenderResult:
- text = self.text
- text.justify = "center"
- if self.tag == "h1":
- # Draw a border around h1s
- yield Panel(
- text,
- box=box.HEAVY,
- style="markdown.h1.border",
- )
- else:
- # Styled text for h2 and beyond
- if self.tag == "h2":
- yield Text("")
- yield text
+ text = self.text.copy()
+ heading_justify = self.LEVEL_ALIGN.get(self.tag, "left")
+ text.justify = heading_justify
+ yield text
class CodeBlock(TextElement):
@@ -219,7 +224,8 @@ def __rich_console__(
self, console: Console, options: ConsoleOptions
) -> RenderResult:
style = console.get_style("markdown.hr", default="none")
- yield Rule(style=style)
+ yield Rule(style=style, characters="-")
+ yield Text()
class TableElement(MarkdownElement):
@@ -241,11 +247,19 @@ def on_child_close(self, context: MarkdownContext, child: MarkdownElement) -> bo
def __rich_console__(
self, console: Console, options: ConsoleOptions
) -> RenderResult:
- table = Table(box=box.SIMPLE_HEAVY)
+ table = Table(
+ box=box.SIMPLE,
+ pad_edge=False,
+ style="markdown.table.border",
+ show_edge=True,
+ collapse_padding=True,
+ )
if self.header is not None and self.header.row is not None:
for column in self.header.row.cells:
- table.add_column(column.content)
+ heading = column.content.copy()
+ heading.stylize("markdown.table.header")
+ table.add_column(heading)
if self.body is not None:
for row in self.body.rows:........ [100%] 8 passed in 0.42s