pygments / pygments.rb

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

Update to latest pygments #122

Closed bkeepers closed 10 years ago

bkeepers commented 10 years ago

Ran rake vendor:update.

There is one failing test that seems like a legitimate failure. The test was added in d6a8f2af7d20eb71184d6bd7ca60e00501146e88, which appears to be testing pipes and not necessarily the expected output.

[26/48] PygmentsHighlightTest#test_highlight_works_with_single_character_input = 0.01 s                    
  1) Error:
test_highlight_works_with_single_character_input(PygmentsHighlightTest):
MentosError: Traceback (most recent call last):
  File "/Users/brandon/github/pygments.rb/lib/pygments/mentos.py", line 303, in start
    res = self.get_data(method, lexer, args, kwargs, text)
  File "/Users/brandon/github/pygments.rb/lib/pygments/mentos.py", line 171, in get_data
    res = self.highlight_text(text, lexer, formatter_name, args, _convert_keys(opts))
  File "/Users/brandon/github/pygments.rb/lib/pygments/mentos.py", line 122, in highlight_text
    lexer = self.return_lexer(lexer, args, kwargs, code)
  File "/Users/brandon/github/pygments.rb/lib/pygments/mentos.py", line 102, in return_lexer
    return lexers.guess_lexer(code, **inputs)
  File "/Users/brandon/github/pygments.rb/vendor/pygments-main/pygments/lexers/__init__.py", line 242, in guess_lexer
    raise ClassNotFound('no lexer matching the text found')
ClassNotFound: no lexer matching the text found
bkeepers commented 10 years ago

/cc @tnm @tmm1 @rick @arfon

thomasboyt commented 10 years ago

:+1: it's not in the Pygments changelog, but this also includes a new Handlebars lexer.

cstrahan commented 10 years ago

The NixOS project could really benefit from the new tokenizer in the latest pygments, which would bring syntax highlighting to tens of thousands of Nix packages.

@tmm1 If this PR looks good, would you mind merging and rolling a new release, please?

cstrahan commented 10 years ago

/cc @tnm @rick @arfon

rick commented 10 years ago

Not sure why I didn't see the original cc: -- yay Inbox 3000.

Confirmed that I still see that test failure locally. I'll :eyes: this and see if any wisdom arises.

rick commented 10 years ago

That test will pass if we provide a lexer argument:

diff --git a/test/test_pygments.rb b/test/test_pygments.rb
index 61df666..37c9835 100644
--- a/test/test_pygments.rb
+++ b/test/test_pygments.rb
@@ -88,7 +88,7 @@ class PygmentsHighlightTest < Test::Unit::TestCase
   end

   def test_highlight_works_with_single_character_input
-    code = P.highlight("a")
+    code = P.highlight("a", :lexer => 'rb')
     assert_match 'a</span>', code
   end

@@ -283,5 +283,3 @@ class PygmentsConfigTest < Test::Unit::TestCase
     assert list['Html'][:aliases].include?('html')
   end
 end
-
-

I'm coming at this very fresh, though, so I don't know if requiring a test change is a bad sign, something related to the upgrade, or just noise.

cstrahan commented 10 years ago

@rick Thanks for looking into this!

bkeepers commented 10 years ago

Done in #127