Skip to content
This repository was archived by the owner on Mar 2, 2025. It is now read-only.
This repository was archived by the owner on Mar 2, 2025. It is now read-only.

Add per-word highlighting to user defined words in syntax highlighting #61

@akalenuk

Description

@akalenuk

The idea behind per-word highlighting is to show things that are different different and thing which are the same - the same. So 'edx' is visually much different from 'ebx' and 'uint_16' from 'uint_64'. I've been using per-word highlighting for reviewing code in C, C++ and Assembly and it has always been a great help.

Here's an example of what I mean: http://awesomescreenshot.com/0bd3072r87 The above is plain code and below is the same piece per-word highlighted.

On the other hand, in high level languages we woudn't mix 'if' for 'else' anyway, but we'd like this words to denote a code structure, so syntax highlighting, not per-word, is preferable.

I've made a hack, that brings complementary per-word highlighting over syntax highlighting provided by 'pygments'.

Here's the code for a colorer:
https://github.com/akalenuk/codrspace/blob/master/apps/codrspace/pygments/over_pygments.py

And that's about how I think of patching the templatetag, so one could chose per-word coloring for user defined words by adding 'more_colors' to a 'code' tag:
akalenuk@29ea2fc#diff-1

It's all ready and working in my fork (the example from above is a locally hosted Codrspace screenshot) and I'm ready to send a pull request any moment. Yet I'm not sure about if this hack is the right way to go. I mean, it isn't orthogonal to pygments and it is not a fair patch on it. It just parasites on its output. If I were to review my own code, I would mark this as a potential malleability issue.

So, what do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions