pygments / pygments.rb

💎 Ruby wrapper for Pygments syntax highlighter
MIT License
572 stars 141 forks source link

Racket formatting incorrect for square brackets #141

Closed zenspider closed 3 years ago

zenspider commented 9 years ago

As seen here: https://github.com/mflatt/s3-sync/blob/master/main.rkt#L26-L33

The square brackets have the CSS class pl-ii which is applying a red color to it. Square brackets in racket (as with most lisps) are just another form of paren and should be treated the same as regular ().

I tried to track it down in pygments.rb, but I'm not familiar enough with the code to see anything wrong with the racket code. Point me in the right direction and I can try to do a PR.

greghendershott commented 9 years ago

From what I can tell, Pygments is lexing this correctly. It was correct in e.g. 1.6 and it still is in the latest version. Specifically, I don't believe that this commit changed this.

For example try live here and

(foo)
[bar]
{baz}

is formatted as

<div class="hlcode">
<div class="syntax">
<pre>
  <span class="p">(</span><span class="n">foo</span><span class="p">)</span>
  <span class="p">[</span><span class="n">bar</span><span class="p">]</span>
  <span class="p">{</span><span class="n">baz</span><span class="p">}</span>
</pre>
</div>
</div>

Notice that parens, brackets, and braces -- all three -- are correctly tagged as punctuation, class="p".

What's strange is that the GitHub HTML classes look nothing like what Pygments emits. Where is class="pl-ii" coming from?? I don't understand.

greghendershott commented 9 years ago

So from rummaging around lingust it looks like they just suddenly stopped using Pygments. O_o https://github.com/github/linguist/commit/5dafa937de8ba58a6a4346365f80793e1f59f290 nukes all the lexers from languages.yml.

The Racket section is here:

Racket:
type: programming
color: "#ae17ff"
extensions:
- .rkt
- .rktd
- .rktl
- .scrbl
tm_scope: source.scheme

It's classifying Racket as a Scheme. So we're back to where we were two years ago, when I contributed a Racket lexer to Pygments and spent months waiting for it to roll into production on GitHub. FML.

From another snippet, I get the impression that "tm" refers to TextMate. So maybe GitHub's plan to have their own editor based on TextMate, led them to decide to stop using the best syntax highlighting system available, Pygments.

TL;DR: I guess we need to file an issue over on the linguist project. And someone needs to write a TextMate highlighter for Racket. (Also someone should probably update the Scheme highlighter -- because AFAIK actually () and [] and {} are all valid and equivalent Scheme. Highlighting [] as an error is wrong for Scheme, too, I think?)

slonopotamus commented 3 years ago

Please, retest this after #205.