-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Is max_width word-wrapping configurable? #258
Comments
No, but it could be done by setting prettytable/src/prettytable/prettytable.py Line 1957 in 1c0aeee
>>> import textwrap
>>> line = "bluedevil breeze breeze-gtk eos-bash-shared glib2 kactivitymanagerd kde-cli-tools"
>>> textwrap.fill(line, 40)
'bluedevil breeze breeze-gtk eos-bash-\nshared glib2 kactivitymanagerd kde-cli-\ntools'
>>> textwrap.fill(line, 40, break_on_hyphens=False)
'bluedevil breeze breeze-gtk\neos-bash-shared glib2 kactivitymanagerd\nkde-cli-tools'
>>> Docs: https://docs.python.org/3/library/textwrap.html Would you like to put a PR together to make it configurable? Maybe the thing to do would have a dictionary that can be used to set all the other |
I've got the time, just not sure where to begin. Can you point me in the right direction? Never contributed directly to a Github project before. |
Sure! The high level is: You start off by forking this repo, there's a Fork button on the main page: https://github.com/jazzband/prettytable Then clone it to your computer, for example: Docs: https://docs.github.com/en/get-started/quickstart/fork-a-repo The comes the coding, add what's needed, with tests. You can test locally via tox, Also it's a good idea to enable GitHub Actions on your fork - https://github.com/ajgringo619/PrettyTable/actions - then it'll run the tests when you push. When you're ready, you create a "pull request" to submit it back here. Then we can review it, update it, then merge. Feel free to ask more details about any of these steps! |
Thanks for the detailed info, although I'm sure I'mm be asking a lot more questions. First one: what's the oldest version of Python I should be testing on? |
We follow the same as the upstream supported CPython versions, so Python 3.8. You don't necessarily need to install all the versions though, because the CI will test 3.8-3.12 on Ubuntu, Windows and macOS. |
I've already got versions 3.9 through 3.11 installed, so one more won't be a problem. Thanks again for all the info! |
Is this fix going to fix the fact that column headers should also wrap? I have column headers that are dynamic, and I need them to wrap - otherwise the table looks terrible. SHould I open a new issue for that? |
Can't believe it's been 7 months since I had "time" to work on this; I deleted the fork as it was just sitting there collecting dust. If I can truly commit to this in the future, I will post again with actual progress. |
@ajgringo619 I can take care of this one if you would like. |
Thanks a bunch. I'll be happy to test whatever you come up with. |
In my use-case, the column in question contains package names, which sometimes have hyphens or multiple hyphens. When I set a max_width on the column, some of the package names get split up:
Is there a way to exclude hyphenated words from being wrapped?
The text was updated successfully, but these errors were encountered: