Skip to content
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

Right-align Markdown #33

Closed
wants to merge 9 commits into from
Closed

Conversation

hugovk
Copy link
Collaborator

@hugovk hugovk commented Dec 7, 2017

Simply adding a colon will align columns nicely in Markdown.

See https://help.github.com/articles/organizing-information-with-tables/#formatting-content-within-your-table

Builds on #23 by including a unit test for this change (eg.). This makes things much easier to develop without going over your quota!

Before

As plaintext:

| python_version | percent | download_count |
| -------------- | ------- | -------------- |
| 2.7            |   59.3% |          3,048 |
| 3.5            |   20.9% |          1,074 |
| 3.6            |   14.3% |            734 |
| 3.4            |    5.4% |            279 |
| 2.6            |    0.1% |              4 |

As rendered Markdown:

python_version percent download_count
2.7 59.3% 3,048
3.5 20.9% 1,074
3.6 14.3% 734
3.4 5.4% 279
2.6 0.1% 4

After

As plaintext:

| python_version | percent | download_count |
| -------------- | ------: | -------------: |
| 2.7            |   59.3% |          3,048 |
| 3.5            |   20.9% |          1,074 |
| 3.6            |   14.3% |            734 |
| 3.4            |    5.4% |            279 |
| 2.6            |    0.1% |              4 |

As rendered Markdown:

python_version percent download_count
2.7 59.3% 3,048
3.5 20.9% 1,074
3.6 14.3% 734
3.4 5.4% 279
2.6 0.1% 4

@ofek
Copy link
Owner

ofek commented Dec 7, 2017

Thanks!

I don't want the right-align; it's too Markdown-centric imo. Also, please use pytest instead of unittest.

@hugovk
Copy link
Collaborator Author

hugovk commented Dec 7, 2017

Would it be okay to add a command-line parameter for the right-align? It'd be very useful for me.

I'll add pytest.

Do you mean something like this:

from pypinfo import core

def test_tabulate():
    ...
    assert tabulated == expected

Or just having it as the pytest command for discovery?

@ofek
Copy link
Owner

ofek commented Dec 7, 2017

Test looks good. A flag is fine.

@hugovk
Copy link
Collaborator Author

hugovk commented Dec 8, 2017

Updated!

https://travis-ci.org/hugovk/pypinfo/builds/313395588

Without --markdown:

[hugo:~/github/pypinfo] align-markdown-with-tests(+45/-18) ± pypinfo --percent --pip pypinfo pyversion
| python_version | percent | download_count |
| -------------- | ------- | -------------- |
| 3.6            |   58.9% |             33 |
| 2.7            |   23.2% |             13 |
| 3.5            |   16.1% |              9 |
| 3.4            |    1.8% |              1 |

With --markdown:

[hugo:~/github/pypinfo] align-markdown-with-tests(+45/-18) 7s ± pypinfo --percent --pip --markdown pypinfo pyversion
| python_version | percent | download_count |
| -------------- | ------: | -------------: |
| 3.6            |   58.9% |             33 |
| 2.7            |   23.2% |             13 |
| 3.5            |   16.1% |              9 |
| 3.4            |    1.8% |              1 |

@hugovk
Copy link
Collaborator Author

hugovk commented Jan 10, 2018

Rebased on master.

@ofek
Copy link
Owner

ofek commented Jan 10, 2018

Can you please open a new PR with just this change?

@ofek ofek closed this Jan 10, 2018
@hugovk hugovk mentioned this pull request Jan 11, 2018
@hugovk
Copy link
Collaborator Author

hugovk commented Jan 11, 2018

There we go: #36.

@hugovk hugovk deleted the align-markdown-with-tests branch October 29, 2021 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants