Make code and diffs easier to read using syntax highlighting and other font options

Bug #306631 reported by David Siegel
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Do
Invalid
Wishlist
Unassigned
loggerhead
Fix Released
Wishlist
Michael Hudson-Doyle

Bug Description

I read a lot of code on LP for my project (http://launchpad.net/do) and my team recently started using the review feature more and more, but I have difficulty viewing diffs, even on my 1920x1200 screen because the fonts are too light, and 8-space tabstops are a bit large for even my gigantic screen; imagine when I try to review merges on my netbook! I also read a lot of code on LP that is not in diff format, and it would help my eyes so much if there were some syntax highlighting options (for a nice example, see Pastie: http://pastie.org/pastes/335139). My project would benefit immensely from better fonts and syntax highlighting in Loggerhead. If I could configure my tabstops and syntax highlighting (maybe a simple stylesheet switcher, where users can add their own styles) in Loggerhead, my team would find reviews more enjoyable, and therefore be more likely to do a thorough job reviewing code, and our code quality would be improved as a result.

Changed in do:
importance: Undecided → Wishlist
status: New → Confirmed
Martin Albisetti (beuno)
Changed in do:
status: Confirmed → Invalid
Changed in loggerhead:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Peter Bui (pnutzh4x0r) wrote :

I started a development branch, linked above that uses python-pygments to enable syntax highlighting. It currently works for the annotated view. No support for themes through the WebUI for now, as I'm not sure what is the best way to integrate that.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

That looks pretty good!

Some comments;

1) Why do you have a class (PygmentsHighlighter) with a single staticmethod? This is Python, not Java, a free function would be fine :)

2) Would you be prepared/able to assign the copyright to Canonical for this? Loggerhead's copyright situation is a bit murky, but we are trying to make it clearer, gradually...

3) I wouldn't worry about themes at all for now. Just make it look OK with the default loggerhead look (which I think it does OK already in fact).

I can tweak the code a bit, so I guess it's only really 2) I need an answer to.

Revision history for this message
Peter Bui (pnutzh4x0r) wrote : Re: [Bug 306631] Re: Make code and diffs easier to read using syntax highlighting and other font options

On 17:54 Sun 01 Mar , Michael Hudson wrote:
> That looks pretty good!
>
> Some comments;
>
> 1) Why do you have a class (PygmentsHighlighter) with a single
> staticmethod? This is Python, not Java, a free function would be fine
> :)

I think my orignal intention was that we might have different
highlighting modules in the future, so we might use
xHighlighter.highlight instead of PygmentsHighlighter.highlight and that
the class may have more than one method... but yeah, as it is, a free
function is probably fine.

> 2) Would you be prepared/able to assign the copyright to Canonical for
> this? Loggerhead's copyright situation is a bit murky, but we are
> trying to make it clearer, gradually...

This would be fine, as long as I get some credit somewhere (NEWS file or
whatever).

> 3) I wouldn't worry about themes at all for now. Just make it look OK
> with the default loggerhead look (which I think it does OK already in
> fact).

I guess the next step is to address 1) which is easy enough and to
perhaps make it work for the diff view. I did run into a slight problem
where the highlighting seems to eat up the whole CPU if it doesn't
quite know what the file is (for me this was a CUDA .cu file), but that
is a problem with pygments and not loggerhead. Perhaps it needs more
testing.

> I can tweak the code a bit, so I guess it's only really 2) I need an
> answer to.
>
> --
> Make code and diffs easier to read using syntax highlighting and other font options
> https://bugs.launchpad.net/bugs/306631
> You received this bug notification because you are a direct subscriber
> of the bug.

--
=======================================================================
 Peter Bui (<email address hidden>)
=======================================================================

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I had a hack on the plane on top of your branch too, I'll see what the conflicts are like in a bit :)

Changed in loggerhead:
assignee: nobody → mwhudson
status: Triaged → In Progress
Revision history for this message
Martin Albisetti (beuno) wrote :

Has this been committed.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Well hum, annotate views highlight nicely now. Diffs don't, but there's another bug for doing diffs better.

Changed in loggerhead:
status: In Progress → Fix Committed
Martin Albisetti (beuno)
Changed in loggerhead:
status: Fix Committed → Fix Released
Revision history for this message
Carnë Draug (carandraug) wrote :

It says fix has been released but if it has, how do I change the syntax highlight when I'm reading the files online? A dropdown box (pastebin style) with the different syntaxes available would be nice. And the possibility to select the default syntax highlight for every file or the whole project too.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.