-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newline control #49
Comments
This behaviour is kind of intentional. Because we can have quite wide terminal rendering with rich, it makes sense that we want to render paragraphs in a justified manner. If you're writing your docstrings with PEP 8 with 79 character line lengths and only 60 chars to play with you're going to have a tonne of whitespace off to the right. Collapsing single line breaks and replacing double line breaks with single was my response to this, and whilst it's crude I'm not sure that I can really think of a better way to do it: rich-click/src/rich_click/rich_click.py Lines 167 to 174 in cb612ff
With the markdown rendering I basically don't do anything and it should render in the same way as any other markdown text. Currently there are two ways around this - double the number of newlines you have in your docstrings or use the What is your suggestion for changing the current behaviour? That newlines should be collapsed but double-newlines should be kept as double-newlines? |
Re-reading those click rewrapping docs (which I don't think I had seen at the time that I wrote this code) I'm thinking that you're probably right. As click was already doing the newlines thing then maybe we should mimic the same behaviour. For default text handling anyway, I'm not super keen on changing how Markdown parsing works. |
For me the main point is that a single line break in the docstring is simply a way to keep to code tidy (and not having a 500-characters long line), so it makes sense that OTOH, a double line is something the person writing the docstring does to better structure the help text. There is a reason why it's put in a certain place. And as you said, click also respects these, so also from a technical standpoint, if Honestly, for the markdown case, I think it's enough to simply split summary and verbose help text, but without touching the verbose text, as that should be fully interpreted as a markdown document. |
Sure, I think we're agreeing on the intent and overall behaviour. That's why I think you're probably right that most people will expect the blank spacing newline though. It means less compact output but we can probably add a configuration variable to maintain the current behaviour for people who prefer it (like me 😅, at least with long help texts). It's the only way I can think of to make single newlines without the blank possible. |
Is there any progress on this issue? I'm quoting an example input file like this:
but because rich-click is eating newlines, it turns into:
so the example input file does not stand out from the main help text (there are more paragraphs of text leading up to this example). |
Not really sorry @davidfokkema. However in your case it's fairly easy to solve - it's not eating all newlines, just collapsing double to single. So if you double up then it works as expected:
Renders as:
|
See also ewels/rich-click#49.
Hi @ewels, that works great as a workaround, thanks! |
I will not be touching the default behavior of rich-click. But, I think it is reasonable to include a formatting feature such as |
Sounds like a good compromise 👍🏻 |
When printing help messages, the paragraph structure gets mangled by
rich_click
in the sense that separation between paragraphs is not respected. The following MWE illustrates what I mean.The output is as follows. The first instance is the output of this MWE directly, the second is when
USE_MARKDOWN
is uncommented.Shouldn't white paragraph separations be left alone?
System info
The text was updated successfully, but these errors were encountered: