gimli 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -63,22 +63,17 @@ h2. Syntax highlighting
63
63
 
64
64
  In page files you can get automatic syntax highlighting for a wide range of languages by using the following syntax:
65
65
 
66
- If you want to be able to use the syntax highlightning you have to install "pygments":http://pygments.org
67
-
68
- Example installation on Ubuntu
69
-
70
- bc. $ sudo aptitude install python-setuptools
71
- $ sudo easy_install pygments
72
-
73
66
  bc. ```ruby
74
67
  def foo
75
68
  puts 'bar'
76
69
  end
77
70
  ```
78
71
 
79
- The block must start with three backticks (as the first characters on the line). After that comes the name of the language that is contained by the block. The language must be one of the short name lexer strings supported by Pygments. See the list of lexers for valid options.
72
+ The block must start with three backticks (as the first characters on the line). After that comes the name of the language that is contained by the block. The language must be one of the short name lexer strings supported by coderay. See the list of lexers for valid options.
80
73
 
81
74
  If the block contents are indented two spaces or one tab, then that whitespace will be ignored (this makes the blocks easier to read in plaintext).
82
75
 
83
76
  The block must end with three backticks as the first characters on a line.
84
77
 
78
+ The syntax highlightning is powered by "coderay":https://github.com/rubychan/coderay and is using a "github theme":https://github.com/pie4dan/CodeRay-GitHub-Theme.
79
+
data/config/style.css CHANGED
@@ -9,106 +9,135 @@ body
9
9
  page-break-before: always;
10
10
  }
11
11
 
12
- /* Code */
13
- code, tt
14
- {
15
- background-color: #f8f8f8;
16
- border: 1px solid #dedede;
17
- font-size: 13px;
18
- padding: 1px 5px;
19
-
20
- -moz-border-radius: 3px;
21
- -webkit-border-radius: 3px;
22
- border-radius: 3px;
12
+ .CodeRay {
13
+ background-color: #FFF;
14
+ border: 1px solid #CCC;
15
+ font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
16
+ color: #000;
17
+ padding: 1em 0px 1em 1em;
23
18
  }
24
19
 
25
- .highlight pre, pre
26
- {
27
- background-color: #f8f8f8;
28
- border: 1px solid #ccc;
29
- font-size: 13px;
30
- line-height: 19px;
31
- padding: 6px;
32
- word-wrap: break-word;
33
-
34
- -moz-border-radius: 3px;
35
- -webkit-border-radius: 3px;
36
- border-radius: 3px;
20
+ .CodeRay pre {
21
+ margin: 0px;
37
22
  }
38
23
 
39
- pre code, pre tt
40
- {
41
- background-color: transparent;
42
- border: none;
24
+ div.CodeRay { }
25
+ span.CodeRay { white-space: pre; border: 0px; padding: 2px }
26
+
27
+ table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px }
28
+ table.CodeRay td {
29
+ padding: 1em 0.5em;
30
+ vertical-align: top;
43
31
  }
44
32
 
45
- .highlight .hll { background-color: #ffffcc }
46
- .highlight .c { color: #8f5902; font-style: italic } /* Comment */
47
- .highlight .err { color: #a40000; border: 1px solid #ef2929 } /* Error */
48
- .highlight .g { color: #000000 } /* Generic */
49
- .highlight .k { color: #204a87; font-weight: bold } /* Keyword */
50
- .highlight .l { color: #000000 } /* Literal */
51
- .highlight .n { color: #000000 } /* Name */
52
- .highlight .o { color: #ce5c00; font-weight: bold } /* Operator */
53
- .highlight .x { color: #000000 } /* Other */
54
- .highlight .p { color: #000000; font-weight: bold } /* Punctuation */
55
- .highlight .cm { color: #8f5902; font-style: italic } /* Comment.Multiline */
56
- .highlight .cp { color: #8f5902; font-style: italic } /* Comment.Preproc */
57
- .highlight .c1 { color: #8f5902; font-style: italic } /* Comment.Single */
58
- .highlight .cs { color: #8f5902; font-style: italic } /* Comment.Special */
59
- .highlight .gd { color: #a40000 } /* Generic.Deleted */
60
- .highlight .ge { color: #000000; font-style: italic } /* Generic.Emph */
61
- .highlight .gr { color: #ef2929 } /* Generic.Error */
62
- .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
63
- .highlight .gi { color: #00A000 } /* Generic.Inserted */
64
- .highlight .go { color: #000000; font-style: italic } /* Generic.Output */
65
- .highlight .gp { color: #8f5902 } /* Generic.Prompt */
66
- .highlight .gs { color: #000000; font-weight: bold } /* Generic.Strong */
67
- .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
68
- .highlight .gt { color: #a40000; font-weight: bold } /* Generic.Traceback */
69
- .highlight .kc { color: #204a87; font-weight: bold } /* Keyword.Constant */
70
- .highlight .kd { color: #204a87; font-weight: bold } /* Keyword.Declaration */
71
- .highlight .kn { color: #204a87; font-weight: bold } /* Keyword.Namespace */
72
- .highlight .kp { color: #204a87; font-weight: bold } /* Keyword.Pseudo */
73
- .highlight .kr { color: #204a87; font-weight: bold } /* Keyword.Reserved */
74
- .highlight .kt { color: #204a87; font-weight: bold } /* Keyword.Type */
75
- .highlight .ld { color: #000000 } /* Literal.Date */
76
- .highlight .m { color: #0000cf; font-weight: bold } /* Literal.Number */
77
- .highlight .s { color: #4e9a06 } /* Literal.String */
78
- .highlight .na { color: #c4a000 } /* Name.Attribute */
79
- .highlight .nb { color: #204a87 } /* Name.Builtin */
80
- .highlight .nc { color: #000000 } /* Name.Class */
81
- .highlight .no { color: #000000 } /* Name.Constant */
82
- .highlight .nd { color: #5c35cc; font-weight: bold } /* Name.Decorator */
83
- .highlight .ni { color: #ce5c00 } /* Name.Entity */
84
- .highlight .ne { color: #cc0000; font-weight: bold } /* Name.Exception */
85
- .highlight .nf { color: #000000 } /* Name.Function */
86
- .highlight .nl { color: #f57900 } /* Name.Label */
87
- .highlight .nn { color: #000000 } /* Name.Namespace */
88
- .highlight .nx { color: #000000 } /* Name.Other */
89
- .highlight .py { color: #000000 } /* Name.Property */
90
- .highlight .nt { color: #204a87; font-weight: bold } /* Name.Tag */
91
- .highlight .nv { color: #000000 } /* Name.Variable */
92
- .highlight .ow { color: #204a87; font-weight: bold } /* Operator.Word */
93
- .highlight .w { color: #f8f8f8; text-decoration: underline } /* Text.Whitespace */
94
- .highlight .mf { color: #0000cf; font-weight: bold } /* Literal.Number.Float */
95
- .highlight .mh { color: #0000cf; font-weight: bold } /* Literal.Number.Hex */
96
- .highlight .mi { color: #0000cf; font-weight: bold } /* Literal.Number.Integer */
97
- .highlight .mo { color: #0000cf; font-weight: bold } /* Literal.Number.Oct */
98
- .highlight .sb { color: #4e9a06 } /* Literal.String.Backtick */
99
- .highlight .sc { color: #4e9a06 } /* Literal.String.Char */
100
- .highlight .sd { color: #8f5902; font-style: italic } /* Literal.String.Doc */
101
- .highlight .s2 { color: #4e9a06 } /* Literal.String.Double */
102
- .highlight .se { color: #4e9a06 } /* Literal.String.Escape */
103
- .highlight .sh { color: #4e9a06 } /* Literal.String.Heredoc */
104
- .highlight .si { color: #4e9a06 } /* Literal.String.Interpol */
105
- .highlight .sx { color: #4e9a06 } /* Literal.String.Other */
106
- .highlight .sr { color: #4e9a06 } /* Literal.String.Regex */
107
- .highlight .s1 { color: #4e9a06 } /* Literal.String.Single */
108
- .highlight .ss { color: #4e9a06 } /* Literal.String.Symbol */
109
- .highlight .bp { color: #3465a4 } /* Name.Builtin.Pseudo */
110
- .highlight .vc { color: #000000 } /* Name.Variable.Class */
111
- .highlight .vg { color: #000000 } /* Name.Variable.Global */
112
- .highlight .vi { color: #000000 } /* Name.Variable.Instance */
113
- .highlight .il { color: #0000cf; font-weight: bold } /* Literal.Number.Integer.Long */
33
+ .CodeRay .line-numbers, .CodeRay .no {
34
+ background-color: #ECECEC;
35
+ color: #AAA;
36
+ text-align: right;
37
+ }
38
+
39
+ .CodeRay .line-numbers a {
40
+ color: #AAA;
41
+ }
42
+
43
+ .CodeRay .line-numbers tt { font-weight: bold }
44
+ .CodeRay .line-numbers .highlighted { color: red }
45
+ .CodeRay .line { display: block; float: left; width: 100%; }
46
+ .CodeRay span.line-numbers { padding: 0px 4px }
47
+ .CodeRay .code { width: 100% }
48
+
49
+ ol.CodeRay { font-size: 10pt }
50
+ ol.CodeRay li { white-space: pre }
51
+
52
+ .CodeRay .code pre { overflow: auto }
53
+ .CodeRay .debug { color:white ! important; background:blue ! important; }
54
+
55
+ .CodeRay .annotation { color:#007 }
56
+ .CodeRay .attribute-name { color:#f08 }
57
+ .CodeRay .attribute-value { color:#700 }
58
+ .CodeRay .binary { color:#509; font-weight:bold }
59
+ .CodeRay .comment { color:#998; font-style: italic;}
60
+ .CodeRay .char { color:#04D }
61
+ .CodeRay .char .content { color:#04D }
62
+ .CodeRay .char .delimiter { color:#039 }
63
+ .CodeRay .class { color:#458; font-weight:bold }
64
+ .CodeRay .complex { color:#A08; font-weight:bold }
65
+ .CodeRay .constant { color:teal; }
66
+ .CodeRay .color { color:#0A0 }
67
+ .CodeRay .class-variable { color:#369 }
68
+ .CodeRay .decorator { color:#B0B; }
69
+ .CodeRay .definition { color:#099; font-weight:bold }
70
+ .CodeRay .directive { color:#088; font-weight:bold }
71
+ .CodeRay .delimiter { color:black }
72
+ .CodeRay .doc { color:#970 }
73
+ .CodeRay .doctype { color:#34b }
74
+ .CodeRay .doc-string { color:#D42; font-weight:bold }
75
+ .CodeRay .escape { color:#666; font-weight:bold }
76
+ .CodeRay .entity { color:#800; font-weight:bold }
77
+ .CodeRay .error { color:#F00; background-color:#FAA }
78
+ .CodeRay .exception { color:#C00; font-weight:bold }
79
+ .CodeRay .filename { color:#099; }
80
+ .CodeRay .function { color:#900; font-weight:bold }
81
+ .CodeRay .global-variable { color:teal; font-weight:bold }
82
+ .CodeRay .hex { color:#058; font-weight:bold }
83
+ .CodeRay .integer { color:#099; }
84
+ .CodeRay .include { color:#B44; font-weight:bold }
85
+ .CodeRay .inline { color: black }
86
+ .CodeRay .inline .inline { background: #ccc }
87
+ .CodeRay .inline .inline .inline { background: #bbb }
88
+ .CodeRay .inline .inline-delimiter { color: #D14; }
89
+ .CodeRay .inline-delimiter { color: #D14; }
90
+ .CodeRay .important { color:#f00; }
91
+ .CodeRay .interpreted { color:#B2B; font-weight:bold }
92
+ .CodeRay .instance-variable { color:teal }
93
+ .CodeRay .label { color:#970; font-weight:bold }
94
+ .CodeRay .local-variable { color:#963 }
95
+ .CodeRay .octal { color:#40E; font-weight:bold }
96
+ .CodeRay .operator { }
97
+ .CodeRay .predefined-constant { font-weight:bold }
98
+ .CodeRay .predefined { color:#369; font-weight:bold }
99
+ .CodeRay .preprocessor { color:#579; }
100
+ .CodeRay .pseudo-class { color:#00C; font-weight:bold }
101
+ .CodeRay .predefined-type { color:#074; font-weight:bold }
102
+ .CodeRay .reserved, .keyword { color:#000; font-weight:bold }
103
+
104
+ .CodeRay .key { color: #808; }
105
+ .CodeRay .key .delimiter { color: #606; }
106
+ .CodeRay .key .char { color: #80f; }
107
+ .CodeRay .value { color: #088; }
108
+
109
+ .CodeRay .regexp { background-color:#fff0ff }
110
+ .CodeRay .regexp .content { color:#808 }
111
+ .CodeRay .regexp .delimiter { color:#404 }
112
+ .CodeRay .regexp .modifier { color:#C2C }
113
+ .CodeRay .regexp .function { color:#404; font-weight: bold }
114
+
115
+ .CodeRay .string { color: #D20; }
116
+ .CodeRay .string .string { }
117
+ .CodeRay .string .string .string { background-color:#ffd0d0 }
118
+ .CodeRay .string .content { color: #D14; }
119
+ .CodeRay .string .char { color: #D14; }
120
+ .CodeRay .string .delimiter { color: #D14; }
121
+
122
+ .CodeRay .shell { color:#D14 }
123
+ .CodeRay .shell .content { }
124
+ .CodeRay .shell .delimiter { color:#D14 }
125
+
126
+ .CodeRay .symbol { color:#990073 }
127
+ .CodeRay .symbol .content { color:#A60 }
128
+ .CodeRay .symbol .delimiter { color:#630 }
129
+
130
+ .CodeRay .tag { color:#070 }
131
+ .CodeRay .tag-special { color:#D70; font-weight:bold }
132
+ .CodeRay .type { color:#339; font-weight:bold }
133
+ .CodeRay .variable { color:#036 }
134
+
135
+ .CodeRay .insert { background: #afa; }
136
+ .CodeRay .delete { background: #faa; }
137
+ .CodeRay .change { color: #aaf; background: #007; }
138
+ .CodeRay .head { color: #f8f; background: #505 }
114
139
 
140
+ .CodeRay .insert .insert { color: #080; font-weight:bold }
141
+ .CodeRay .delete .delete { color: #800; font-weight:bold }
142
+ .CodeRay .change .change { color: #66f; }
143
+ .CodeRay .head .head { color: #f4f; }
data/lib/gimli.rb CHANGED
@@ -5,7 +5,6 @@ require 'gimli/config'
5
5
  require 'gimli/setup'
6
6
  require 'gimli/markupfile'
7
7
  require 'gimli/converter'
8
- require 'gimli/albino'
9
8
  require 'gimli/path'
10
9
  require 'gimli/wkhtmltopdf'
11
10
 
data/lib/gimli/markup.rb CHANGED
@@ -13,10 +13,10 @@
13
13
  # furnished to do so, subject to the following conditions:
14
14
 
15
15
  require 'digest/sha1'
16
- require 'cgi'
17
16
 
18
17
  require 'github/markup'
19
18
  require 'nokogiri'
19
+ require 'coderay'
20
20
 
21
21
  module Gimli
22
22
 
@@ -259,20 +259,12 @@ module Gimli
259
259
  blocks << [spec[:lang], code]
260
260
  end
261
261
 
262
- highlighted = begin
263
- blocks.size.zero? ? [] : Gimli::Albino.colorize(blocks)
264
- rescue ::Albino::ShellArgumentError, ::Albino::TimeoutExceeded,
265
- ::Albino::MaximumOutputExceeded
266
- []
267
- end
268
-
269
262
  @codemap.each do |id, spec|
270
263
  body = spec[:output] || begin
271
- if (body = highlighted.shift.to_s).size > 0
272
- update_cache(:code, id, body)
273
- body
264
+ if spec[:lang]
265
+ CodeRay.scan(spec[:code], spec[:lang]).html(:line_numbers => :table)
274
266
  else
275
- "<pre><code>#{CGI.escapeHTML(spec[:code])}</code></pre>"
267
+ CodeRay.scan(spec[:code], :text).div
276
268
  end
277
269
  end
278
270
  body = body.force_encoding('utf-8') if body.respond_to? :force_encoding
data/lib/gimli/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Gimli
4
4
 
5
- Version = "0.3.0"
5
+ Version = "0.3.1"
6
6
 
7
7
  end
8
8
 
@@ -6,58 +6,6 @@ require './lib/gimli'
6
6
 
7
7
  describe Gimli::Markup do
8
8
 
9
- it 'should give correct code block' do
10
-
11
- output_with_pygments = "<p>a</p>\n<div class=\"highlight\"><pre>" +
12
- "<span class=\"n\">x</span> <span class=\"o\">=</span> " +
13
- "<span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>"
14
-
15
- output_without_pygments = "<p>a</p>\n<pre>\n <code>x = 1</code>\n</pre>\n<p>b</p>"
16
-
17
- file = Gimli::MarkupFile.new File.expand_path('../../fixtures/code_block.textile', __FILE__)
18
- markup = Gimli::Markup.new file
19
-
20
- # Check if the html seems to be highlighted
21
- if markup.render.include? "<div class=\"highlight\">"
22
- markup.render.should == output_with_pygments
23
- else
24
- markup.render.should == output_without_pygments
25
- end
26
- end
27
-
28
- it 'should give correct code block for utf8' do
29
-
30
- output_with_pygments = "<p>Abcåäö</p>\n<div class=\"highlight\"><pre>" +
31
- "<span class=\"nt\">&lt;h1&gt;</span>Abcåäö<span class=\"nt\">&lt;/h1&gt;</span>\n" +
32
- "<span class=\"nt\">&lt;img</span> <span class=\"na\">src=</span><span class=\"s\">\"åäö.png\"" +
33
- "</span> <span class=\"na\">alt=</span><span class=\"s\">\"ÅÄÖ\"" +
34
- "</span> <span class=\"nt\">/&gt;</span>\n</pre>\n</div>\n"
35
-
36
- output_without_pygments = "<p>Abcåäö</p>\n<pre>\n <code>&lt;h1&gt;Abcåäö&lt;/h1&gt;\n&lt;img " +
37
- "src=\"åäö.png\" alt=\"ÅÄÖ\" /&gt;</code>\n</pre>"
38
-
39
- file = Gimli::MarkupFile.new File.expand_path('../../fixtures/code_block_with_utf8.textile', __FILE__)
40
- markup = Gimli::Markup.new file
41
-
42
- # Check if the html seems to be highlighted
43
- if markup.render.include? "<div class=\"highlight\">"
44
- markup.render.should == output_with_pygments
45
- else
46
- markup.render.should == output_without_pygments
47
- end
48
- end
49
-
50
- it 'should give correct code for utf8' do
51
-
52
- output = "<p>a</p>\n<code>&lt;img src=\"åäö.png\" " +
53
- "alt=\"Abcåäö\" /&gt;</code>\n<p>b</p>"
54
-
55
- file = Gimli::MarkupFile.new File.expand_path('../../fixtures/code_with_utf8.textile', __FILE__)
56
- markup = Gimli::Markup.new file
57
-
58
- markup.render.should == output
59
- end
60
-
61
9
  it "should remove yaml front matter if asked to" do
62
10
  output = "<p>This should be at the top of the file</p>"
63
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gimli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -108,13 +108,13 @@ dependencies:
108
108
  - !ruby/object:Gem::Version
109
109
  version: 0.8.0
110
110
  - !ruby/object:Gem::Dependency
111
- name: albino
111
+ name: coderay
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.3.3
117
+ version: 1.0.7
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.3.3
125
+ version: 1.0.7
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: nokogiri
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -251,7 +251,6 @@ files:
251
251
  - lib/gimli/converter.rb
252
252
  - lib/gimli/wkhtmltopdf.rb
253
253
  - lib/gimli/setup.rb
254
- - lib/gimli/albino.rb
255
254
  - lib/gimli/config.rb
256
255
  - lib/gimli/version.rb
257
256
  - lib/gimli/markup.rb
@@ -286,7 +285,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
286
285
  version: '0'
287
286
  segments:
288
287
  - 0
289
- hash: 4505981425751423079
288
+ hash: 2809593776543819551
290
289
  required_rubygems_version: !ruby/object:Gem::Requirement
291
290
  none: false
292
291
  requirements:
@@ -295,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
295
294
  version: '0'
296
295
  segments:
297
296
  - 0
298
- hash: 4505981425751423079
297
+ hash: 2809593776543819551
299
298
  requirements: []
300
299
  rubyforge_project: gimli
301
300
  rubygems_version: 1.8.24
data/lib/gimli/albino.rb DELETED
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'albino/multi'
4
-
5
- # Use Albino Multi
6
- class Gimli::Albino < Albino::Multi
7
- self.bin = ::Albino::Multi.bin
8
- end
9
-