pygments.rb 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -50,6 +50,12 @@ Pygments.css
50
50
  Pygments.css('.highlight')
51
51
  ```
52
52
 
53
+ To use a specific pygments style, pass the `:style` option to the `#css` method:
54
+
55
+ ``` ruby
56
+ Pygments.css(:style => "monokai")
57
+ ```
58
+
53
59
  Other Pygments high-level API methods are also available.
54
60
  These methods return arrays detailing all the available lexers, formatters,
55
61
  and styles.
@@ -364,7 +364,8 @@ module Pygments
364
364
  unless method == :lexer_name_for || method == :highlight || method == :css
365
365
  res = Yajl.load(res, :symbolize_keys => true)
366
366
  end
367
- res = res[0..-2]
367
+ res = res.rstrip if res.class == String
368
+ res
368
369
  end
369
370
 
370
371
  # Convert a text header into JSON for easy access.
@@ -1,3 +1,3 @@
1
1
  module Pygments
2
- VERSION = '0.4.2'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -17,6 +17,18 @@ class PygmentsHighlightTest < Test::Unit::TestCase
17
17
  assert_equal '<div class', code[0..9]
18
18
  end
19
19
 
20
+ def test_full_html_highlight
21
+ code = P.highlight(RUBY_CODE)
22
+ assert_match '<span class="c1">#!/usr/bin/ruby</span>', code
23
+ assert_equal "<div class=\"highlight\"><pre><span class=\"c1\">#!/usr/bin/ruby</span>\n<span class=\"nb\">puts</span> <span class=\"s1\">&#39;foo&#39;</span>\n</pre></div>", code
24
+ end
25
+
26
+ def test_full_table_highlight
27
+ code = P.highlight(RUBY_CODE, :options => {:linenos => true})
28
+ assert_match '<span class="c1">#!/usr/bin/ruby</span>', code
29
+ assert_equal "<table class=\"highlighttable\"><tr><td class=\"linenos\"><div class=\"linenodiv\"><pre>1\n2</pre></div></td><td class=\"code\"><div class=\"highlight\"><pre><span class=\"c1\">#!/usr/bin/ruby</span>\n<span class=\"nb\">puts</span> <span class=\"s1\">&#39;foo&#39;</span>\n</pre></div>\n</td></tr></table>", code
30
+ end
31
+
20
32
  def test_highlight_works_with_larger_files
21
33
  code = P.highlight(REDIS_CODE)
22
34
  assert_match 'used_memory_peak_human', code
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pygments.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-25 00:00:00.000000000 Z
13
+ date: 2013-04-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: yajl-ruby