Add GitLab specific formatter #1

Merged
merged 14 commits into from Nov 10, 2012

Projects

None yet

8 participants

@riyad

This adds a GitLab formatter to Pygments. It's based on the Html formatter, where all but a few options were removed and output generation was greatly simplified.
It must be set explicitly by calling:

Pygments.highlight(code, formatter: :gitlab)

This generates proper code to be used for gitlabhq/gitlabhq#1937.

btw: I also merged in the latest changes from upstream.

@randx
GitLab member

@riyad seems ok. I'll merge it :)

@randx randx merged commit 4db80c5 into gitlabhq:master Nov 10, 2012
@avtobiff

At a glance this seems to be the only change from upstream (except lagging behind). Is it so?

Why not just make a pull request for this and remove the fork?

Also, the reference in the file headers to a BSD LICENSE file is wrong. No such file exists.

Why would you want to change license in your fork from the MIT/Expat license to BSD?

@avtobiff There are basically two deviations in this fork. The use of python2 for calling Python (see gitlabhq/gitlabhq#2214) and the custom GitLab formatter (see #1).

@riyad

  1. Not seeing any consensus on gitlabhq/gitlabhq#2214 but ok.
  2. Why not integrate the GitLab formatter to upstream pygments.rb? It is a fairly small changeset anyways.
  3. References in file headers to BSD LICENSE are wrong. No such file exists.
  4. Why change from upstream (and still actually most of gitlab-pygments.rb) MIT/Expat to BSD?
GitLab member

@avtobiff what's so special with pygments upstream?

@riyad

Well, generally a proliferation of a codebase should be avoided.

The Debian Ruby team is working with packaging GitLab and it's
dependencies. We don't want to package all custom forks of
different gems. This is why I suggest to pull request this change
to pygment.rb upstream.

Furthermore, Debian takes licensing seriously. It is a tad unclear
what the license of these additions are. (Code says BSD License
but references a file with the MIT License.)

GitLab member

Code says BSD License but references a file with the MIT License

can you point please? As I see all custom lexers have BSD LIcense but Pygments.rb itself has MIT

tmm1/pygments.rb#74 seems to have made it upstream so we can drop the python2 hack. This only leaves the custom formatter.

can you point please? As I see all custom lexers have BSD LIcense but Pygments.rb itself has MIT

Ah yes, I did not realize that vendor/pygments-main/ is actually a copy of upstream pygments itself.
So the changes should be pushed there and not to pygments.rb. (We rip pygments-main out in the
Debian package and use python-pygments.)

I only checked the pygments.rb root for the LICENSE file.

Do you want to push this to pygments bitbucket? Otherwise I volunteer!

tmm1/pygments.rb#74 seems to have made it upstream so we can drop the python2 hack. This only leaves the custom formatter.

Sweet!

@avtobiff go ahead 😄

@riyad riyad referenced this pull request in tmm1/pygments.rb Jun 11, 2013
Closed

Add GitLab formatter #77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment