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 +3 -8
- data/config/style.css +125 -96
- data/lib/gimli.rb +0 -1
- data/lib/gimli/markup.rb +4 -12
- data/lib/gimli/version.rb +1 -1
- data/spec/gimli/markup_spec.rb +0 -52
- metadata +6 -7
- data/lib/gimli/albino.rb +0 -9
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
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
.
|
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
|
-
|
40
|
-
{
|
41
|
-
|
42
|
-
|
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
|
-
.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
.
|
56
|
-
.
|
57
|
-
.
|
58
|
-
.
|
59
|
-
.
|
60
|
-
|
61
|
-
.
|
62
|
-
.
|
63
|
-
|
64
|
-
.
|
65
|
-
.
|
66
|
-
|
67
|
-
.
|
68
|
-
.
|
69
|
-
.
|
70
|
-
.
|
71
|
-
.
|
72
|
-
.
|
73
|
-
.
|
74
|
-
.
|
75
|
-
.
|
76
|
-
.
|
77
|
-
.
|
78
|
-
.
|
79
|
-
.
|
80
|
-
.
|
81
|
-
.
|
82
|
-
.
|
83
|
-
.
|
84
|
-
.
|
85
|
-
.
|
86
|
-
.
|
87
|
-
.
|
88
|
-
.
|
89
|
-
.
|
90
|
-
.
|
91
|
-
.
|
92
|
-
.
|
93
|
-
.
|
94
|
-
.
|
95
|
-
.
|
96
|
-
.
|
97
|
-
.
|
98
|
-
.
|
99
|
-
.
|
100
|
-
.
|
101
|
-
.
|
102
|
-
.
|
103
|
-
.
|
104
|
-
.
|
105
|
-
.
|
106
|
-
.
|
107
|
-
.
|
108
|
-
.
|
109
|
-
.
|
110
|
-
.
|
111
|
-
.
|
112
|
-
.
|
113
|
-
.
|
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
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
|
272
|
-
|
273
|
-
body
|
264
|
+
if spec[:lang]
|
265
|
+
CodeRay.scan(spec[:code], spec[:lang]).html(:line_numbers => :table)
|
274
266
|
else
|
275
|
-
|
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
data/spec/gimli/markup_spec.rb
CHANGED
@@ -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\"><h1></span>Abcåäö<span class=\"nt\"></h1></span>\n" +
|
32
|
-
"<span class=\"nt\"><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\">/></span>\n</pre>\n</div>\n"
|
35
|
-
|
36
|
-
output_without_pygments = "<p>Abcåäö</p>\n<pre>\n <code><h1>Abcåäö</h1>\n<img " +
|
37
|
-
"src=\"åäö.png\" alt=\"ÅÄÖ\" /></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><img src=\"åäö.png\" " +
|
53
|
-
"alt=\"Abcåäö\" /></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.
|
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:
|
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.
|
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.
|
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:
|
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:
|
297
|
+
hash: 2809593776543819551
|
299
298
|
requirements: []
|
300
299
|
rubyforge_project: gimli
|
301
300
|
rubygems_version: 1.8.24
|