Skip to content

Commit

Permalink
Fix incorrect markdown formatting
Browse files Browse the repository at this point in the history
Ref #447
  • Loading branch information
gar1t committed Sep 26, 2023
1 parent e0b207f commit 9012f58
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions tests/test_rich_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,28 @@ def secondary():
assert "Hello World" in result.stdout
result = runner.invoke(app, ["secondary"])
assert "Hello Secondary World" in result.stdout


def test_markdown_pars():
app = typer.Typer(rich_markup_mode="markdown")

@app.command()
def main():
"""First line
Line 1
Line 2
"""

result = runner.invoke(app, ["--help"])
lines = [l.strip() for l in result.stdout.split("\n")]
help_start = lines.index("First line")
assert help_start != -1
assert lines[help_start : help_start + 5] == [
"First line",
"Line 1",
"",
"Line 2",
"",
]
2 changes: 1 addition & 1 deletion typer/rich_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _get_help_text(
# Get remaining lines, remove single line breaks and format as dim
remaining_paragraphs = help_text.split("\n\n")[1:]
if remaining_paragraphs:
if markup_mode != MARKUP_MODE_RICH:
if markup_mode not in (MARKUP_MODE_RICH, MARKUP_MODE_MARKDOWN):
# Remove single linebreaks
remaining_paragraphs = [
x.replace("\n", " ").strip()
Expand Down

0 comments on commit 9012f58

Please sign in to comment.