jekyll-asciidoc 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +27 -8
- data/Gemfile +13 -3
- data/LICENSE.adoc +1 -1
- data/README.adoc +409 -103
- data/jekyll-asciidoc.gemspec +6 -7
- data/lib/jekyll-asciidoc/compat.rb +4 -3
- data/lib/jekyll-asciidoc/converter.rb +50 -30
- data/lib/jekyll-asciidoc/filters.rb +21 -1
- data/lib/jekyll-asciidoc/integrator.rb +42 -34
- data/lib/jekyll-asciidoc/mixins.rb +6 -0
- data/lib/jekyll-asciidoc/version.rb +1 -1
- data/spec/fixtures/basic_site/docid.adoc +4 -0
- data/spec/fixtures/basic_site/section-with-id-and-role.adoc +6 -0
- data/spec/fixtures/imagesdir_relative_to_root/_config.yml +1 -1
- data/spec/fixtures/{include_relative_to_doc → include_relative_to_docdir}/_config.yml +0 -0
- data/spec/fixtures/{include_relative_to_doc → include_relative_to_docdir}/_layouts/default.html +0 -0
- data/spec/fixtures/{include_relative_to_doc → include_relative_to_docdir}/about/_people.adoc +0 -0
- data/spec/fixtures/{include_relative_to_doc → include_relative_to_docdir}/about/index.adoc +0 -0
- data/spec/fixtures/include_relative_to_root/source/_config.yml +2 -0
- data/spec/fixtures/include_relative_to_root/source/_layouts/default.html +11 -0
- data/spec/fixtures/include_relative_to_root/source/about/_people.adoc +2 -0
- data/spec/fixtures/include_relative_to_root/source/about/index.adoc +13 -0
- data/spec/fixtures/tocify_filter/_config.yml +2 -0
- data/spec/fixtures/tocify_filter/_layouts/default.html +15 -0
- data/spec/fixtures/tocify_filter/index.adoc +25 -0
- data/spec/fixtures/with_posts/_config.yml +4 -0
- data/spec/fixtures/with_posts/_layouts/post.html +8 -0
- data/spec/fixtures/with_posts/_posts/2016-02-02-post-with-singular-vars.adoc +7 -0
- data/spec/fixtures/with_posts/_posts/2016-06-15-post-with-date.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-07-15-post-with-date-and-tz.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-07-20-post-with-date-in-revision-line.adoc +6 -0
- data/spec/fixtures/xhtml_syntax/images/sunset.jpg +0 -0
- data/spec/jekyll-asciidoc_spec.rb +320 -127
- data/spec/spec_helper.rb +4 -0
- metadata +41 -15
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>{{ page.title }}</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div class="page-content">
|
9
|
+
{{ content }}
|
10
|
+
</div>
|
11
|
+
<aside class="page-toc">
|
12
|
+
{{ page.document | tocify_asciidoc: 2 }}
|
13
|
+
</aside>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
= Page Title
|
2
|
+
|
3
|
+
== Major Section A
|
4
|
+
|
5
|
+
content
|
6
|
+
|
7
|
+
=== Minor Section A.1
|
8
|
+
|
9
|
+
content
|
10
|
+
|
11
|
+
== Major Section B
|
12
|
+
|
13
|
+
content
|
14
|
+
|
15
|
+
=== Minor Section B.1
|
16
|
+
|
17
|
+
content
|
18
|
+
|
19
|
+
==== Micro Section B.1.1
|
20
|
+
|
21
|
+
content
|
22
|
+
|
23
|
+
== Major Section C
|
24
|
+
|
25
|
+
content
|
@@ -5,9 +5,17 @@
|
|
5
5
|
<title>{{ page.title }}</title>
|
6
6
|
</head>
|
7
7
|
<body>
|
8
|
+
<article class="post">
|
9
|
+
<header class="post-header">
|
10
|
+
<h1 class="post-title">{{ page.title }}</h1>
|
11
|
+
<p class="post-details">
|
12
|
+
<time class="date-published" datetime="{{ page.date | date_to_xmlschema }}">{{ page.date | date: "%B %d, %Y" }}</time>
|
13
|
+
</p>
|
14
|
+
</header>
|
8
15
|
<div class="post-content">
|
9
16
|
{{ content }}
|
10
17
|
</div>
|
18
|
+
</article>
|
11
19
|
<footer>
|
12
20
|
<p>Footer for post layout.</p>
|
13
21
|
</footer>
|
Binary file
|
@@ -22,6 +22,10 @@ describe 'Jekyll::AsciiDoc' do
|
|
22
22
|
'default_config'
|
23
23
|
end
|
24
24
|
|
25
|
+
before :each do
|
26
|
+
site.object_id
|
27
|
+
end
|
28
|
+
|
25
29
|
it 'should register AsciiDoc converter' do
|
26
30
|
expect(site.converters.any? {|c| ::Jekyll::AsciiDoc::Converter === c }).to be true
|
27
31
|
end
|
@@ -40,6 +44,15 @@ describe 'Jekyll::AsciiDoc' do
|
|
40
44
|
expect(converter.output_ext '.adoc').to eql('.html')
|
41
45
|
end
|
42
46
|
|
47
|
+
it 'should mark configuration as configured to prevent duplicate initialization' do
|
48
|
+
expect(asciidoc_config = site.config['asciidoc']).to be_a(::Jekyll::AsciiDoc::Configured)
|
49
|
+
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Jekyll::AsciiDoc::Configured)
|
50
|
+
site.reset
|
51
|
+
site.setup
|
52
|
+
expect(site.config['asciidoc'].object_id).to eql(asciidoc_config.object_id)
|
53
|
+
expect(site.config['asciidoctor'].object_id).to eql(asciidoctor_config.object_id)
|
54
|
+
end
|
55
|
+
|
43
56
|
it 'should use Asciidoctor to process AsciiDoc files by default' do
|
44
57
|
expect(site.config['asciidoc']).to be_a(::Hash)
|
45
58
|
expect(site.config['asciidoc']['processor']).to eql('asciidoctor')
|
@@ -93,6 +106,10 @@ describe 'Jekyll::AsciiDoc' do
|
|
93
106
|
'legacy_config'
|
94
107
|
end
|
95
108
|
|
109
|
+
before :each do
|
110
|
+
site.object_id
|
111
|
+
end
|
112
|
+
|
96
113
|
it 'should allow processor to be set using asciidoc key' do
|
97
114
|
expect(site.config['asciidoc']).to be_a(::Hash)
|
98
115
|
expect(site.config['asciidoc']['processor']).to eql('asciidoctor')
|
@@ -114,6 +131,10 @@ describe 'Jekyll::AsciiDoc' do
|
|
114
131
|
'hybrid_config'
|
115
132
|
end
|
116
133
|
|
134
|
+
before :each do
|
135
|
+
site.object_id
|
136
|
+
end
|
137
|
+
|
117
138
|
it 'should use new key for ext over legacy key' do
|
118
139
|
expect(site.config['asciidoc']).to be_a(::Hash)
|
119
140
|
expect(site.config['asciidoc']['ext']).to eql('asciidoc,adoc')
|
@@ -130,6 +151,10 @@ describe 'Jekyll::AsciiDoc' do
|
|
130
151
|
'default_config'
|
131
152
|
end
|
132
153
|
|
154
|
+
before :each do
|
155
|
+
site.object_id
|
156
|
+
end
|
157
|
+
|
133
158
|
it 'should parse string as YAML value' do
|
134
159
|
expect(integrator.send :parse_yaml_value, '').to eql('')
|
135
160
|
expect(integrator.send :parse_yaml_value, 'true').to be true
|
@@ -150,11 +175,15 @@ describe 'Jekyll::AsciiDoc' do
|
|
150
175
|
'imagesdir_relative_to_root'
|
151
176
|
end
|
152
177
|
|
178
|
+
before :each do
|
179
|
+
site.object_id
|
180
|
+
end
|
181
|
+
|
153
182
|
it 'should set imagesoutdir if imagesdir is relative to root' do
|
154
183
|
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
155
184
|
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
156
|
-
expect(attrs['imagesdir']).to eql('/images')
|
157
|
-
expect(attrs['imagesoutdir']).to eql(::File.join
|
185
|
+
expect(attrs['imagesdir']).to eql('/images@')
|
186
|
+
expect(attrs['imagesoutdir']).to eql(::File.join site.dest, (attrs['imagesdir'].chomp '@'))
|
158
187
|
end
|
159
188
|
end
|
160
189
|
|
@@ -163,6 +192,10 @@ describe 'Jekyll::AsciiDoc' do
|
|
163
192
|
'default_config'
|
164
193
|
end
|
165
194
|
|
195
|
+
before :each do
|
196
|
+
site.object_id
|
197
|
+
end
|
198
|
+
|
166
199
|
it 'should not set imagesoutdir if imagesdir is not set' do
|
167
200
|
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
168
201
|
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
@@ -176,43 +209,91 @@ describe 'Jekyll::AsciiDoc' do
|
|
176
209
|
'default_config'
|
177
210
|
end
|
178
211
|
|
212
|
+
before :each do
|
213
|
+
site.object_id
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'should assign nil value to attribute for attribute with nil value' do
|
217
|
+
result = converter.send :assemble_attributes, { 'icons' => nil }
|
218
|
+
expect(result.key? 'icons').to be true
|
219
|
+
expect(result['icons']).to be_nil
|
220
|
+
end
|
221
|
+
|
179
222
|
it 'should transform negated attribute with trailing ! to attribute with nil value' do
|
180
|
-
result = converter.send :
|
223
|
+
result = converter.send :assemble_attributes, { 'icons!' => '' }
|
181
224
|
expect(result.key? 'icons').to be true
|
182
225
|
expect(result['icons']).to be_nil
|
183
226
|
end
|
184
227
|
|
185
228
|
it 'should transform negated attribute with leading ! to attribute with nil value' do
|
186
|
-
result = converter.send :
|
229
|
+
result = converter.send :assemble_attributes, { '!icons' => '' }
|
187
230
|
expect(result.key? 'icons').to be true
|
188
231
|
expect(result['icons']).to be_nil
|
189
232
|
end
|
190
233
|
|
191
|
-
it 'should
|
192
|
-
result = converter.send :
|
234
|
+
it 'should set existing attribute to nil when attribute is unset' do
|
235
|
+
result = converter.send :assemble_attributes, { 'icons' => 'font', '!icons' => '' }
|
193
236
|
expect(result.key? 'icons').to be true
|
194
237
|
expect(result['icons']).to be_nil
|
195
238
|
end
|
196
239
|
|
197
|
-
it 'should assign
|
198
|
-
result = converter.send :
|
240
|
+
it 'should assign value to existing attribute when set again' do
|
241
|
+
result = converter.send :assemble_attributes, ['!icons', 'icons=font', '!source-highlighter', 'source-highlighter=coderay']
|
199
242
|
expect(result['icons']).to eql('font')
|
243
|
+
expect(result['source-highlighter']).to eql('coderay')
|
200
244
|
end
|
201
245
|
|
202
246
|
it 'should resolve attribute references in attribute value' do
|
203
|
-
result = converter.send :
|
247
|
+
result = converter.send :assemble_attributes, { 'foo' => 'foo', 'bar' => 'bar', 'baz' => nil, 'foobar' => '{foo}{bar}{baz}' }
|
248
|
+
expect(result['foobar']).to eql('foobar')
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'should drop trailing @ from value when resolving attribute reference' do
|
252
|
+
result = converter.send :assemble_attributes, { 'foo' => 'foo@', 'bar' => 'bar@', 'baz' => '@', 'foobar' => '{foo}{bar}{baz}' }
|
204
253
|
expect(result['foobar']).to eql('foobar')
|
205
254
|
end
|
206
255
|
|
207
256
|
it 'should not resolve escaped attribute reference' do
|
208
|
-
result = converter.send :
|
257
|
+
result = converter.send :assemble_attributes, { 'foo' => 'foo', 'bar' => 'bar', 'foobar' => '{foo}\{bar}' }
|
209
258
|
expect(result['foobar']).to eql('foo{bar}')
|
210
259
|
end
|
211
260
|
|
212
261
|
it 'should leave unresolved attribute reference in place' do
|
213
|
-
result = converter.send :
|
262
|
+
result = converter.send :assemble_attributes, { 'foo' => 'foo', 'foobar' => '{foo}{bar}' }
|
214
263
|
expect(result['foobar']).to eql('foo{bar}')
|
215
264
|
end
|
265
|
+
|
266
|
+
it 'should remove matching attribute if attribute starts with minus' do
|
267
|
+
result = converter.send :assemble_attributes, { '-idseparator' => '' }, { 'idseparator' => '-' }
|
268
|
+
expect(result).to be_empty
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'should not fail if attribute to be removed does not exist' do
|
272
|
+
result = converter.send :assemble_attributes, { '-idseparator' => '' }
|
273
|
+
expect(result).to be_empty
|
274
|
+
end
|
275
|
+
|
276
|
+
it 'should assign empty string to attribute if value is true' do
|
277
|
+
result = converter.send :assemble_attributes, { 'icons' => true }
|
278
|
+
expect(result['icons']).to eql('')
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'should assign nil value to attribute if value is false' do
|
282
|
+
result = converter.send :assemble_attributes, { 'icons' => false }
|
283
|
+
expect(result.key? 'icons').to be true
|
284
|
+
expect(result['icons']).to be_nil
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'should assign numeric value as string if value is numeric' do
|
288
|
+
result = converter.send :assemble_attributes, { 'count' => 1 }
|
289
|
+
expect(result['count']).to eql('1')
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'should pass through Date value to attribute if value is Date' do
|
293
|
+
date = ::Date.parse('2016-01-01')
|
294
|
+
result = converter.send :assemble_attributes, { 'localdate' => date }
|
295
|
+
expect(result['localdate']).to eql(date)
|
296
|
+
end
|
216
297
|
end
|
217
298
|
|
218
299
|
describe 'attributes as hash' do
|
@@ -220,6 +301,10 @@ describe 'Jekyll::AsciiDoc' do
|
|
220
301
|
'attributes_as_hash'
|
221
302
|
end
|
222
303
|
|
304
|
+
before :each do
|
305
|
+
site.object_id
|
306
|
+
end
|
307
|
+
|
223
308
|
it 'should merge attributes defined as a Hash into the attributes Hash' do
|
224
309
|
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
225
310
|
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
@@ -236,6 +321,10 @@ describe 'Jekyll::AsciiDoc' do
|
|
236
321
|
'attributes_as_array'
|
237
322
|
end
|
238
323
|
|
324
|
+
before :each do
|
325
|
+
site.object_id
|
326
|
+
end
|
327
|
+
|
239
328
|
it 'should merge attributes defined as an Array into the attributes Hash' do
|
240
329
|
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
241
330
|
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
@@ -252,9 +341,7 @@ describe 'Jekyll::AsciiDoc' do
|
|
252
341
|
'alternate_page_attribute_prefix'
|
253
342
|
end
|
254
343
|
|
255
|
-
before
|
256
|
-
site.process
|
257
|
-
end
|
344
|
+
before(:each) { site.process }
|
258
345
|
|
259
346
|
it 'should strip trailing hyphen from page attribute prefix value' do
|
260
347
|
expect(site.config['asciidoc']).to be_a(::Hash)
|
@@ -268,8 +355,8 @@ describe 'Jekyll::AsciiDoc' do
|
|
268
355
|
file = output_file 'permalink/index.html'
|
269
356
|
expect(::File).to exist(file)
|
270
357
|
contents = ::File.read file
|
271
|
-
expect(contents).to
|
272
|
-
expect(contents).not_to
|
358
|
+
expect(contents).to include('<div class="page-content">')
|
359
|
+
expect(contents).not_to include(%(<meta name="generator" content="Asciidoctor #{::Asciidoctor::VERSION}">))
|
273
360
|
end
|
274
361
|
end
|
275
362
|
|
@@ -278,9 +365,7 @@ describe 'Jekyll::AsciiDoc' do
|
|
278
365
|
'blank_page_attribute_prefix'
|
279
366
|
end
|
280
367
|
|
281
|
-
before
|
282
|
-
site.process
|
283
|
-
end
|
368
|
+
before(:each) { site.process }
|
284
369
|
|
285
370
|
it 'should coerce null value for page attribute prefix to empty string' do
|
286
371
|
expect(site.config['asciidoc']).to be_a(::Hash)
|
@@ -294,8 +379,8 @@ describe 'Jekyll::AsciiDoc' do
|
|
294
379
|
file = output_file 'permalink/index.html'
|
295
380
|
expect(::File).to exist(file)
|
296
381
|
contents = ::File.read file
|
297
|
-
expect(contents).to
|
298
|
-
expect(contents).not_to
|
382
|
+
expect(contents).to include('<div class="page-content">')
|
383
|
+
expect(contents).not_to include(%(<meta name="generator" content="Asciidoctor #{::Asciidoctor::VERSION}">))
|
299
384
|
end
|
300
385
|
end
|
301
386
|
|
@@ -304,9 +389,7 @@ describe 'Jekyll::AsciiDoc' do
|
|
304
389
|
'basic_site'
|
305
390
|
end
|
306
391
|
|
307
|
-
before
|
308
|
-
site.process
|
309
|
-
end
|
392
|
+
before(:each) { site.process }
|
310
393
|
|
311
394
|
it 'should consider a plain AsciiDoc file to have a YAML header' do
|
312
395
|
file = source_file 'without-front-matter-header.adoc'
|
@@ -317,14 +400,14 @@ describe 'Jekyll::AsciiDoc' do
|
|
317
400
|
file = output_file 'without-front-matter-header.html'
|
318
401
|
expect(::File).to exist(file)
|
319
402
|
contents = ::File.read file
|
320
|
-
expect(contents).to
|
403
|
+
expect(contents).to include('<p>Lorem ipsum.</p>')
|
321
404
|
end
|
322
405
|
|
323
406
|
it 'should promote AsciiDoc document title to page title' do
|
324
407
|
file = output_file 'without-front-matter-header.html'
|
325
408
|
expect(::File).to exist(file)
|
326
409
|
contents = ::File.read file
|
327
|
-
expect(contents).to
|
410
|
+
expect(contents).to include('<title>Page Title</title>')
|
328
411
|
end
|
329
412
|
|
330
413
|
it 'should convert an AsciiDoc with no doctitle or AsciiDoc header' do
|
@@ -334,8 +417,8 @@ describe 'Jekyll::AsciiDoc' do
|
|
334
417
|
file = output_file 'no-doctitle.html'
|
335
418
|
expect(::File).to exist(file)
|
336
419
|
contents = ::File.read file
|
337
|
-
expect(contents).to
|
338
|
-
expect(contents).to
|
420
|
+
expect(contents).to include('<title>Site Title</title>')
|
421
|
+
expect(contents).to include(%(<p>Just content.\nLorem ipsum.</p>))
|
339
422
|
end
|
340
423
|
|
341
424
|
it 'should convert an AsciiDoc with bare AsciiDoc header' do
|
@@ -346,8 +429,8 @@ describe 'Jekyll::AsciiDoc' do
|
|
346
429
|
file = output_file 'bare/index.html'
|
347
430
|
expect(::File).to exist(file)
|
348
431
|
contents = ::File.read file
|
349
|
-
expect(contents).to
|
350
|
-
expect(contents).to
|
432
|
+
expect(contents).to include('<title>Site Title</title>')
|
433
|
+
expect(contents).to include(%(<p>Just content.\nLorem ipsum.</p>))
|
351
434
|
end
|
352
435
|
|
353
436
|
it 'should consider an AsciiDoc file with a front matter header to have a YAML header' do
|
@@ -359,22 +442,36 @@ describe 'Jekyll::AsciiDoc' do
|
|
359
442
|
file = output_file 'with-front-matter-header.html'
|
360
443
|
expect(::File).to exist(file)
|
361
444
|
contents = ::File.read file
|
362
|
-
expect(contents).to
|
363
|
-
expect(contents).to
|
445
|
+
expect(contents).to include('<title>Page Title</title>')
|
446
|
+
expect(contents).to include('<p>Lorem ipsum.</p>')
|
447
|
+
end
|
448
|
+
|
449
|
+
it 'should apply explicit id and role attributes on section titles' do
|
450
|
+
file = output_file 'section-with-id-and-role.html'
|
451
|
+
expect(::File).to exist(file)
|
452
|
+
contents = ::File.read file
|
453
|
+
expect(contents).to include(%(<div class="sect1 section-role">\n<h2 id="section-id">Section Title</h2>))
|
454
|
+
end
|
455
|
+
|
456
|
+
it 'should assign AsciiDoc document id, if set, to docid page attribute' do
|
457
|
+
page = find_page 'docid.adoc'
|
458
|
+
expect(page).not_to be_nil
|
459
|
+
expect(page.data.key? 'docid').to be true
|
460
|
+
expect(page.data['docid']).to eq('page-id')
|
364
461
|
end
|
365
462
|
|
366
463
|
it 'should not use Liquid preprocessor by default' do
|
367
464
|
file = output_file 'no-liquid.html'
|
368
465
|
expect(::File).to exist(file)
|
369
466
|
contents = ::File.read file
|
370
|
-
expect(contents).to
|
467
|
+
expect(contents).to include('<p>{{ page.title }}</p>')
|
371
468
|
end
|
372
469
|
|
373
470
|
it 'should enable Liquid preprocessor if liquid page variable is set' do
|
374
471
|
file = output_file 'liquid-enabled.html'
|
375
472
|
expect(::File).to exist(file)
|
376
473
|
contents = ::File.read file
|
377
|
-
expect(contents).to
|
474
|
+
expect(contents).to include('<p>Liquid Enabled</p>')
|
378
475
|
end
|
379
476
|
|
380
477
|
it 'should not publish a page if the published page variable is set in the AsciiDoc header' do
|
@@ -386,55 +483,53 @@ describe 'Jekyll::AsciiDoc' do
|
|
386
483
|
file = output_file 'standalone-a.html'
|
387
484
|
expect(::File).to exist(file)
|
388
485
|
contents = ::File.read file
|
389
|
-
expect(contents).to
|
390
|
-
expect(contents).to
|
391
|
-
expect(contents).to
|
486
|
+
expect(contents).to include(%(<meta name="generator" content="Asciidoctor #{::Asciidoctor::VERSION}">))
|
487
|
+
expect(contents).to include('<title>Standalone Page A</title>')
|
488
|
+
expect(contents).to include('<h1>Standalone Page A</h1>')
|
392
489
|
end
|
393
490
|
|
394
491
|
it 'should output a standalone HTML page if the page-layout attribute is false' do
|
395
492
|
file = output_file 'standalone-b.html'
|
396
493
|
expect(::File).to exist(file)
|
397
494
|
contents = ::File.read file
|
398
|
-
expect(contents).to
|
399
|
-
expect(contents).to
|
400
|
-
expect(contents).to
|
495
|
+
expect(contents).to include(%(<meta name="generator" content="Asciidoctor #{::Asciidoctor::VERSION}">))
|
496
|
+
expect(contents).to include('<title>Standalone Page B</title>')
|
497
|
+
expect(contents).to include('<h1>Standalone Page B</h1>')
|
401
498
|
end
|
402
499
|
|
403
500
|
it 'should apply layout named page to page content if page-layout attribute not specified' do
|
404
501
|
file = output_file 'without-front-matter-header.html'
|
405
502
|
expect(::File).to exist(file)
|
406
503
|
contents = ::File.read file
|
407
|
-
expect(contents).to
|
504
|
+
expect(contents).to include('<p>Footer for page layout.</p>')
|
408
505
|
end
|
409
506
|
|
410
507
|
it 'should apply layout named page to page content if page-layout attribute is empty' do
|
411
508
|
file = output_file 'empty-layout.html'
|
412
509
|
expect(::File).to exist(file)
|
413
510
|
contents = ::File.read file
|
414
|
-
expect(contents).to
|
511
|
+
expect(contents).to include('<p>Footer for page layout.</p>')
|
415
512
|
end
|
416
513
|
|
417
514
|
it 'should apply layout named page to page content if page-layout attribute has value _auto' do
|
418
515
|
file = output_file 'auto-layout.html'
|
419
516
|
expect(::File).to exist(file)
|
420
517
|
contents = ::File.read file
|
421
|
-
expect(contents).to
|
518
|
+
expect(contents).to include('<p>Footer for page layout.</p>')
|
422
519
|
end
|
423
520
|
|
424
521
|
it 'should apply specified layout to page content if page-layout has non-empty string value' do
|
425
522
|
file = output_file 'custom-layout.html'
|
426
523
|
expect(::File).to exist(file)
|
427
524
|
contents = ::File.read file
|
428
|
-
expect(contents).to
|
525
|
+
expect(contents).to include('<p>Footer for custom layout.</p>')
|
429
526
|
end
|
430
527
|
|
431
528
|
it 'should not apply a layout to page content if page-layout attribute is nil' do
|
432
529
|
file = output_file 'nil-layout.html'
|
433
530
|
expect(::File).to exist(file)
|
434
531
|
contents = ::File.read file
|
435
|
-
expect(contents).to
|
436
|
-
<p>Lorem ipsum.</p>
|
437
|
-
</div>')
|
532
|
+
expect(contents).to include(%(div class="paragraph">\n<p>Lorem ipsum.</p>\n</div>))
|
438
533
|
end
|
439
534
|
|
440
535
|
it 'should convert an empty page attribute value to empty string' do
|
@@ -448,10 +543,10 @@ describe 'Jekyll::AsciiDoc' do
|
|
448
543
|
out_file = output_file 'subdir/page-in-subdir.html'
|
449
544
|
expect(::File).to exist(out_file)
|
450
545
|
contents = ::File.read out_file
|
451
|
-
expect(contents).to
|
546
|
+
expect(contents).to include(%(docdir=#{::Dir.pwd}))
|
452
547
|
if ::Jekyll::MIN_VERSION_3
|
453
|
-
expect(contents).to
|
454
|
-
expect(contents).to
|
548
|
+
expect(contents).to include(%(docfile=#{src_file}))
|
549
|
+
expect(contents).to include(%(docname=#{::File.basename src_file, '.adoc'}))
|
455
550
|
end
|
456
551
|
end
|
457
552
|
|
@@ -474,11 +569,9 @@ describe 'Jekyll::AsciiDoc' do
|
|
474
569
|
'explicit_site_time'
|
475
570
|
end
|
476
571
|
|
477
|
-
before
|
478
|
-
site.process
|
479
|
-
end
|
572
|
+
before(:each) { site.process }
|
480
573
|
|
481
|
-
it 'should set localdatetime on AsciiDoc pages to match site time and
|
574
|
+
it 'should set localdatetime on AsciiDoc pages to match site time and time zone' do
|
482
575
|
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
483
576
|
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
484
577
|
expect(attrs['localdate']).to eql(site.time.strftime '%Y-%m-%d')
|
@@ -486,7 +579,7 @@ describe 'Jekyll::AsciiDoc' do
|
|
486
579
|
file = output_file 'home.html'
|
487
580
|
expect(::File).to exist(file)
|
488
581
|
contents = ::File.read file
|
489
|
-
expect(contents).to
|
582
|
+
expect(contents).to include(%(localdatetime=#{site.time.strftime '%Y-%m-%d %H:%M:%S %Z'}))
|
490
583
|
end
|
491
584
|
end
|
492
585
|
|
@@ -495,9 +588,7 @@ describe 'Jekyll::AsciiDoc' do
|
|
495
588
|
'safe_mode'
|
496
589
|
end
|
497
590
|
|
498
|
-
before
|
499
|
-
site.process
|
500
|
-
end
|
591
|
+
before(:each) { site.process }
|
501
592
|
|
502
593
|
it 'should register converter and generator when running in safe mode' do
|
503
594
|
expect(site.converters.any? {|c| ::Jekyll::AsciiDoc::Converter === c }).to be true
|
@@ -508,8 +599,8 @@ describe 'Jekyll::AsciiDoc' do
|
|
508
599
|
file = output_file 'home.html'
|
509
600
|
expect(::File).to exist(file)
|
510
601
|
contents = ::File.read file
|
511
|
-
expect(contents).to
|
512
|
-
expect(contents).to
|
602
|
+
expect(contents).to include('<title>Home Page</title>')
|
603
|
+
expect(contents).to include('<p>Footer for home layout.</p>')
|
513
604
|
end
|
514
605
|
end
|
515
606
|
|
@@ -518,29 +609,27 @@ describe 'Jekyll::AsciiDoc' do
|
|
518
609
|
'fallback_to_default_layout'
|
519
610
|
end
|
520
611
|
|
521
|
-
before
|
522
|
-
site.process
|
523
|
-
end
|
612
|
+
before(:each) { site.process }
|
524
613
|
|
525
614
|
it 'should use default layout for page if page layout is not available' do
|
526
615
|
file = output_file 'home.html'
|
527
616
|
expect(::File).to exist(file)
|
528
617
|
contents = ::File.read file
|
529
|
-
expect(contents).to
|
618
|
+
expect(contents).to include('<p>Footer for default layout.</p>')
|
530
619
|
end
|
531
620
|
|
532
621
|
it 'should use default layout for post if post layout is not available' do
|
533
622
|
file = output_file '2016/01/01/post.html'
|
534
623
|
expect(::File).to exist(file)
|
535
624
|
contents = ::File.read file
|
536
|
-
expect(contents).to
|
625
|
+
expect(contents).to include('<p>Footer for default layout.</p>')
|
537
626
|
end
|
538
627
|
|
539
628
|
it 'should use default layout for document if layout for document collection is not available' do
|
540
629
|
file = output_file 'blueprints/blueprint.html'
|
541
630
|
expect(::File).to exist(file)
|
542
631
|
contents = ::File.read file
|
543
|
-
expect(contents).to
|
632
|
+
expect(contents).to include('<p>Footer for default layout.</p>')
|
544
633
|
end
|
545
634
|
end
|
546
635
|
|
@@ -549,9 +638,7 @@ describe 'Jekyll::AsciiDoc' do
|
|
549
638
|
'require_front_matter_header'
|
550
639
|
end
|
551
640
|
|
552
|
-
before
|
553
|
-
site.process
|
554
|
-
end
|
641
|
+
before(:each) { site.process }
|
555
642
|
|
556
643
|
it 'should consider an AsciiDoc file with a front matter header to have a YAML header' do
|
557
644
|
file = source_file 'with-front-matter-header.adoc'
|
@@ -567,8 +654,8 @@ describe 'Jekyll::AsciiDoc' do
|
|
567
654
|
file = output_file 'with-front-matter-header.html'
|
568
655
|
expect(::File).to exist(file)
|
569
656
|
contents = ::File.read file
|
570
|
-
expect(contents).to
|
571
|
-
expect(contents).to
|
657
|
+
expect(contents).to include('<title>Page Title</title>')
|
658
|
+
expect(contents).to include('<p>Lorem ipsum.</p>')
|
572
659
|
end
|
573
660
|
|
574
661
|
it 'should not convert an AsciiDoc file without a front matter header' do
|
@@ -594,8 +681,8 @@ describe 'Jekyll::AsciiDoc' do
|
|
594
681
|
file = output_file '2016/01/01/welcome.html'
|
595
682
|
expect(::File).to exist(file)
|
596
683
|
contents = ::File.read file
|
597
|
-
expect(contents).to
|
598
|
-
expect(contents).not_to
|
684
|
+
expect(contents).to include('<title>Welcome, Visitor!</title>')
|
685
|
+
expect(contents).not_to include('<h1>Welcome, Visitor!</h1>')
|
599
686
|
end
|
600
687
|
|
601
688
|
it 'should use automatic title if no document title is given' do
|
@@ -609,7 +696,7 @@ describe 'Jekyll::AsciiDoc' do
|
|
609
696
|
file = output_file '2016/05/31/automatic-title.html'
|
610
697
|
expect(::File).to exist(file)
|
611
698
|
contents = ::File.read file
|
612
|
-
expect(contents).to
|
699
|
+
expect(contents).to include('<title>Automatic Title</title>')
|
613
700
|
end
|
614
701
|
|
615
702
|
it 'should set author of post to value defined in AsciiDoc header' do
|
@@ -622,45 +709,44 @@ describe 'Jekyll::AsciiDoc' do
|
|
622
709
|
file = output_file '2016/01/01/welcome.html'
|
623
710
|
expect(::File).to exist(file)
|
624
711
|
contents = ::File.read file
|
625
|
-
expect(contents).to
|
712
|
+
expect(contents).to include('<p>Footer for post layout.</p>')
|
626
713
|
end
|
627
714
|
|
628
715
|
it 'should apply layout named post to post content if page-layout attribute is empty' do
|
629
716
|
file = output_file '2016/01/02/empty-layout.html'
|
630
717
|
expect(::File).to exist(file)
|
631
718
|
contents = ::File.read file
|
632
|
-
expect(contents).to
|
719
|
+
expect(contents).to include('<p>Footer for post layout.</p>')
|
633
720
|
end
|
634
721
|
|
635
722
|
it 'should apply layout named post to post content if page-layout attribute has value _auto' do
|
636
723
|
file = output_file '2016/01/03/auto-layout.html'
|
637
724
|
expect(::File).to exist(file)
|
638
725
|
contents = ::File.read file
|
639
|
-
expect(contents).to
|
726
|
+
expect(contents).to include('<p>Footer for post layout.</p>')
|
640
727
|
end
|
641
728
|
|
642
729
|
it 'should apply custom layout to post content if page-layout attribute has non-empty string value' do
|
643
730
|
file = output_file '2016/01/04/custom-layout.html'
|
644
731
|
expect(::File).to exist(file)
|
645
732
|
contents = ::File.read file
|
646
|
-
expect(contents).to
|
733
|
+
expect(contents).to include('<p>Footer for custom layout.</p>')
|
647
734
|
end
|
648
735
|
|
649
736
|
it 'should not apply a layout to post content if page-layout attribute is nil' do
|
650
737
|
file = output_file '2016/01/05/nil-layout.html'
|
651
738
|
expect(::File).to exist(file)
|
652
739
|
contents = ::File.read file
|
653
|
-
expect(contents).to
|
654
|
-
<p>Lorem ipsum.</p>
|
655
|
-
</div>')
|
740
|
+
expect(contents).to include(%(div class="paragraph">\n<p>Lorem ipsum.</p>\n</div>))
|
656
741
|
end
|
657
742
|
|
658
743
|
it 'should show the title above the content if the showtitle attribute is set' do
|
659
744
|
file = output_file '2016/04/01/show-me-the-title.html'
|
660
745
|
expect(::File).to exist(file)
|
661
746
|
contents = ::File.read file
|
662
|
-
expect(contents).to
|
663
|
-
expect(contents).to
|
747
|
+
expect(contents).to include('<title>Show Me the Title</title>')
|
748
|
+
expect(contents).to include('<h1 class="post-title">Show Me the Title</h1>')
|
749
|
+
expect(contents).to include('<h1>Show Me the Title</h1>')
|
664
750
|
end
|
665
751
|
|
666
752
|
it 'should interpret value of page attribute as YAML data' do
|
@@ -673,6 +759,60 @@ describe 'Jekyll::AsciiDoc' do
|
|
673
759
|
end
|
674
760
|
end
|
675
761
|
|
762
|
+
it 'should merge singular variables with collection variables' do
|
763
|
+
post = find_post '2016-02-02-post-with-singular-vars.adoc'
|
764
|
+
expect(post).not_to be_nil
|
765
|
+
expect(post.data['categories']).to eql(['code', 'javascript', 'node'])
|
766
|
+
expect(post.data['tags']).to eql(['syntax', 'beginner', 'tip'])
|
767
|
+
if ::Jekyll::MIN_VERSION_3
|
768
|
+
file = output_file 'code/javascript/node/2016/02/02/post-with-singular-vars.html'
|
769
|
+
expect(::File).to exist(file)
|
770
|
+
end
|
771
|
+
end
|
772
|
+
|
773
|
+
it 'should convert revdate to local Time object and use it as date of post' do
|
774
|
+
# NOTE Time.parse without time zone assumes time zone of site
|
775
|
+
date = ::Time.parse('2016-06-15 10:30:00')
|
776
|
+
date = date.localtime if ::Jekyll::MIN_VERSION_3
|
777
|
+
slug = 'post-with-date'
|
778
|
+
post = find_post %(#{date.strftime '%Y-%m-%d'}-#{slug}.adoc)
|
779
|
+
expect(post).not_to be_nil
|
780
|
+
expect(post.data['date']).to be_a(::Time)
|
781
|
+
expect(post.data['date'].to_s).to eql(date.to_s)
|
782
|
+
file = output_file %(#{date.strftime '%Y/%m/%d'}/#{slug}.html)
|
783
|
+
expect(::File).to exist(file)
|
784
|
+
contents = ::File.read file
|
785
|
+
expect(contents).to include(%(<time class="date-published" datetime="#{date.xmlschema}">#{date.strftime '%B %d, %Y'}</time>))
|
786
|
+
end
|
787
|
+
|
788
|
+
it 'should convert revdate with time zone to local Time object and use it as date of post' do
|
789
|
+
date = ::Time.parse('2016-07-15 04:15:30 -0600')
|
790
|
+
date = date.localtime if ::Jekyll::MIN_VERSION_3
|
791
|
+
slug = 'post-with-date-and-tz'
|
792
|
+
post = find_post %(#{date.strftime '%Y-%m-%d'}-#{slug}.adoc)
|
793
|
+
expect(post).not_to be_nil
|
794
|
+
expect(post.data['date']).to be_a(::Time)
|
795
|
+
expect(post.data['date'].to_s).to eql(date.to_s)
|
796
|
+
file = output_file %(#{date.strftime '%Y/%m/%d'}/#{slug}.html)
|
797
|
+
expect(::File).to exist(file)
|
798
|
+
contents = ::File.read file
|
799
|
+
expect(contents).to include(%(<time class="date-published" datetime="#{date.xmlschema}">#{date.strftime '%B %d, %Y'}</time>))
|
800
|
+
end
|
801
|
+
|
802
|
+
it 'should convert revdate in revision line to local Time object and use it as date of post' do
|
803
|
+
date = ::Time.parse('2016-07-20 05:45:25 -0600')
|
804
|
+
date = date.localtime if ::Jekyll::MIN_VERSION_3
|
805
|
+
slug = 'post-with-date-in-revision-line'
|
806
|
+
post = find_post %(#{date.strftime '%Y-%m-%d'}-#{slug}.adoc)
|
807
|
+
expect(post).not_to be_nil
|
808
|
+
expect(post.data['date']).to be_a(::Time)
|
809
|
+
expect(post.data['date'].to_s).to eql(date.to_s)
|
810
|
+
file = output_file %(#{date.strftime '%Y/%m/%d'}/#{slug}.html)
|
811
|
+
expect(::File).to exist(file)
|
812
|
+
contents = ::File.read file
|
813
|
+
expect(contents).to include(%(<time class="date-published" datetime="#{date.xmlschema}">#{date.strftime '%B %d, %Y'}</time>))
|
814
|
+
end
|
815
|
+
|
676
816
|
it 'should process AsciiDoc header of draft post' do
|
677
817
|
draft = find_draft 'a-draft-post.adoc'
|
678
818
|
expect(draft).not_to be_nil
|
@@ -682,11 +822,11 @@ describe 'Jekyll::AsciiDoc' do
|
|
682
822
|
expect(::File).to exist(file)
|
683
823
|
end
|
684
824
|
|
685
|
-
it 'should apply asciidocify filter' do
|
825
|
+
it 'should apply asciidocify filter to excerpt' do
|
686
826
|
file = output_file 'index.html'
|
687
827
|
expect(::File).to exist(file)
|
688
828
|
contents = ::File.read file
|
689
|
-
expect(contents).to
|
829
|
+
expect(contents).to include('<p class="excerpt">This is the <em>excerpt</em> of this post.</p>')
|
690
830
|
end
|
691
831
|
end
|
692
832
|
|
@@ -710,52 +850,95 @@ describe 'Jekyll::AsciiDoc' do
|
|
710
850
|
contents = ::File.read file
|
711
851
|
expect(contents).to be_empty
|
712
852
|
end
|
713
|
-
end
|
853
|
+
end unless windows?
|
714
854
|
|
715
|
-
describe 'site with include relative to
|
855
|
+
describe 'site with include relative to docdir' do
|
716
856
|
let :name do
|
717
|
-
'
|
857
|
+
'include_relative_to_docdir'
|
718
858
|
end
|
719
859
|
|
720
|
-
before
|
721
|
-
|
860
|
+
before(:each) { site.process }
|
861
|
+
|
862
|
+
it 'should not expand base_dir when base_dir config key has value :docdir' do
|
863
|
+
expect(site.config['asciidoctor'][:base_dir]).to eql(:docdir)
|
722
864
|
end
|
723
865
|
|
724
|
-
it 'should resolve
|
866
|
+
it 'should resolve include relative to docdir when base_dir config key has value :docdir' do
|
725
867
|
src_file = source_file 'about/index.adoc'
|
726
868
|
out_file = output_file 'about/index.html'
|
727
869
|
expect(::File).to exist(out_file)
|
728
870
|
contents = ::File.read out_file
|
729
|
-
expect(contents).to
|
730
|
-
expect(contents).to
|
731
|
-
expect(contents).to
|
732
|
-
expect(contents).to
|
733
|
-
expect(contents).to
|
734
|
-
expect(contents).to
|
871
|
+
expect(contents).to include('Doc Writer')
|
872
|
+
expect(contents).to include(%(docfile=#{src_file}))
|
873
|
+
expect(contents).to include(%(docdir=#{::File.dirname src_file}))
|
874
|
+
expect(contents).to include(%(outfile=#{out_file}))
|
875
|
+
expect(contents).to include(%(outdir=#{::File.dirname out_file}))
|
876
|
+
expect(contents).to include(%(outpath=/about/))
|
735
877
|
end
|
736
878
|
end if ::Jekyll::MIN_VERSION_3
|
737
879
|
|
880
|
+
describe 'site with include relative to root' do
|
881
|
+
let :name do
|
882
|
+
'include_relative_to_root'
|
883
|
+
end
|
884
|
+
|
885
|
+
let :config do
|
886
|
+
::Jekyll.configuration((fixture_site_params name).merge('source' => (::File.join (source_dir name), 'source')))
|
887
|
+
end
|
888
|
+
|
889
|
+
before(:each) {
|
890
|
+
@old_pwd = ::Dir.pwd
|
891
|
+
::Dir.chdir(source_dir name)
|
892
|
+
site.process
|
893
|
+
}
|
894
|
+
|
895
|
+
after(:each) {
|
896
|
+
::Dir.chdir(@old_pwd)
|
897
|
+
}
|
898
|
+
|
899
|
+
it 'should not set base_dir if base_dir config key has no value' do
|
900
|
+
expect(site.config['asciidoctor'].key? :base_dir).to be false
|
901
|
+
end
|
902
|
+
|
903
|
+
it 'should resolve include relative to root when base_dir is not set' do
|
904
|
+
src_file = source_file 'about/index.adoc'
|
905
|
+
out_file = output_file 'about/index.html'
|
906
|
+
expect(::File).to exist(out_file)
|
907
|
+
contents = ::File.read out_file
|
908
|
+
expect(contents).to include('Doc Writer')
|
909
|
+
expect(contents).to include(%(docdir=#{::Dir.pwd}))
|
910
|
+
if ::Jekyll::MIN_VERSION_3
|
911
|
+
expect(contents).to include(%(docfile=#{src_file}))
|
912
|
+
expect(contents).to include(%(outfile=#{out_file}))
|
913
|
+
expect(contents).to include(%(outdir=#{::File.dirname out_file}))
|
914
|
+
expect(contents).to include(%(outpath=/about/))
|
915
|
+
end
|
916
|
+
end
|
917
|
+
end
|
918
|
+
|
738
919
|
describe 'site with include relative to source' do
|
739
920
|
let :name do
|
740
921
|
'include_relative_to_source'
|
741
922
|
end
|
742
923
|
|
743
|
-
before
|
744
|
-
|
924
|
+
before(:each) { site.process }
|
925
|
+
|
926
|
+
it 'should expand base_dir to match site source when base_dir config key has value :source' do
|
927
|
+
expect(site.config['asciidoctor'][:base_dir]).to eql(site.source)
|
745
928
|
end
|
746
929
|
|
747
|
-
it 'should resolve
|
930
|
+
it 'should resolve include relative to source when base_dir config key has value :source' do
|
748
931
|
src_file = source_file 'about/index.adoc'
|
749
932
|
out_file = output_file 'about/index.html'
|
750
933
|
expect(::File).to exist(out_file)
|
751
934
|
contents = ::File.read out_file
|
752
|
-
expect(contents).to
|
753
|
-
expect(contents).to
|
935
|
+
expect(contents).to include('Doc Writer')
|
936
|
+
expect(contents).to include(%(docdir=#{site.source}))
|
754
937
|
if ::Jekyll::MIN_VERSION_3
|
755
|
-
expect(contents).to
|
756
|
-
expect(contents).to
|
757
|
-
expect(contents).to
|
758
|
-
expect(contents).to
|
938
|
+
expect(contents).to include(%(docfile=#{src_file}))
|
939
|
+
expect(contents).to include(%(outfile=#{out_file}))
|
940
|
+
expect(contents).to include(%(outdir=#{::File.dirname out_file}))
|
941
|
+
expect(contents).to include(%(outpath=/about/))
|
759
942
|
end
|
760
943
|
end
|
761
944
|
|
@@ -770,15 +953,12 @@ describe 'Jekyll::AsciiDoc' do
|
|
770
953
|
'with_custom_collection'
|
771
954
|
end
|
772
955
|
|
773
|
-
before
|
774
|
-
site.process
|
775
|
-
end
|
956
|
+
before(:each) { site.process }
|
776
957
|
|
777
958
|
it 'should decorate document in custom collection' do
|
778
959
|
doc = find_doc 'blueprint-a.adoc', 'blueprints'
|
779
960
|
expect(doc).not_to be_nil
|
780
961
|
expect(doc.data['title']).to eql('First Blueprint')
|
781
|
-
expect(doc.title).to eql('First Blueprint') if ::Jekyll::MIN_VERSION_3
|
782
962
|
expect(doc.data['foo']).to eql('bar')
|
783
963
|
end
|
784
964
|
|
@@ -786,14 +966,14 @@ describe 'Jekyll::AsciiDoc' do
|
|
786
966
|
file = output_file 'blueprints/blueprint-a.html'
|
787
967
|
expect(::File).to exist(file)
|
788
968
|
contents = ::File.read file
|
789
|
-
expect(contents).to
|
969
|
+
expect(contents).to include('<p>Footer for blueprint layout.</p>')
|
790
970
|
end
|
791
971
|
|
792
972
|
it 'should allow the layout to be customized' do
|
793
973
|
file = output_file 'blueprints/blueprint-b.html'
|
794
974
|
expect(::File).to exist(file)
|
795
975
|
contents = ::File.read file
|
796
|
-
expect(contents).to
|
976
|
+
expect(contents).to include('<p>Footer for default layout.</p>')
|
797
977
|
end
|
798
978
|
|
799
979
|
it 'should set docdir for document in custom collection when base_dir config key has the value :docdir' do
|
@@ -801,11 +981,11 @@ describe 'Jekyll::AsciiDoc' do
|
|
801
981
|
out_file = output_file 'blueprints/blueprint-b.html'
|
802
982
|
expect(::File).to exist(out_file)
|
803
983
|
contents = ::File.read out_file
|
804
|
-
expect(contents).to
|
805
|
-
expect(contents).to
|
806
|
-
expect(contents).to
|
807
|
-
expect(contents).to
|
808
|
-
expect(contents).to
|
984
|
+
expect(contents).to include(%(docfile=#{src_file}))
|
985
|
+
expect(contents).to include(%(docdir=#{::File.dirname src_file}))
|
986
|
+
expect(contents).to include(%(outfile=#{out_file}))
|
987
|
+
expect(contents).to include(%(outdir=#{::File.dirname out_file}))
|
988
|
+
expect(contents).to include(%(outpath=/blueprints/blueprint-b.html))
|
809
989
|
end if ::Jekyll::MIN_VERSION_3
|
810
990
|
end
|
811
991
|
|
@@ -814,9 +994,7 @@ describe 'Jekyll::AsciiDoc' do
|
|
814
994
|
'pygments_code_highlighting'
|
815
995
|
end
|
816
996
|
|
817
|
-
before
|
818
|
-
site.process
|
819
|
-
end
|
997
|
+
before(:each) { site.process }
|
820
998
|
|
821
999
|
it 'should write the pygments stylesheet to the stylesdir' do
|
822
1000
|
src_file = source_file 'css/asciidoc-pygments.css'
|
@@ -827,7 +1005,7 @@ describe 'Jekyll::AsciiDoc' do
|
|
827
1005
|
src_content = ::File.read src_file
|
828
1006
|
out_content = ::File.read out_file
|
829
1007
|
expect(src_content).to eql(out_content)
|
830
|
-
expect(src_content).to
|
1008
|
+
expect(src_content).to include('.pygments .tok-c')
|
831
1009
|
ensure
|
832
1010
|
if ::File.exist? src_file
|
833
1011
|
::File.delete src_file
|
@@ -844,14 +1022,13 @@ describe 'Jekyll::AsciiDoc' do
|
|
844
1022
|
out_content = ::File.read src_file
|
845
1023
|
attrs = site.config['asciidoctor'][:attributes]
|
846
1024
|
attrs['pygments-style'] = 'monokai'
|
847
|
-
integrator = site.generators.find {|g| ::Jekyll::AsciiDoc::Integrator === g }
|
848
1025
|
integrator.generate_pygments_stylesheet site, attrs
|
849
1026
|
expect(::File.read src_file).not_to eql(src_content)
|
850
1027
|
::Jekyll::StaticFile.reset_cache
|
851
1028
|
site.process
|
852
1029
|
new_out_content = ::File.read out_file
|
853
1030
|
expect(new_out_content).not_to eql(out_content)
|
854
|
-
expect(new_out_content).to
|
1031
|
+
expect(new_out_content).to include('background-color: #49483e')
|
855
1032
|
ensure
|
856
1033
|
if ::File.exist? src_file
|
857
1034
|
::File.delete src_file
|
@@ -866,15 +1043,31 @@ describe 'Jekyll::AsciiDoc' do
|
|
866
1043
|
'xhtml_syntax'
|
867
1044
|
end
|
868
1045
|
|
869
|
-
before
|
870
|
-
site.process
|
871
|
-
end
|
1046
|
+
before(:each) { site.process }
|
872
1047
|
|
873
1048
|
it 'should output xhtml if asciidoctor backend option is xhtml' do
|
874
1049
|
file = output_file 'home.html'
|
875
1050
|
expect(::File).to exist(file)
|
876
1051
|
contents = ::File.read file
|
877
|
-
expect(contents).to
|
1052
|
+
expect(contents).to include('<img src="/images/sunset.jpg" alt="Sunset" width="408" height="230"/>')
|
878
1053
|
end
|
879
1054
|
end
|
1055
|
+
|
1056
|
+
describe 'tocify filter' do
|
1057
|
+
let :name do
|
1058
|
+
'tocify_filter'
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
before(:each) { site.process }
|
1062
|
+
|
1063
|
+
it 'should generate document outline when tocify_asciidoc filter is applied to page.document' do
|
1064
|
+
file = output_file 'index.html'
|
1065
|
+
expect(::File).to exist(file)
|
1066
|
+
contents = ::File.read file
|
1067
|
+
aside = contents.match(/<aside class="page-toc">.*<\/aside>/m)[0]
|
1068
|
+
expect(aside).to include('<ul class="sectlevel1">')
|
1069
|
+
expect(aside).to include('<a href="#major-section-a">Major Section A</a>')
|
1070
|
+
expect(aside).not_to include('Micro Section')
|
1071
|
+
end
|
1072
|
+
end if ::Jekyll::MIN_VERSION_3
|
880
1073
|
end
|