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

Add syntax highlighting using pygments. #20

Merged
merged 9 commits into from
Feb 16, 2013
Merged

Add syntax highlighting using pygments. #20

merged 9 commits into from
Feb 16, 2013

Conversation

bellecp
Copy link
Contributor

@bellecp bellecp commented Jan 9, 2013

It looks nicer with some color highlighting, which comes for free using pygments and its guess_lexer smart function.

The few lines of code come from http://pygments.org/docs/quickstart/

(nice idea btw!)

@hughdbrown
Copy link

Nice. I like.

@gleitz
Copy link
Owner

gleitz commented Jan 10, 2013

I like the idea of colorization but I think it may need to be more specific than the default guess_lexer. I tried the following commands:

$ howdoi format string bash
$ howdoi print stack trace python
$ howdoi convert mp4 to animated gif
$ howdoi create tar archive

Of all the commands only two were colored, and of those the only symbols that were selected for color were "for", "${", and "$}"

You might want to take a look at this comment and try to implement some of the suggestions.

@bellecp
Copy link
Contributor Author

bellecp commented Jan 10, 2013

It now finds a lexer based on the first argument/tag matching a pygments lexer.

Duplicate: #24

@gleitz
Copy link
Owner

gleitz commented Jan 14, 2013

Thanks for this request. I'm evaluating it and #24 and will provide feedback once I have tested both.

@gleitz
Copy link
Owner

gleitz commented Feb 3, 2013

After playing with this commit and #24 I prefer this version. The highlighting is nice but I find that it can sometimes be too intrusive. What do you think about colorization being optional through a flag (-c / --color)? If you want to permanently enable color you would include the following alias:

alias howdoi='howdoi -c'

@bellecp
Copy link
Contributor Author

bellecp commented Feb 5, 2013

I merged your master branch and updated the code with a -c, --colorflag. It seems to work smoothly.

My favorite setting is with --alland --color--:

howdoi -c -a C++ for loop

I feel it's often preferable to have the full (colorized) answer, where so much can be learned... But I let you choose what the default behavior should be.

@gleitz
Copy link
Owner

gleitz commented Feb 11, 2013

Thanks @pierroweb! I'll take a final look this week.

@gleitz gleitz merged commit 8c11994 into gleitz:master Feb 16, 2013
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

3 participants