Skip to content

Commit

Permalink
feat: add blank lines in blockquote to adhere to MD standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Olle Jernström committed Feb 29, 2024
1 parent 26152e9 commit 025614a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion rich/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,26 @@ def __rich_console__(
)
yield syntax


class BlockQuote(TextElement):
"""A block quote."""

style_name = "markdown.block_quote"

def __init__(self) -> None:
super().__init__()
self.elements: Renderables = Renderables()
# Track if the previous element was a paragraph
self.previous_element_was_paragraph = False

def on_child_close(
self, context: "MarkdownContext", child: "MarkdownElement"
) -> bool:
if isinstance(child, Paragraph):
if self.previous_element_was_paragraph:
self.elements.append(Text(""))
self.previous_element_was_paragraph = True
else:
self.previous_element_was_paragraph = False
self.elements.append(child)
return False

Expand All @@ -219,6 +227,8 @@ def __rich_console__(
yield new_line




class HorizontalRule(MarkdownElement):
"""A horizontal rule to divide sections."""

Expand Down Expand Up @@ -565,6 +575,8 @@ def __init__(
parser = MarkdownIt().enable("strikethrough").enable("table")
self.markup = markup
self.parsed = parser.parse(markup)
print(self.parsed)
print('--------')
self.code_theme = code_theme
self.justify: Optional[JustifyMethod] = justify
self.style = style
Expand All @@ -582,6 +594,8 @@ def _flatten_tokens(self, tokens: Iterable[Token]) -> Iterable[Token]:
else:
yield token



def __rich_console__(
self, console: Console, options: ConsoleOptions
) -> RenderResult:
Expand Down

0 comments on commit 025614a

Please sign in to comment.