gimli 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gimli CHANGED
@@ -9,5 +9,5 @@ if ARGV.flags.version?
9
9
  exit
10
10
  end
11
11
 
12
- Gimli.process! ARGV.flags.file, ARGV.flags.recursive?, ARGV.flags.merge?, ARGV.flags.pagenumbers?, ARGV.flags.removefrontmatter, ARGV.flags.outputfilename, ARGV.flags.outputdir, ARGV.flags.stylesheet
12
+ Gimli.process! ARGV.flags.file, ARGV.flags.recursive?, ARGV.flags.merge?, ARGV.flags.pagenumbers?, ARGV.flags.tableofcontents?, ARGV.flags.removefrontmatter, ARGV.flags.outputfilename, ARGV.flags.outputdir, ARGV.flags.stylesheet
13
13
 
data/lib/gimli.rb CHANGED
@@ -10,10 +10,10 @@ require 'gimli/path'
10
10
  module Gimli
11
11
 
12
12
  # Starts the processing of selected files
13
- def self.process!(file, recursive = false, merge = false, pagenumbers = false, remove_front_matter = false, output_filename = nil, output_dir = nil, stylesheet = nil)
13
+ def self.process!(file, recursive = false, merge = false, pagenumbers = false, tableofcontents = false, remove_front_matter = false, output_filename = nil, output_dir = nil, stylesheet = nil)
14
14
 
15
15
 
16
16
  @files = Path.list_valid(file, recursive).map { |file| MarkupFile.new(file) }
17
- Converter.new(@files, merge, pagenumbers, remove_front_matter, output_filename, output_dir, stylesheet).convert!
17
+ Converter.new(@files, merge, pagenumbers, tableofcontents, remove_front_matter, output_filename, output_dir, stylesheet).convert!
18
18
  end
19
19
  end
@@ -15,14 +15,16 @@ module Gimli
15
15
  # @param [Array] files The list of Gimli::MarkupFile to convert (passing a single file will still work)
16
16
  # @param [Boolean] merge
17
17
  # @param [Boolean] pagenumbers
18
+ # @param [Boolean] tableofcontents
18
19
  # @param [Boolean] remove_front_matter
19
20
  # @param [String] output_filename
20
21
  # @param [String] output_dir
21
22
  # @param [String] stylesheet
22
- def initialize(files, merge = false, pagenumbers = false, remove_front_matter = false, output_filename = nil, output_dir = nil, stylesheet = nil)
23
+ def initialize(files, merge = false, pagenumbers = false, tableofcontents = false, remove_front_matter = false, output_filename = nil, output_dir = nil, stylesheet = nil)
23
24
  @files = files
24
25
  @merge = merge
25
26
  @pagenumbers = pagenumbers
27
+ @tableofcontents = tableofcontents
26
28
  @remove_front_matter = remove_front_matter
27
29
  @output_filename = output_filename
28
30
  @output_dir = output_dir
@@ -67,6 +69,7 @@ module Gimli
67
69
  def pdf_kit(html)
68
70
  options = {}
69
71
  options.merge!({ :footer_right => '[page]/[toPage]' }) if @pagenumbers
72
+ options.merge!({ :toc => true }) if @tableofcontents
70
73
  kit = PDFKit.new(html, options)
71
74
 
72
75
  load_stylesheets kit
data/lib/gimli/markup.rb CHANGED
@@ -14,7 +14,6 @@
14
14
 
15
15
  require 'digest/sha1'
16
16
  require 'cgi'
17
- require 'iconv'
18
17
 
19
18
  require 'github/markup'
20
19
  require 'nokogiri'
@@ -250,7 +249,12 @@ module Gimli
250
249
  code.gsub!(/^( |\t)/m, '')
251
250
  end
252
251
 
253
- code = Iconv.conv('ISO-8859-1//IGNORE', 'utf-8', code)
252
+ if RUBY_VERSION =~ /1\.8\../
253
+ require 'iconv'
254
+ code = Iconv.conv('ISO-8859-1//IGNORE', 'utf-8', code)
255
+ else
256
+ code = code.encode('ISO-8859-1', 'utf-8')
257
+ end
254
258
 
255
259
  blocks << [spec[:lang], code]
256
260
  end
@@ -271,6 +275,7 @@ module Gimli
271
275
  "<pre><code>#{CGI.escapeHTML(spec[:code])}</code></pre>"
272
276
  end
273
277
  end
278
+ body = body.force_encoding('utf-8') if body.respond_to? :force_encoding
274
279
  data.gsub!(id, body)
275
280
  end
276
281
 
data/lib/gimli/setup.rb CHANGED
@@ -32,6 +32,10 @@ module Gimli extend OptiFlagSet
32
32
  description 'Print the page numbers in the lower right corner of all pages in pdf'
33
33
  alternate_forms 'p'
34
34
  end
35
+ optional_switch_flag 'tableofcontents' do
36
+ description 'Insert a table of contents first in the pdf'
37
+ alternate_forms 't'
38
+ end
35
39
  optional_switch_flag 'removefrontmatter' do
36
40
  description 'Remove yaml frontmatter from your files.'
37
41
  alternate_forms 'y'
data/lib/gimli/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Gimli
4
4
 
5
- Version = "0.2.2"
5
+ Version = "0.2.3"
6
6
 
7
7
  end
8
8
 
@@ -1,4 +1,4 @@
1
- a
1
+ Abcåäö
2
2
 
3
3
  ```html
4
4
  <h1>Abcåäö</h1>
@@ -31,7 +31,7 @@ describe Gimli::Converter do
31
31
  file = Gimli::MarkupFile.new 'fake'
32
32
  output_filename = 'my_file'
33
33
 
34
- converter = Gimli::Converter.new [file], false, false, false, output_filename
34
+ converter = Gimli::Converter.new [file], false, false, false, false, output_filename
35
35
  mock(converter).output_dir { Dir.getwd }
36
36
 
37
37
  converter.output_file.should == File.join(Dir.getwd, "#{output_filename}.pdf")
@@ -50,7 +50,7 @@ describe Gimli::Converter do
50
50
  dir = '/tmp/out'
51
51
 
52
52
  file = Gimli::MarkupFile.new 'fake'
53
- converter = Gimli::Converter.new file, false, false, false, nil, dir
53
+ converter = Gimli::Converter.new file, false, false, false, false, nil, dir
54
54
 
55
55
  mock(File).directory?(dir) { true }
56
56
 
@@ -68,7 +68,7 @@ describe Gimli::Converter do
68
68
  file = Gimli::MarkupFile.new 'fake'
69
69
  stylesheet = '/home/me/gimli/my-style.css'
70
70
 
71
- converter = Gimli::Converter.new file, false, false, false, nil, nil, stylesheet
71
+ converter = Gimli::Converter.new file, false, false, false, false, nil, nil, stylesheet
72
72
 
73
73
  converter.stylesheet.should == stylesheet
74
74
  end
@@ -12,7 +12,7 @@ describe Gimli::Markup do
12
12
  "<span class=\"n\">x</span> <span class=\"o\">=</span> " +
13
13
  "<span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>"
14
14
 
15
- output_without_pygments = "<p>a</p>\n<pre><code>x = 1</code></pre>\n<p>b</p>"
15
+ output_without_pygments = "<p>a</p>\n<pre>\n <code>x = 1</code>\n</pre>\n<p>b</p>"
16
16
 
17
17
  file = Gimli::MarkupFile.new File.expand_path('../../fixtures/code_block.textile', __FILE__)
18
18
  markup = Gimli::Markup.new file
@@ -27,14 +27,14 @@ describe Gimli::Markup do
27
27
 
28
28
  it 'should give correct code block for utf8' do
29
29
 
30
- output_with_pygments = "<p>a</p>\n<div class=\"highlight\"><pre>" +
30
+ output_with_pygments = "<p>Abcåäö</p>\n<div class=\"highlight\"><pre>" +
31
31
  "<span class=\"nt\">&lt;h1&gt;</span>Abcåäö<span class=\"nt\">&lt;/h1&gt;</span>\n" +
32
32
  "<span class=\"nt\">&lt;img</span> <span class=\"na\">src=</span><span class=\"s\">\"åäö.png\"" +
33
33
  "</span> <span class=\"na\">alt=</span><span class=\"s\">\"ÅÄÖ\"" +
34
34
  "</span> <span class=\"nt\">/&gt;</span>\n</pre>\n</div>\n"
35
35
 
36
- output_without_pygments = "<p>a</p>\n<pre><code>&lt;h1&gt;Abcåäö&lt;/h1&gt;\n&lt;img " +
37
- "src=\"åäö.png\" alt=\"ÅÄÖ\" /&gt;</code></pre>"
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
38
 
39
39
  file = Gimli::MarkupFile.new File.expand_path('../../fixtures/code_block_with_utf8.textile', __FILE__)
40
40
  markup = Gimli::Markup.new file
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.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,33 +9,43 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-09 00:00:00.000000000Z
12
+ date: 2012-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: github-markup
16
- requirement: &20702400 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.5.3
21
+ version: 0.7.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *20702400
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.7.4
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: redcarpet
27
- requirement: &20696880 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
31
36
  - !ruby/object:Gem::Version
32
- version: 1.17.2
37
+ version: 2.1.1
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *20696880
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.1.1
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: RedCloth
38
- requirement: &20693760 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,21 +53,31 @@ dependencies:
43
53
  version: 4.2.7
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *20693760
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 4.2.7
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: org-ruby
49
- requirement: &20692000 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
53
68
  - !ruby/object:Gem::Version
54
- version: 0.5.3
69
+ version: 0.7.1
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *20692000
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.7.1
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: creole
60
- requirement: &20689620 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,21 +85,31 @@ dependencies:
65
85
  version: 0.4.2
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *20689620
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.4.2
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: wikicloth
71
- requirement: &20682020 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
75
100
  - !ruby/object:Gem::Version
76
- version: 0.6.3
101
+ version: 0.8.0
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *20682020
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.8.0
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: albino
82
- requirement: &20680400 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ~>
@@ -87,32 +117,47 @@ dependencies:
87
117
  version: 1.3.3
88
118
  type: :runtime
89
119
  prerelease: false
90
- version_requirements: *20680400
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.3.3
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: nokogiri
93
- requirement: &20678620 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ~>
97
132
  - !ruby/object:Gem::Version
98
- version: 1.4.4
133
+ version: 1.5.5
99
134
  type: :runtime
100
135
  prerelease: false
101
- version_requirements: *20678620
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 1.5.5
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: wkhtmltopdf-binary
104
- requirement: &20666520 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
147
  - - ~>
108
148
  - !ruby/object:Gem::Version
109
- version: 0.9.5.3
149
+ version: 0.9.9.1
110
150
  type: :runtime
111
151
  prerelease: false
112
- version_requirements: *20666520
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 0.9.9.1
113
158
  - !ruby/object:Gem::Dependency
114
159
  name: pdfkit
115
- requirement: &20663960 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
116
161
  none: false
117
162
  requirements:
118
163
  - - ~>
@@ -120,10 +165,15 @@ dependencies:
120
165
  version: 0.5.2
121
166
  type: :runtime
122
167
  prerelease: false
123
- version_requirements: *20663960
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 0.5.2
124
174
  - !ruby/object:Gem::Dependency
125
175
  name: optiflag
126
- requirement: &20650800 !ruby/object:Gem::Requirement
176
+ requirement: !ruby/object:Gem::Requirement
127
177
  none: false
128
178
  requirements:
129
179
  - - ~>
@@ -131,10 +181,15 @@ dependencies:
131
181
  version: '0.7'
132
182
  type: :runtime
133
183
  prerelease: false
134
- version_requirements: *20650800
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ~>
188
+ - !ruby/object:Gem::Version
189
+ version: '0.7'
135
190
  - !ruby/object:Gem::Dependency
136
191
  name: rake
137
- requirement: &20649780 !ruby/object:Gem::Requirement
192
+ requirement: !ruby/object:Gem::Requirement
138
193
  none: false
139
194
  requirements:
140
195
  - - ! '>='
@@ -142,10 +197,15 @@ dependencies:
142
197
  version: '0'
143
198
  type: :development
144
199
  prerelease: false
145
- version_requirements: *20649780
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
146
206
  - !ruby/object:Gem::Dependency
147
207
  name: rspec
148
- requirement: &20648240 !ruby/object:Gem::Requirement
208
+ requirement: !ruby/object:Gem::Requirement
149
209
  none: false
150
210
  requirements:
151
211
  - - ! '>='
@@ -153,10 +213,15 @@ dependencies:
153
213
  version: '0'
154
214
  type: :development
155
215
  prerelease: false
156
- version_requirements: *20648240
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
157
222
  - !ruby/object:Gem::Dependency
158
223
  name: rr
159
- requirement: &20646200 !ruby/object:Gem::Requirement
224
+ requirement: !ruby/object:Gem::Requirement
160
225
  none: false
161
226
  requirements:
162
227
  - - ! '>='
@@ -164,10 +229,15 @@ dependencies:
164
229
  version: '0'
165
230
  type: :development
166
231
  prerelease: false
167
- version_requirements: *20646200
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ! '>='
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
168
238
  - !ruby/object:Gem::Dependency
169
239
  name: bundler
170
- requirement: &20645360 !ruby/object:Gem::Requirement
240
+ requirement: !ruby/object:Gem::Requirement
171
241
  none: false
172
242
  requirements:
173
243
  - - ! '>='
@@ -175,7 +245,12 @@ dependencies:
175
245
  version: '0'
176
246
  type: :development
177
247
  prerelease: false
178
- version_requirements: *20645360
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
179
254
  description: Utility for converting markup files to pdf files. Useful for reports
180
255
  etc.
181
256
  email: fredrik.wallgren@gmail.com
@@ -187,25 +262,25 @@ extra_rdoc_files:
187
262
  - LICENSE
188
263
  files:
189
264
  - bin/gimli
190
- - lib/gimli/version.rb
191
265
  - lib/gimli/path.rb
192
- - lib/gimli/albino.rb
193
266
  - lib/gimli/markupfile.rb
194
- - lib/gimli/markup.rb
195
- - lib/gimli/setup.rb
196
267
  - lib/gimli/converter.rb
268
+ - lib/gimli/setup.rb
269
+ - lib/gimli/albino.rb
270
+ - lib/gimli/version.rb
271
+ - lib/gimli/markup.rb
197
272
  - lib/gimli.rb
198
- - spec/spec_helper.rb
199
- - spec/fixtures/code_with_utf8.textile
200
- - spec/fixtures/code_block_with_utf8.textile
201
- - spec/fixtures/yaml_front_matter.textile
202
- - spec/fixtures/recursion/level2/level2.markdown
203
- - spec/fixtures/recursion/level1.textile
204
- - spec/fixtures/code_block.textile
205
273
  - spec/gimli/path_spec.rb
206
274
  - spec/gimli/converter_spec.rb
207
275
  - spec/gimli/markup_spec.rb
208
276
  - spec/gimli/file_spec.rb
277
+ - spec/fixtures/code_with_utf8.textile
278
+ - spec/fixtures/recursion/level2/level2.markdown
279
+ - spec/fixtures/recursion/level1.textile
280
+ - spec/fixtures/code_block.textile
281
+ - spec/fixtures/yaml_front_matter.textile
282
+ - spec/fixtures/code_block_with_utf8.textile
283
+ - spec/spec_helper.rb
209
284
  - config/style.css
210
285
  - LICENSE
211
286
  - README.textile
@@ -224,7 +299,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
299
  version: '0'
225
300
  segments:
226
301
  - 0
227
- hash: 3487250391176844937
302
+ hash: -3032383899323034374
228
303
  required_rubygems_version: !ruby/object:Gem::Requirement
229
304
  none: false
230
305
  requirements:
@@ -233,11 +308,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
308
  version: '0'
234
309
  segments:
235
310
  - 0
236
- hash: 3487250391176844937
311
+ hash: -3032383899323034374
237
312
  requirements: []
238
313
  rubyforge_project: gimli
239
- rubygems_version: 1.8.6
314
+ rubygems_version: 1.8.24
240
315
  signing_key:
241
316
  specification_version: 3
242
317
  summary: Utility for converting markup files to pdf files.
243
318
  test_files: []
319
+ has_rdoc: