jekyll-asciidoc 2.1.1 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +26 -0
- data/Gemfile +4 -16
- data/LICENSE.adoc +1 -1
- data/README.adoc +370 -192
- data/jekyll-asciidoc.gemspec +23 -11
- data/lib/jekyll-asciidoc/compat.rb +5 -9
- data/lib/jekyll-asciidoc/converter.rb +89 -69
- data/lib/jekyll-asciidoc/filters.rb +2 -3
- data/lib/jekyll-asciidoc/integrator.rb +18 -29
- data/lib/jekyll-asciidoc/utils.rb +6 -3
- data/lib/jekyll-asciidoc/version.rb +1 -1
- metadata +48 -220
- data/Rakefile +0 -24
- data/spec/fixtures/alternate_page_attribute_prefix/_config.yml +0 -4
- data/spec/fixtures/alternate_page_attribute_prefix/_layouts/default.html +0 -12
- data/spec/fixtures/alternate_page_attribute_prefix/explicit-permalink.adoc +0 -4
- data/spec/fixtures/attributes_as_array/_config.yml +0 -7
- data/spec/fixtures/attributes_as_hash/_config.yml +0 -7
- data/spec/fixtures/basic_site/_config.yml +0 -2
- data/spec/fixtures/basic_site/_layouts/custom.html +0 -15
- data/spec/fixtures/basic_site/_layouts/page.html +0 -15
- data/spec/fixtures/basic_site/auto-layout.adoc +0 -4
- data/spec/fixtures/basic_site/bare-header.adoc +0 -4
- data/spec/fixtures/basic_site/custom-layout.adoc +0 -4
- data/spec/fixtures/basic_site/docid.adoc +0 -4
- data/spec/fixtures/basic_site/empty-layout.adoc +0 -4
- data/spec/fixtures/basic_site/empty-page-attribute.adoc +0 -4
- data/spec/fixtures/basic_site/liquid-enabled.adoc +0 -6
- data/spec/fixtures/basic_site/nil-layout.adoc +0 -4
- data/spec/fixtures/basic_site/no-doctitle.adoc +0 -2
- data/spec/fixtures/basic_site/no-liquid.adoc +0 -3
- data/spec/fixtures/basic_site/not-published.adoc +0 -4
- data/spec/fixtures/basic_site/section-with-id-and-role.adoc +0 -6
- data/spec/fixtures/basic_site/standalone-a.adoc +0 -4
- data/spec/fixtures/basic_site/standalone-b.adoc +0 -4
- data/spec/fixtures/basic_site/subdir/page-in-subdir.adoc +0 -7
- data/spec/fixtures/basic_site/with-front-matter-header-only.adoc +0 -4
- data/spec/fixtures/basic_site/with-front-matter-header.adoc +0 -6
- data/spec/fixtures/basic_site/without-front-matter-header.adoc +0 -3
- data/spec/fixtures/blank_page_attribute_prefix/_config.yml +0 -4
- data/spec/fixtures/blank_page_attribute_prefix/_layouts/default.html +0 -12
- data/spec/fixtures/blank_page_attribute_prefix/explicit-permalink.adoc +0 -4
- data/spec/fixtures/default_config/_config.yml +0 -2
- data/spec/fixtures/explicit_site_time/_config.yml +0 -4
- data/spec/fixtures/explicit_site_time/_layouts/default.html +0 -12
- data/spec/fixtures/explicit_site_time/home.adoc +0 -3
- data/spec/fixtures/fallback_to_default_layout/_blueprints/blueprint.adoc +0 -3
- data/spec/fixtures/fallback_to_default_layout/_config.yml +0 -5
- data/spec/fixtures/fallback_to_default_layout/_layouts/default.html +0 -15
- data/spec/fixtures/fallback_to_default_layout/_posts/2016-01-01-post.adoc +0 -4
- data/spec/fixtures/fallback_to_default_layout/home.adoc +0 -3
- data/spec/fixtures/front_matter_defaults/_config.yml +0 -10
- data/spec/fixtures/front_matter_defaults/_layouts/docs.html +0 -15
- data/spec/fixtures/front_matter_defaults/_layouts/general.html +0 -15
- data/spec/fixtures/front_matter_defaults/docs/page.adoc +0 -3
- data/spec/fixtures/front_matter_defaults/page.adoc +0 -3
- data/spec/fixtures/hybrid_config/_config.yml +0 -8
- data/spec/fixtures/imagesdir_relative_to_root/_config.yml +0 -5
- data/spec/fixtures/include_relative_to_docdir/_config.yml +0 -4
- data/spec/fixtures/include_relative_to_docdir/_layouts/default.html +0 -12
- data/spec/fixtures/include_relative_to_docdir/about/_people.adoc +0 -2
- data/spec/fixtures/include_relative_to_docdir/about/index.adoc +0 -13
- data/spec/fixtures/include_relative_to_root/source/_config.yml +0 -2
- data/spec/fixtures/include_relative_to_root/source/_layouts/default.html +0 -11
- data/spec/fixtures/include_relative_to_root/source/about/_people.adoc +0 -2
- data/spec/fixtures/include_relative_to_root/source/about/index.adoc +0 -13
- data/spec/fixtures/include_relative_to_source/_config.yml +0 -4
- data/spec/fixtures/include_relative_to_source/_layouts/default.html +0 -12
- data/spec/fixtures/include_relative_to_source/about/_people.adoc +0 -2
- data/spec/fixtures/include_relative_to_source/about/index.adoc +0 -13
- data/spec/fixtures/legacy_config/_config.yml +0 -5
- data/spec/fixtures/pygments_code_highlighting/_config.yml +0 -6
- data/spec/fixtures/pygments_code_highlighting/_layouts/page.html +0 -13
- data/spec/fixtures/pygments_code_highlighting/page-with-code.adoc +0 -16
- data/spec/fixtures/read_error/_config.yml +0 -2
- data/spec/fixtures/read_error/unreadable.adoc +0 -3
- data/spec/fixtures/require_front_matter_header/_config.yml +0 -4
- data/spec/fixtures/require_front_matter_header/_layouts/default.html +0 -12
- data/spec/fixtures/require_front_matter_header/with-front-matter-header.adoc +0 -5
- data/spec/fixtures/require_front_matter_header/without-front-matter-header.adoc +0 -3
- data/spec/fixtures/safe_mode/_config.yml +0 -4
- data/spec/fixtures/safe_mode/_layouts/home.html +0 -15
- data/spec/fixtures/safe_mode/home.adoc +0 -5
- data/spec/fixtures/tocify_filter/_config.yml +0 -2
- data/spec/fixtures/tocify_filter/_layouts/default.html +0 -15
- data/spec/fixtures/tocify_filter/index.adoc +0 -25
- data/spec/fixtures/with_custom_collection/_blueprints/blueprint-a.adoc +0 -4
- data/spec/fixtures/with_custom_collection/_blueprints/blueprint-b.adoc +0 -10
- data/spec/fixtures/with_custom_collection/_config.yml +0 -7
- data/spec/fixtures/with_custom_collection/_layouts/blueprint.html +0 -15
- data/spec/fixtures/with_custom_collection/_layouts/default.html +0 -15
- data/spec/fixtures/with_posts/_config.yml +0 -6
- data/spec/fixtures/with_posts/_drafts/a-draft-post.adoc +0 -5
- data/spec/fixtures/with_posts/_layouts/custom.html +0 -15
- data/spec/fixtures/with_posts/_layouts/post.html +0 -23
- data/spec/fixtures/with_posts/_posts/2016-01-01-welcome.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-01-02-empty-layout.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-01-03-auto-layout.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-01-04-custom-layout.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-01-05-nil-layout.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-02-01-post-with-categories.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-02-02-post-with-singular-vars.adoc +0 -7
- data/spec/fixtures/with_posts/_posts/2016-03-01-post-with-excerpt.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-04-01-show-me-the-title.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-05-31-automatic-title.adoc +0 -1
- data/spec/fixtures/with_posts/_posts/2016-06-15-post-with-date.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-07-15-post-with-date-and-tz.adoc +0 -4
- data/spec/fixtures/with_posts/_posts/2016-07-20-post-with-date-in-revision-line.adoc +0 -6
- data/spec/fixtures/with_posts/index.html +0 -22
- data/spec/fixtures/xhtml_syntax/_config.yml +0 -6
- data/spec/fixtures/xhtml_syntax/home.adoc +0 -5
- data/spec/fixtures/xhtml_syntax/images/sunset.jpg +0 -0
- data/spec/jekyll-asciidoc_spec.rb +0 -1103
- data/spec/spec_helper.rb +0 -64
@@ -1,15 +0,0 @@
|
|
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>
|
@@ -1,25 +0,0 @@
|
|
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
|
@@ -1,15 +0,0 @@
|
|
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
|
-
<footer>
|
12
|
-
<p>Footer for blueprint layout.</p>
|
13
|
-
</footer>
|
14
|
-
</body>
|
15
|
-
</html>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<title>{{ page.title }}</title>
|
6
|
-
</head>
|
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>
|
15
|
-
<div class="post-content">
|
16
|
-
{{ content }}
|
17
|
-
</div>
|
18
|
-
</article>
|
19
|
-
<footer>
|
20
|
-
<p>Footer for post layout.</p>
|
21
|
-
</footer>
|
22
|
-
</body>
|
23
|
-
</html>
|
@@ -1 +0,0 @@
|
|
1
|
-
Lorem ipsum.
|
@@ -1,22 +0,0 @@
|
|
1
|
-
---
|
2
|
-
---
|
3
|
-
<!DOCTYPE html>
|
4
|
-
<html>
|
5
|
-
<head>
|
6
|
-
<title>Posts</title>
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div class="index">
|
10
|
-
<h1>Posts</h1>
|
11
|
-
<ul class="posts">
|
12
|
-
{% for post in site.posts %}
|
13
|
-
<li>
|
14
|
-
<a href="{{ post.url }}">{{ post.title }}</a>
|
15
|
-
{% if post.excerpt != '' %}<p class="excerpt">{{ post.excerpt | asciidocify: 'inline' }}</p>{% endif %}
|
16
|
-
</li>
|
17
|
-
{% endfor %}
|
18
|
-
</ul>
|
19
|
-
</div>
|
20
|
-
</body>
|
21
|
-
</html>
|
22
|
-
|
Binary file
|
@@ -1,1103 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Jekyll::AsciiDoc' do
|
4
|
-
let :config do
|
5
|
-
::Jekyll.configuration(fixture_site_params name)
|
6
|
-
end
|
7
|
-
|
8
|
-
let :site do
|
9
|
-
::Jekyll::Site.new config
|
10
|
-
end
|
11
|
-
|
12
|
-
let :converter do
|
13
|
-
::Jekyll::AsciiDoc::Converter.get_instance site
|
14
|
-
end
|
15
|
-
|
16
|
-
let :integrator do
|
17
|
-
::Jekyll::AsciiDoc::Integrator.get_instance site
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'default configuration' do
|
21
|
-
let :name do
|
22
|
-
'default_config'
|
23
|
-
end
|
24
|
-
|
25
|
-
before :each do
|
26
|
-
site.object_id
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should register AsciiDoc converter' do
|
30
|
-
expect(site.converters.any? {|c| ::Jekyll::AsciiDoc::Converter === c }).to be true
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should register AsciiDoc generator' do
|
34
|
-
expect(site.generators.any? {|g| ::Jekyll::AsciiDoc::Integrator === g }).to be true
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should configure AsciiDoc converter to match AsciiDoc file extension' do
|
38
|
-
expect(converter).not_to be_nil
|
39
|
-
expect(converter.matches '.adoc').to be_truthy
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should use .html as output extension' do
|
43
|
-
expect(converter).not_to be_nil
|
44
|
-
expect(converter.output_ext '.adoc').to eql('.html')
|
45
|
-
end
|
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
|
-
|
56
|
-
it 'should use Asciidoctor to process AsciiDoc files by default' do
|
57
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
58
|
-
expect(site.config['asciidoc']['processor']).to eql('asciidoctor')
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should match AsciiDoc file extensions asciidoc,adoc,ad by default' do
|
62
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
63
|
-
expect(site.config['asciidoc']['ext']).to eql('asciidoc,adoc,ad')
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should use page as page attribute prefix by default' do
|
67
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
68
|
-
expect(site.config['asciidoc']['page_attribute_prefix']).to eql('page')
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'should not require a front matter header by default' do
|
72
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
73
|
-
expect(site.config['asciidoc']['require_front_matter_header']).to be false
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'should use Asciidoctor in safe mode by default' do
|
77
|
-
expect(site.config['asciidoctor']).to be_a(::Hash)
|
78
|
-
expect(site.config['asciidoctor'][:safe]).to eql('safe')
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'should pass implicit attributes to Asciidoctor' do
|
82
|
-
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
83
|
-
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
84
|
-
expect(attrs['env']).to eql('site')
|
85
|
-
expect(attrs['env-site']).to eql('')
|
86
|
-
expect(attrs['site-gen']).to eql('jekyll')
|
87
|
-
expect(attrs['site-gen-jekyll']).to eql('')
|
88
|
-
expect(attrs['builder']).to eql('jekyll')
|
89
|
-
expect(attrs['builder-jekyll']).to eql('')
|
90
|
-
expect(attrs['jekyll-version']).to eql(::Jekyll::VERSION)
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'should should pass site attributes to Asciidoctor' do
|
94
|
-
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
95
|
-
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
96
|
-
expect(attrs['site-root']).to eql(::Dir.pwd)
|
97
|
-
expect(attrs['site-source']).to eql(site.source)
|
98
|
-
expect(attrs['site-destination']).to eql(site.dest)
|
99
|
-
expect(attrs['site-baseurl']).to eql(site.config['baseurl'])
|
100
|
-
expect(attrs['site-url']).to eql('http://example.org')
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe 'legacy configuration' do
|
105
|
-
let :name do
|
106
|
-
'legacy_config'
|
107
|
-
end
|
108
|
-
|
109
|
-
before :each do
|
110
|
-
site.object_id
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should allow processor to be set using asciidoc key' do
|
114
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
115
|
-
expect(site.config['asciidoc']['processor']).to eql('asciidoctor')
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should migrate asciidoc_ext key' do
|
119
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
120
|
-
expect(site.config['asciidoc']['ext']).to eql('adoc')
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'should migrate asciidoc_page_attribute_prefix key' do
|
124
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
125
|
-
expect(site.config['asciidoc']['page_attribute_prefix']).to eql('jekyll')
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe 'hybrid configuration' do
|
130
|
-
let :name do
|
131
|
-
'hybrid_config'
|
132
|
-
end
|
133
|
-
|
134
|
-
before :each do
|
135
|
-
site.object_id
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'should use new key for ext over legacy key' do
|
139
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
140
|
-
expect(site.config['asciidoc']['ext']).to eql('asciidoc,adoc')
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'should use new key page_attribute_prefix over legacy key' do
|
144
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
145
|
-
expect(site.config['asciidoc']['page_attribute_prefix']).to eql('pg')
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe 'parse YAML value' do
|
150
|
-
let :name do
|
151
|
-
'default_config'
|
152
|
-
end
|
153
|
-
|
154
|
-
before :each do
|
155
|
-
site.object_id
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'should parse string as YAML value' do
|
159
|
-
expect(integrator.send :parse_yaml_value, '').to eql('')
|
160
|
-
expect(integrator.send :parse_yaml_value, 'true').to be true
|
161
|
-
expect(integrator.send :parse_yaml_value, 'false').to be false
|
162
|
-
expect(integrator.send :parse_yaml_value, '~').to be_nil
|
163
|
-
expect(integrator.send :parse_yaml_value, '1').to eql(1)
|
164
|
-
expect(integrator.send :parse_yaml_value, '[one, two]').to eql(['one', 'two'])
|
165
|
-
expect(integrator.send :parse_yaml_value, 'John\'s House').to eql('John\'s House')
|
166
|
-
expect(integrator.send :parse_yaml_value, '\'bar\'').to eql('bar')
|
167
|
-
expect(integrator.send :parse_yaml_value, '\'').to eql('\'')
|
168
|
-
expect(integrator.send :parse_yaml_value, '-').to eql('-')
|
169
|
-
expect(integrator.send :parse_yaml_value, '@').to eql('@')
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
describe 'imagesdir relative to root' do
|
174
|
-
let :name do
|
175
|
-
'imagesdir_relative_to_root'
|
176
|
-
end
|
177
|
-
|
178
|
-
before :each do
|
179
|
-
site.object_id
|
180
|
-
end
|
181
|
-
|
182
|
-
it 'should set imagesoutdir if imagesdir is relative to root' do
|
183
|
-
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
184
|
-
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
185
|
-
expect(attrs['imagesdir']).to eql('/images@')
|
186
|
-
expect(attrs['imagesoutdir']).to eql(::File.join site.dest, (attrs['imagesdir'].chomp '@'))
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe 'imagesdir not set' do
|
191
|
-
let :name do
|
192
|
-
'default_config'
|
193
|
-
end
|
194
|
-
|
195
|
-
before :each do
|
196
|
-
site.object_id
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'should not set imagesoutdir if imagesdir is not set' do
|
200
|
-
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
201
|
-
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
202
|
-
expect(attrs.key? 'imagesdir').to be false
|
203
|
-
expect(attrs.key? 'imagesoutdir').to be false
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
describe 'compile attributes' do
|
208
|
-
let :name do
|
209
|
-
'default_config'
|
210
|
-
end
|
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
|
-
|
222
|
-
it 'should transform negated attribute with trailing ! to attribute with nil value' do
|
223
|
-
result = converter.send :assemble_attributes, { 'icons!' => '' }
|
224
|
-
expect(result.key? 'icons').to be true
|
225
|
-
expect(result['icons']).to be_nil
|
226
|
-
end
|
227
|
-
|
228
|
-
it 'should transform negated attribute with leading ! to attribute with nil value' do
|
229
|
-
result = converter.send :assemble_attributes, { '!icons' => '' }
|
230
|
-
expect(result.key? 'icons').to be true
|
231
|
-
expect(result['icons']).to be_nil
|
232
|
-
end
|
233
|
-
|
234
|
-
it 'should set existing attribute to nil when attribute is unset' do
|
235
|
-
result = converter.send :assemble_attributes, { 'icons' => 'font', '!icons' => '' }
|
236
|
-
expect(result.key? 'icons').to be true
|
237
|
-
expect(result['icons']).to be_nil
|
238
|
-
end
|
239
|
-
|
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']
|
242
|
-
expect(result['icons']).to eql('font')
|
243
|
-
expect(result['source-highlighter']).to eql('coderay')
|
244
|
-
end
|
245
|
-
|
246
|
-
it 'should resolve attribute references in attribute value' do
|
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}' }
|
253
|
-
expect(result['foobar']).to eql('foobar')
|
254
|
-
end
|
255
|
-
|
256
|
-
it 'should not resolve escaped attribute reference' do
|
257
|
-
result = converter.send :assemble_attributes, { 'foo' => 'foo', 'bar' => 'bar', 'foobar' => '{foo}\{bar}' }
|
258
|
-
expect(result['foobar']).to eql('foo{bar}')
|
259
|
-
end
|
260
|
-
|
261
|
-
it 'should leave unresolved attribute reference in place' do
|
262
|
-
result = converter.send :assemble_attributes, { 'foo' => 'foo', 'foobar' => '{foo}{bar}' }
|
263
|
-
expect(result['foobar']).to eql('foo{bar}')
|
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
|
297
|
-
end
|
298
|
-
|
299
|
-
describe 'attributes as hash' do
|
300
|
-
let :name do
|
301
|
-
'attributes_as_hash'
|
302
|
-
end
|
303
|
-
|
304
|
-
before :each do
|
305
|
-
site.object_id
|
306
|
-
end
|
307
|
-
|
308
|
-
it 'should merge attributes defined as a Hash into the attributes Hash' do
|
309
|
-
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
310
|
-
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
311
|
-
expect(attrs['env']).to eql('site')
|
312
|
-
expect(attrs['icons']).to eql('font')
|
313
|
-
expect(attrs['sectanchors']).to eql('')
|
314
|
-
expect(attrs.key? 'table-caption').to be true
|
315
|
-
expect(attrs['table-caption']).to be_nil
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe 'attributes as array' do
|
320
|
-
let :name do
|
321
|
-
'attributes_as_array'
|
322
|
-
end
|
323
|
-
|
324
|
-
before :each do
|
325
|
-
site.object_id
|
326
|
-
end
|
327
|
-
|
328
|
-
it 'should merge attributes defined as an Array into the attributes Hash' do
|
329
|
-
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
330
|
-
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
331
|
-
expect(attrs['env']).to eql('site')
|
332
|
-
expect(attrs['icons']).to eql('font')
|
333
|
-
expect(attrs['sectanchors']).to eql('')
|
334
|
-
expect(attrs.key? 'table-caption').to be true
|
335
|
-
expect(attrs['table-caption']).to be_nil
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
describe 'alternate page attribute prefix' do
|
340
|
-
let :name do
|
341
|
-
'alternate_page_attribute_prefix'
|
342
|
-
end
|
343
|
-
|
344
|
-
before(:each) { site.process }
|
345
|
-
|
346
|
-
it 'should strip trailing hyphen from page attribute prefix value' do
|
347
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
348
|
-
expect(site.config['asciidoc']['page_attribute_prefix']).to eql('jekyll')
|
349
|
-
end
|
350
|
-
|
351
|
-
it 'should recognize page attributes with alternate page attribute prefix' do
|
352
|
-
page = find_page 'explicit-permalink.adoc'
|
353
|
-
expect(page).not_to be_nil
|
354
|
-
expect(page.permalink).to eql('/permalink/')
|
355
|
-
file = output_file 'permalink/index.html'
|
356
|
-
expect(::File).to exist(file)
|
357
|
-
contents = ::File.read file
|
358
|
-
expect(contents).to include('<div class="page-content">')
|
359
|
-
expect(contents).not_to include(%(<meta name="generator" content="Asciidoctor #{::Asciidoctor::VERSION}">))
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
describe 'blank page attribute prefix' do
|
364
|
-
let :name do
|
365
|
-
'blank_page_attribute_prefix'
|
366
|
-
end
|
367
|
-
|
368
|
-
before(:each) { site.process }
|
369
|
-
|
370
|
-
it 'should coerce null value for page attribute prefix to empty string' do
|
371
|
-
expect(site.config['asciidoc']).to be_a(::Hash)
|
372
|
-
expect(site.config['asciidoc']['page_attribute_prefix']).to eql('')
|
373
|
-
end
|
374
|
-
|
375
|
-
it 'should recognize page attributes with no page attribute prefix' do
|
376
|
-
page = find_page 'explicit-permalink.adoc'
|
377
|
-
expect(page).not_to be_nil
|
378
|
-
expect(page.permalink).to eql('/permalink/')
|
379
|
-
file = output_file 'permalink/index.html'
|
380
|
-
expect(::File).to exist(file)
|
381
|
-
contents = ::File.read file
|
382
|
-
expect(contents).to include('<div class="page-content">')
|
383
|
-
expect(contents).not_to include(%(<meta name="generator" content="Asciidoctor #{::Asciidoctor::VERSION}">))
|
384
|
-
end
|
385
|
-
end
|
386
|
-
|
387
|
-
describe 'basic site' do
|
388
|
-
let :name do
|
389
|
-
'basic_site'
|
390
|
-
end
|
391
|
-
|
392
|
-
before(:each) { site.process }
|
393
|
-
|
394
|
-
it 'should consider a plain AsciiDoc file to have a YAML header' do
|
395
|
-
file = source_file 'without-front-matter-header.adoc'
|
396
|
-
expect(::Jekyll::Utils.has_yaml_header? file).to be true
|
397
|
-
end
|
398
|
-
|
399
|
-
it 'should convert a plain AsciiDoc file' do
|
400
|
-
file = output_file 'without-front-matter-header.html'
|
401
|
-
expect(::File).to exist(file)
|
402
|
-
contents = ::File.read file
|
403
|
-
expect(contents).to include('<p>Lorem ipsum.</p>')
|
404
|
-
end
|
405
|
-
|
406
|
-
it 'should promote AsciiDoc document title to page title' do
|
407
|
-
file = output_file 'without-front-matter-header.html'
|
408
|
-
expect(::File).to exist(file)
|
409
|
-
contents = ::File.read file
|
410
|
-
expect(contents).to include('<title>Page Title</title>')
|
411
|
-
end
|
412
|
-
|
413
|
-
it 'should convert an AsciiDoc with no doctitle or AsciiDoc header' do
|
414
|
-
page = find_page 'no-doctitle.adoc'
|
415
|
-
expect(page).not_to be_nil
|
416
|
-
expect(page.data.key? 'title').to be false
|
417
|
-
file = output_file 'no-doctitle.html'
|
418
|
-
expect(::File).to exist(file)
|
419
|
-
contents = ::File.read file
|
420
|
-
expect(contents).to include('<title>Site Title</title>')
|
421
|
-
expect(contents).to include(%(<p>Just content.\nLorem ipsum.</p>))
|
422
|
-
end
|
423
|
-
|
424
|
-
it 'should convert an AsciiDoc with bare AsciiDoc header' do
|
425
|
-
page = find_page 'bare-header.adoc'
|
426
|
-
expect(page).not_to be_nil
|
427
|
-
expect(page.data.key? 'title').to be false
|
428
|
-
expect(page.permalink).to eql('/bare/')
|
429
|
-
file = output_file 'bare/index.html'
|
430
|
-
expect(::File).to exist(file)
|
431
|
-
contents = ::File.read file
|
432
|
-
expect(contents).to include('<title>Site Title</title>')
|
433
|
-
expect(contents).to include(%(<p>Just content.\nLorem ipsum.</p>))
|
434
|
-
end
|
435
|
-
|
436
|
-
it 'should consider an AsciiDoc file with a front matter header to have a YAML header' do
|
437
|
-
file = source_file 'with-front-matter-header.adoc'
|
438
|
-
expect(::Jekyll::Utils.has_yaml_header? file).to be true
|
439
|
-
end
|
440
|
-
|
441
|
-
it 'should convert an AsciiDoc file with a front matter header' do
|
442
|
-
file = output_file 'with-front-matter-header.html'
|
443
|
-
expect(::File).to exist(file)
|
444
|
-
contents = ::File.read file
|
445
|
-
expect(contents).to include('<title>Page Title</title>')
|
446
|
-
expect(contents).to include('<p>Lorem ipsum.</p>')
|
447
|
-
end
|
448
|
-
|
449
|
-
it 'should convert an AsciiDoc file with only a front matter header' do
|
450
|
-
file = output_file 'with-front-matter-header-only.html'
|
451
|
-
expect(::File).to exist(file)
|
452
|
-
contents = ::File.read file
|
453
|
-
expect(contents).to include('<title>Front Matter Only</title>')
|
454
|
-
expect(contents).to include(%(<div class="page-content">\n\n</div>))
|
455
|
-
end
|
456
|
-
|
457
|
-
it 'should apply explicit id and role attributes on section titles' do
|
458
|
-
file = output_file 'section-with-id-and-role.html'
|
459
|
-
expect(::File).to exist(file)
|
460
|
-
contents = ::File.read file
|
461
|
-
expect(contents).to include(%(<div class="sect1 section-role">\n<h2 id="section-id">Section Title</h2>))
|
462
|
-
end
|
463
|
-
|
464
|
-
it 'should assign AsciiDoc document id, if set, to docid page attribute' do
|
465
|
-
page = find_page 'docid.adoc'
|
466
|
-
expect(page).not_to be_nil
|
467
|
-
expect(page.data.key? 'docid').to be true
|
468
|
-
expect(page.data['docid']).to eq('page-id')
|
469
|
-
end
|
470
|
-
|
471
|
-
it 'should not use Liquid preprocessor by default' do
|
472
|
-
file = output_file 'no-liquid.html'
|
473
|
-
expect(::File).to exist(file)
|
474
|
-
contents = ::File.read file
|
475
|
-
expect(contents).to include('<p>{{ page.title }}</p>')
|
476
|
-
end
|
477
|
-
|
478
|
-
it 'should enable Liquid preprocessor if liquid page variable is set' do
|
479
|
-
file = output_file 'liquid-enabled.html'
|
480
|
-
expect(::File).to exist(file)
|
481
|
-
contents = ::File.read file
|
482
|
-
expect(contents).to include('<p>Liquid Enabled</p>')
|
483
|
-
end
|
484
|
-
|
485
|
-
it 'should not publish a page if the published page variable is set in the AsciiDoc header' do
|
486
|
-
file = output_file 'not-published.html'
|
487
|
-
expect(::File).not_to exist(file)
|
488
|
-
end
|
489
|
-
|
490
|
-
it 'should output a standalone HTML page if the page-layout attribute is unset' do
|
491
|
-
file = output_file 'standalone-a.html'
|
492
|
-
expect(::File).to exist(file)
|
493
|
-
contents = ::File.read file
|
494
|
-
expect(contents).to include(%(<meta name="generator" content="Asciidoctor #{::Asciidoctor::VERSION}">))
|
495
|
-
expect(contents).to include('<title>Standalone Page A</title>')
|
496
|
-
expect(contents).to include('<h1>Standalone Page A</h1>')
|
497
|
-
end
|
498
|
-
|
499
|
-
it 'should output a standalone HTML page if the page-layout attribute is false' do
|
500
|
-
file = output_file 'standalone-b.html'
|
501
|
-
expect(::File).to exist(file)
|
502
|
-
contents = ::File.read file
|
503
|
-
expect(contents).to include(%(<meta name="generator" content="Asciidoctor #{::Asciidoctor::VERSION}">))
|
504
|
-
expect(contents).to include('<title>Standalone Page B</title>')
|
505
|
-
expect(contents).to include('<h1>Standalone Page B</h1>')
|
506
|
-
end
|
507
|
-
|
508
|
-
it 'should apply layout named page to page content if page-layout attribute not specified' do
|
509
|
-
file = output_file 'without-front-matter-header.html'
|
510
|
-
expect(::File).to exist(file)
|
511
|
-
contents = ::File.read file
|
512
|
-
expect(contents).to include('<p>Footer for page layout.</p>')
|
513
|
-
end
|
514
|
-
|
515
|
-
it 'should apply layout named page to page content if page-layout attribute is empty' do
|
516
|
-
file = output_file 'empty-layout.html'
|
517
|
-
expect(::File).to exist(file)
|
518
|
-
contents = ::File.read file
|
519
|
-
expect(contents).to include('<p>Footer for page layout.</p>')
|
520
|
-
end
|
521
|
-
|
522
|
-
it 'should apply layout named page to page content if page-layout attribute has value _auto' do
|
523
|
-
file = output_file 'auto-layout.html'
|
524
|
-
expect(::File).to exist(file)
|
525
|
-
contents = ::File.read file
|
526
|
-
expect(contents).to include('<p>Footer for page layout.</p>')
|
527
|
-
end
|
528
|
-
|
529
|
-
it 'should apply specified layout to page content if page-layout has non-empty string value' do
|
530
|
-
file = output_file 'custom-layout.html'
|
531
|
-
expect(::File).to exist(file)
|
532
|
-
contents = ::File.read file
|
533
|
-
expect(contents).to include('<p>Footer for custom layout.</p>')
|
534
|
-
end
|
535
|
-
|
536
|
-
it 'should not apply a layout to page content if page-layout attribute is nil' do
|
537
|
-
file = output_file 'nil-layout.html'
|
538
|
-
expect(::File).to exist(file)
|
539
|
-
contents = ::File.read file
|
540
|
-
expect(contents).to include(%(div class="paragraph">\n<p>Lorem ipsum.</p>\n</div>))
|
541
|
-
end
|
542
|
-
|
543
|
-
it 'should convert an empty page attribute value to empty string' do
|
544
|
-
page = find_page 'empty-page-attribute.adoc'
|
545
|
-
expect(page).not_to be_nil
|
546
|
-
expect(page.data['attribute-with-empty-value']).to eql('')
|
547
|
-
end
|
548
|
-
|
549
|
-
it 'should resolve docdir as base_dir if base_dir value is not :docdir' do
|
550
|
-
src_file = source_file 'subdir/page-in-subdir.adoc'
|
551
|
-
out_file = output_file 'subdir/page-in-subdir.html'
|
552
|
-
expect(::File).to exist(out_file)
|
553
|
-
contents = ::File.read out_file
|
554
|
-
expect(contents).to include(%(docdir=#{::Dir.pwd}))
|
555
|
-
if ::Jekyll::MIN_VERSION_3
|
556
|
-
expect(contents).to include(%(docfile=#{src_file}))
|
557
|
-
expect(contents).to include(%(docname=#{::File.basename src_file, '.adoc'}))
|
558
|
-
end
|
559
|
-
end
|
560
|
-
|
561
|
-
it 'should only register pre and post render hooks once' do
|
562
|
-
hooks_registry = ::Jekyll::Hooks.instance_variable_get :@registry
|
563
|
-
expect(hooks_registry[:pages][:pre_render].size).to eql(1)
|
564
|
-
expect(hooks_registry[:pages][:post_render].size).to eql(1)
|
565
|
-
expect(hooks_registry[:documents][:pre_render].size).to eql(1)
|
566
|
-
expect(hooks_registry[:documents][:post_render].size).to eql(1)
|
567
|
-
site.process
|
568
|
-
expect(hooks_registry[:pages][:pre_render].size).to eql(1)
|
569
|
-
expect(hooks_registry[:pages][:post_render].size).to eql(1)
|
570
|
-
expect(hooks_registry[:documents][:pre_render].size).to eql(1)
|
571
|
-
expect(hooks_registry[:documents][:post_render].size).to eql(1)
|
572
|
-
end if ::Jekyll::MIN_VERSION_3
|
573
|
-
end
|
574
|
-
|
575
|
-
describe 'explicit site time' do
|
576
|
-
let :name do
|
577
|
-
'explicit_site_time'
|
578
|
-
end
|
579
|
-
|
580
|
-
before(:each) { site.process }
|
581
|
-
|
582
|
-
it 'should set localdatetime on AsciiDoc pages to match site time and time zone' do
|
583
|
-
expect(asciidoctor_config = site.config['asciidoctor']).to be_a(::Hash)
|
584
|
-
expect(attrs = asciidoctor_config[:attributes]).to be_a(::Hash)
|
585
|
-
expect(attrs['localdate']).to eql(site.time.strftime '%Y-%m-%d')
|
586
|
-
expect(attrs['localtime']).to eql(site.time.strftime '%H:%M:%S %Z')
|
587
|
-
file = output_file 'home.html'
|
588
|
-
expect(::File).to exist(file)
|
589
|
-
contents = ::File.read file
|
590
|
-
expect(contents).to include(%(localdatetime=#{site.time.strftime '%Y-%m-%d %H:%M:%S %Z'}))
|
591
|
-
end
|
592
|
-
end
|
593
|
-
|
594
|
-
describe 'safe mode' do
|
595
|
-
let :name do
|
596
|
-
'safe_mode'
|
597
|
-
end
|
598
|
-
|
599
|
-
before(:each) { site.process }
|
600
|
-
|
601
|
-
it 'should register converter and generator when running in safe mode' do
|
602
|
-
expect(site.converters.any? {|c| ::Jekyll::AsciiDoc::Converter === c }).to be true
|
603
|
-
expect(site.generators.any? {|g| ::Jekyll::AsciiDoc::Integrator === g }).to be true
|
604
|
-
end
|
605
|
-
|
606
|
-
it 'should convert AsciiDoc file when running in safe mode' do
|
607
|
-
file = output_file 'home.html'
|
608
|
-
expect(::File).to exist(file)
|
609
|
-
contents = ::File.read file
|
610
|
-
expect(contents).to include('<title>Home Page</title>')
|
611
|
-
expect(contents).to include('<p>Footer for home layout.</p>')
|
612
|
-
end
|
613
|
-
end
|
614
|
-
|
615
|
-
describe 'use default as fallback layout' do
|
616
|
-
let :name do
|
617
|
-
'fallback_to_default_layout'
|
618
|
-
end
|
619
|
-
|
620
|
-
before(:each) { site.process }
|
621
|
-
|
622
|
-
it 'should use default layout for page if page layout is not available' do
|
623
|
-
file = output_file 'home.html'
|
624
|
-
expect(::File).to exist(file)
|
625
|
-
contents = ::File.read file
|
626
|
-
expect(contents).to include('<p>Footer for default layout.</p>')
|
627
|
-
end
|
628
|
-
|
629
|
-
it 'should use default layout for post if post layout is not available' do
|
630
|
-
file = output_file '2016/01/01/post.html'
|
631
|
-
expect(::File).to exist(file)
|
632
|
-
contents = ::File.read file
|
633
|
-
expect(contents).to include('<p>Footer for default layout.</p>')
|
634
|
-
end
|
635
|
-
|
636
|
-
it 'should use default layout for document if layout for document collection is not available' do
|
637
|
-
file = output_file 'blueprints/blueprint.html'
|
638
|
-
expect(::File).to exist(file)
|
639
|
-
contents = ::File.read file
|
640
|
-
expect(contents).to include('<p>Footer for default layout.</p>')
|
641
|
-
end
|
642
|
-
end
|
643
|
-
|
644
|
-
describe 'use front matter defaults' do
|
645
|
-
let :name do
|
646
|
-
'front_matter_defaults'
|
647
|
-
end
|
648
|
-
|
649
|
-
before(:each) { site.process }
|
650
|
-
|
651
|
-
it 'should use the layout for the default scope when no layout is specified' do
|
652
|
-
file = output_file 'page.html'
|
653
|
-
expect(::File).to exist(file)
|
654
|
-
contents = ::File.read file
|
655
|
-
expect(contents).to include('<p>Footer for general layout.</p>')
|
656
|
-
end
|
657
|
-
|
658
|
-
it 'should use the layout for the matching scope when no layout is specified' do
|
659
|
-
file = output_file 'docs/page.html'
|
660
|
-
expect(::File).to exist(file)
|
661
|
-
contents = ::File.read file
|
662
|
-
expect(contents).to include('<p>Footer for docs layout.</p>')
|
663
|
-
end
|
664
|
-
end
|
665
|
-
|
666
|
-
describe 'require front matter header' do
|
667
|
-
let :name do
|
668
|
-
'require_front_matter_header'
|
669
|
-
end
|
670
|
-
|
671
|
-
before(:each) { site.process }
|
672
|
-
|
673
|
-
it 'should consider an AsciiDoc file with a front matter header to have a YAML header' do
|
674
|
-
file = source_file 'with-front-matter-header.adoc'
|
675
|
-
expect(::Jekyll::Utils.has_yaml_header? file).to be true
|
676
|
-
end
|
677
|
-
|
678
|
-
it 'should consider an AsciiDoc file without a front matter header to not have a YAML header' do
|
679
|
-
file = source_file 'without-front-matter-header.adoc'
|
680
|
-
expect(::Jekyll::Utils.has_yaml_header? file).to be false
|
681
|
-
end
|
682
|
-
|
683
|
-
it 'should convert an AsciiDoc file with a front matter header' do
|
684
|
-
file = output_file 'with-front-matter-header.html'
|
685
|
-
expect(::File).to exist(file)
|
686
|
-
contents = ::File.read file
|
687
|
-
expect(contents).to include('<title>Page Title</title>')
|
688
|
-
expect(contents).to include('<p>Lorem ipsum.</p>')
|
689
|
-
end
|
690
|
-
|
691
|
-
it 'should not convert an AsciiDoc file without a front matter header' do
|
692
|
-
file = output_file 'without-front-matter-header.adoc'
|
693
|
-
expect(::File).to exist(file)
|
694
|
-
end
|
695
|
-
end
|
696
|
-
|
697
|
-
describe 'site with posts' do
|
698
|
-
let :name do
|
699
|
-
'with_posts'
|
700
|
-
end
|
701
|
-
|
702
|
-
before :each do
|
703
|
-
site.show_drafts = true
|
704
|
-
site.process
|
705
|
-
end
|
706
|
-
|
707
|
-
it 'should use document title as post title' do
|
708
|
-
post = find_post '2016-01-01-welcome.adoc'
|
709
|
-
expect(post).not_to be_nil
|
710
|
-
expect(post.data['title']).to eql('Welcome, Visitor!')
|
711
|
-
file = output_file '2016/01/01/welcome.html'
|
712
|
-
expect(::File).to exist(file)
|
713
|
-
contents = ::File.read file
|
714
|
-
expect(contents).to include('<title>Welcome, Visitor!</title>')
|
715
|
-
expect(contents).not_to include('<h1>Welcome, Visitor!</h1>')
|
716
|
-
end
|
717
|
-
|
718
|
-
it 'should use automatic title if no document title is given' do
|
719
|
-
post = find_post '2016-05-31-automatic-title.adoc'
|
720
|
-
expect(post).not_to be_nil
|
721
|
-
if ::Jekyll::MIN_VERSION_3
|
722
|
-
expect(post.data['title']).to eql('Automatic Title')
|
723
|
-
else
|
724
|
-
expect(post.data['title']).to be_nil
|
725
|
-
end
|
726
|
-
file = output_file '2016/05/31/automatic-title.html'
|
727
|
-
expect(::File).to exist(file)
|
728
|
-
contents = ::File.read file
|
729
|
-
expect(contents).to include('<title>Automatic Title</title>')
|
730
|
-
end
|
731
|
-
|
732
|
-
it 'should set author of post to value defined in AsciiDoc header' do
|
733
|
-
post = find_post '2016-01-01-welcome.adoc'
|
734
|
-
expect(post).not_to be_nil
|
735
|
-
expect(post.data['author']).to eql('Henry Jekyll')
|
736
|
-
end
|
737
|
-
|
738
|
-
it 'should apply layout named post to post content if page-layout attribute not specified' do
|
739
|
-
file = output_file '2016/01/01/welcome.html'
|
740
|
-
expect(::File).to exist(file)
|
741
|
-
contents = ::File.read file
|
742
|
-
expect(contents).to include('<p>Footer for post layout.</p>')
|
743
|
-
end
|
744
|
-
|
745
|
-
it 'should apply layout named post to post content if page-layout attribute is empty' do
|
746
|
-
file = output_file '2016/01/02/empty-layout.html'
|
747
|
-
expect(::File).to exist(file)
|
748
|
-
contents = ::File.read file
|
749
|
-
expect(contents).to include('<p>Footer for post layout.</p>')
|
750
|
-
end
|
751
|
-
|
752
|
-
it 'should apply layout named post to post content if page-layout attribute has value _auto' do
|
753
|
-
file = output_file '2016/01/03/auto-layout.html'
|
754
|
-
expect(::File).to exist(file)
|
755
|
-
contents = ::File.read file
|
756
|
-
expect(contents).to include('<p>Footer for post layout.</p>')
|
757
|
-
end
|
758
|
-
|
759
|
-
it 'should apply custom layout to post content if page-layout attribute has non-empty string value' do
|
760
|
-
file = output_file '2016/01/04/custom-layout.html'
|
761
|
-
expect(::File).to exist(file)
|
762
|
-
contents = ::File.read file
|
763
|
-
expect(contents).to include('<p>Footer for custom layout.</p>')
|
764
|
-
end
|
765
|
-
|
766
|
-
it 'should not apply a layout to post content if page-layout attribute is nil' do
|
767
|
-
file = output_file '2016/01/05/nil-layout.html'
|
768
|
-
expect(::File).to exist(file)
|
769
|
-
contents = ::File.read file
|
770
|
-
expect(contents).to include(%(div class="paragraph">\n<p>Lorem ipsum.</p>\n</div>))
|
771
|
-
end
|
772
|
-
|
773
|
-
it 'should show the title above the content if the showtitle attribute is set' do
|
774
|
-
file = output_file '2016/04/01/show-me-the-title.html'
|
775
|
-
expect(::File).to exist(file)
|
776
|
-
contents = ::File.read file
|
777
|
-
expect(contents).to include('<title>Show Me the Title</title>')
|
778
|
-
expect(contents).to include('<h1 class="post-title">Show Me the Title</h1>')
|
779
|
-
expect(contents).to include('<h1>Show Me the Title</h1>')
|
780
|
-
end
|
781
|
-
|
782
|
-
it 'should interpret value of page attribute as YAML data' do
|
783
|
-
post = find_post '2016-02-01-post-with-categories.adoc'
|
784
|
-
expect(post).not_to be_nil
|
785
|
-
expect(post.data['categories']).to eql(['code', 'javascript'])
|
786
|
-
if ::Jekyll::MIN_VERSION_3
|
787
|
-
file = output_file 'code/javascript/2016/02/01/post-with-categories.html'
|
788
|
-
expect(::File).to exist(file)
|
789
|
-
end
|
790
|
-
end
|
791
|
-
|
792
|
-
it 'should merge singular variables with collection variables' do
|
793
|
-
post = find_post '2016-02-02-post-with-singular-vars.adoc'
|
794
|
-
expect(post).not_to be_nil
|
795
|
-
expect(post.data['categories']).to eql(['code', 'javascript', 'node'])
|
796
|
-
expect(post.data['tags']).to eql(['syntax', 'beginner', 'tip'])
|
797
|
-
if ::Jekyll::MIN_VERSION_3
|
798
|
-
file = output_file 'code/javascript/node/2016/02/02/post-with-singular-vars.html'
|
799
|
-
expect(::File).to exist(file)
|
800
|
-
end
|
801
|
-
end
|
802
|
-
|
803
|
-
it 'should convert revdate to local Time object and use it as date of post' do
|
804
|
-
# NOTE Time.parse without time zone assumes time zone of site
|
805
|
-
date = ::Time.parse('2016-06-15 10:30:00')
|
806
|
-
date = date.localtime if ::Jekyll::MIN_VERSION_3
|
807
|
-
slug = 'post-with-date'
|
808
|
-
post = find_post %(#{date.strftime '%Y-%m-%d'}-#{slug}.adoc)
|
809
|
-
expect(post).not_to be_nil
|
810
|
-
expect(post.data['date']).to be_a(::Time)
|
811
|
-
expect(post.data['date'].to_s).to eql(date.to_s)
|
812
|
-
file = output_file %(#{date.strftime '%Y/%m/%d'}/#{slug}.html)
|
813
|
-
expect(::File).to exist(file)
|
814
|
-
contents = ::File.read file
|
815
|
-
expect(contents).to include(%(<time class="date-published" datetime="#{date.xmlschema}">#{date.strftime '%B %d, %Y'}</time>))
|
816
|
-
end
|
817
|
-
|
818
|
-
it 'should convert revdate with time zone to local Time object and use it as date of post' do
|
819
|
-
date = ::Time.parse('2016-07-15 04:15:30 -0600')
|
820
|
-
date = date.localtime if ::Jekyll::MIN_VERSION_3
|
821
|
-
slug = 'post-with-date-and-tz'
|
822
|
-
post = find_post %(#{date.strftime '%Y-%m-%d'}-#{slug}.adoc)
|
823
|
-
expect(post).not_to be_nil
|
824
|
-
expect(post.data['date']).to be_a(::Time)
|
825
|
-
expect(post.data['date'].to_s).to eql(date.to_s)
|
826
|
-
file = output_file %(#{date.strftime '%Y/%m/%d'}/#{slug}.html)
|
827
|
-
expect(::File).to exist(file)
|
828
|
-
contents = ::File.read file
|
829
|
-
expect(contents).to include(%(<time class="date-published" datetime="#{date.xmlschema}">#{date.strftime '%B %d, %Y'}</time>))
|
830
|
-
end
|
831
|
-
|
832
|
-
it 'should convert revdate in revision line to local Time object and use it as date of post' do
|
833
|
-
date = ::Time.parse('2016-07-20 05:45:25 -0600')
|
834
|
-
date = date.localtime if ::Jekyll::MIN_VERSION_3
|
835
|
-
slug = 'post-with-date-in-revision-line'
|
836
|
-
post = find_post %(#{date.strftime '%Y-%m-%d'}-#{slug}.adoc)
|
837
|
-
expect(post).not_to be_nil
|
838
|
-
expect(post.data['date']).to be_a(::Time)
|
839
|
-
expect(post.data['date'].to_s).to eql(date.to_s)
|
840
|
-
file = output_file %(#{date.strftime '%Y/%m/%d'}/#{slug}.html)
|
841
|
-
expect(::File).to exist(file)
|
842
|
-
contents = ::File.read file
|
843
|
-
expect(contents).to include(%(<time class="date-published" datetime="#{date.xmlschema}">#{date.strftime '%B %d, %Y'}</time>))
|
844
|
-
end
|
845
|
-
|
846
|
-
it 'should process AsciiDoc header of draft post' do
|
847
|
-
draft = find_draft 'a-draft-post.adoc'
|
848
|
-
expect(draft).not_to be_nil
|
849
|
-
expect(draft.data['author']).to eql('Henry Jekyll')
|
850
|
-
expect(draft.data['tags']).to eql(['draft'])
|
851
|
-
file = output_file %(#{draft.date.strftime('%Y/%m/%d')}/a-draft-post.html)
|
852
|
-
expect(::File).to exist(file)
|
853
|
-
end
|
854
|
-
|
855
|
-
it 'should apply asciidocify filter to excerpt' do
|
856
|
-
file = output_file 'index.html'
|
857
|
-
expect(::File).to exist(file)
|
858
|
-
contents = ::File.read file
|
859
|
-
expect(contents).to include('<p class="excerpt">This is the <em>excerpt</em> of this post.</p>')
|
860
|
-
end
|
861
|
-
end
|
862
|
-
|
863
|
-
describe 'read error' do
|
864
|
-
let :name do
|
865
|
-
'read_error'
|
866
|
-
end
|
867
|
-
|
868
|
-
before :each do
|
869
|
-
::File.chmod 0000, (source_file 'unreadable.adoc')
|
870
|
-
site.process
|
871
|
-
end
|
872
|
-
|
873
|
-
after :each do
|
874
|
-
::File.chmod 0664, (source_file 'unreadable.adoc')
|
875
|
-
end
|
876
|
-
|
877
|
-
it 'should not fail when file cannot be read' do
|
878
|
-
file = output_file 'unreadable.html'
|
879
|
-
expect(::File).to exist(file)
|
880
|
-
contents = ::File.read file
|
881
|
-
expect(contents).to be_empty
|
882
|
-
end
|
883
|
-
end unless windows?
|
884
|
-
|
885
|
-
describe 'site with include relative to docdir' do
|
886
|
-
let :name do
|
887
|
-
'include_relative_to_docdir'
|
888
|
-
end
|
889
|
-
|
890
|
-
before(:each) { site.process }
|
891
|
-
|
892
|
-
it 'should not expand base_dir when base_dir config key has value :docdir' do
|
893
|
-
expect(site.config['asciidoctor'][:base_dir]).to eql(:docdir)
|
894
|
-
end
|
895
|
-
|
896
|
-
it 'should resolve include relative to docdir when base_dir config key has value :docdir' do
|
897
|
-
src_file = source_file 'about/index.adoc'
|
898
|
-
out_file = output_file 'about/index.html'
|
899
|
-
expect(::File).to exist(out_file)
|
900
|
-
contents = ::File.read out_file
|
901
|
-
expect(contents).to include('Doc Writer')
|
902
|
-
expect(contents).to include(%(docfile=#{src_file}))
|
903
|
-
expect(contents).to include(%(docdir=#{::File.dirname src_file}))
|
904
|
-
expect(contents).to include(%(outfile=#{out_file}))
|
905
|
-
expect(contents).to include(%(outdir=#{::File.dirname out_file}))
|
906
|
-
expect(contents).to include(%(outpath=/about/))
|
907
|
-
end
|
908
|
-
end if ::Jekyll::MIN_VERSION_3
|
909
|
-
|
910
|
-
describe 'site with include relative to root' do
|
911
|
-
let :name do
|
912
|
-
'include_relative_to_root'
|
913
|
-
end
|
914
|
-
|
915
|
-
let :config do
|
916
|
-
::Jekyll.configuration((fixture_site_params name).merge('source' => (::File.join (source_dir name), 'source')))
|
917
|
-
end
|
918
|
-
|
919
|
-
before(:each) {
|
920
|
-
@old_pwd = ::Dir.pwd
|
921
|
-
::Dir.chdir(source_dir name)
|
922
|
-
site.process
|
923
|
-
}
|
924
|
-
|
925
|
-
after(:each) {
|
926
|
-
::Dir.chdir(@old_pwd)
|
927
|
-
}
|
928
|
-
|
929
|
-
it 'should not set base_dir if base_dir config key has no value' do
|
930
|
-
expect(site.config['asciidoctor'].key? :base_dir).to be false
|
931
|
-
end
|
932
|
-
|
933
|
-
it 'should resolve include relative to root when base_dir is not set' do
|
934
|
-
src_file = source_file 'about/index.adoc'
|
935
|
-
out_file = output_file 'about/index.html'
|
936
|
-
expect(::File).to exist(out_file)
|
937
|
-
contents = ::File.read out_file
|
938
|
-
expect(contents).to include('Doc Writer')
|
939
|
-
expect(contents).to include(%(docdir=#{::Dir.pwd}))
|
940
|
-
if ::Jekyll::MIN_VERSION_3
|
941
|
-
expect(contents).to include(%(docfile=#{src_file}))
|
942
|
-
expect(contents).to include(%(outfile=#{out_file}))
|
943
|
-
expect(contents).to include(%(outdir=#{::File.dirname out_file}))
|
944
|
-
expect(contents).to include(%(outpath=/about/))
|
945
|
-
end
|
946
|
-
end
|
947
|
-
end
|
948
|
-
|
949
|
-
describe 'site with include relative to source' do
|
950
|
-
let :name do
|
951
|
-
'include_relative_to_source'
|
952
|
-
end
|
953
|
-
|
954
|
-
before(:each) { site.process }
|
955
|
-
|
956
|
-
it 'should expand base_dir to match site source when base_dir config key has value :source' do
|
957
|
-
expect(site.config['asciidoctor'][:base_dir]).to eql(site.source)
|
958
|
-
end
|
959
|
-
|
960
|
-
it 'should resolve include relative to source when base_dir config key has value :source' do
|
961
|
-
src_file = source_file 'about/index.adoc'
|
962
|
-
out_file = output_file 'about/index.html'
|
963
|
-
expect(::File).to exist(out_file)
|
964
|
-
contents = ::File.read out_file
|
965
|
-
expect(contents).to include('Doc Writer')
|
966
|
-
expect(contents).to include(%(docdir=#{site.source}))
|
967
|
-
if ::Jekyll::MIN_VERSION_3
|
968
|
-
expect(contents).to include(%(docfile=#{src_file}))
|
969
|
-
expect(contents).to include(%(outfile=#{out_file}))
|
970
|
-
expect(contents).to include(%(outdir=#{::File.dirname out_file}))
|
971
|
-
expect(contents).to include(%(outpath=/about/))
|
972
|
-
end
|
973
|
-
end
|
974
|
-
|
975
|
-
it 'should not process file that begins with an underscore' do
|
976
|
-
file = output_file 'about/_people.html'
|
977
|
-
expect(::File).not_to exist(file)
|
978
|
-
end
|
979
|
-
end
|
980
|
-
|
981
|
-
describe 'site with custom collection' do
|
982
|
-
let :name do
|
983
|
-
'with_custom_collection'
|
984
|
-
end
|
985
|
-
|
986
|
-
before(:each) { site.process }
|
987
|
-
|
988
|
-
it 'should decorate document in custom collection' do
|
989
|
-
doc = find_doc 'blueprint-a.adoc', 'blueprints'
|
990
|
-
expect(doc).not_to be_nil
|
991
|
-
expect(doc.data['title']).to eql('First Blueprint')
|
992
|
-
expect(doc.data['foo']).to eql('bar')
|
993
|
-
end
|
994
|
-
|
995
|
-
it 'should select layout that is based on the collection label by default' do
|
996
|
-
file = output_file 'blueprints/blueprint-a.html'
|
997
|
-
expect(::File).to exist(file)
|
998
|
-
contents = ::File.read file
|
999
|
-
expect(contents).to include('<p>Footer for blueprint layout.</p>')
|
1000
|
-
end
|
1001
|
-
|
1002
|
-
it 'should allow the layout to be customized' do
|
1003
|
-
file = output_file 'blueprints/blueprint-b.html'
|
1004
|
-
expect(::File).to exist(file)
|
1005
|
-
contents = ::File.read file
|
1006
|
-
expect(contents).to include('<p>Footer for default layout.</p>')
|
1007
|
-
end
|
1008
|
-
|
1009
|
-
it 'should set docdir for document in custom collection when base_dir config key has the value :docdir' do
|
1010
|
-
src_file = source_file '_blueprints/blueprint-b.adoc'
|
1011
|
-
out_file = output_file 'blueprints/blueprint-b.html'
|
1012
|
-
expect(::File).to exist(out_file)
|
1013
|
-
contents = ::File.read out_file
|
1014
|
-
expect(contents).to include(%(docfile=#{src_file}))
|
1015
|
-
expect(contents).to include(%(docdir=#{::File.dirname src_file}))
|
1016
|
-
expect(contents).to include(%(outfile=#{out_file}))
|
1017
|
-
expect(contents).to include(%(outdir=#{::File.dirname out_file}))
|
1018
|
-
expect(contents).to include(%(outpath=/blueprints/blueprint-b.html))
|
1019
|
-
end if ::Jekyll::MIN_VERSION_3
|
1020
|
-
end
|
1021
|
-
|
1022
|
-
describe 'pygments code highlighting' do
|
1023
|
-
let :name do
|
1024
|
-
'pygments_code_highlighting'
|
1025
|
-
end
|
1026
|
-
|
1027
|
-
before(:each) { site.process }
|
1028
|
-
|
1029
|
-
it 'should write the pygments stylesheet to the stylesdir' do
|
1030
|
-
src_file = source_file 'css/asciidoc-pygments.css'
|
1031
|
-
out_file = output_file 'css/asciidoc-pygments.css'
|
1032
|
-
begin
|
1033
|
-
expect(::File).to exist(src_file)
|
1034
|
-
expect(::File).to exist(out_file)
|
1035
|
-
src_content = ::File.read src_file
|
1036
|
-
out_content = ::File.read out_file
|
1037
|
-
expect(src_content).to eql(out_content)
|
1038
|
-
expect(src_content).to include('.pygments .tok-c')
|
1039
|
-
ensure
|
1040
|
-
if ::File.exist? src_file
|
1041
|
-
::File.delete src_file
|
1042
|
-
::Dir.rmdir(::File.dirname src_file)
|
1043
|
-
end
|
1044
|
-
end
|
1045
|
-
end
|
1046
|
-
|
1047
|
-
it 'should overwrite pygments stylesheet if style has changed' do
|
1048
|
-
src_file = source_file 'css/asciidoc-pygments.css'
|
1049
|
-
out_file = output_file 'css/asciidoc-pygments.css'
|
1050
|
-
begin
|
1051
|
-
src_content = ::File.read src_file
|
1052
|
-
out_content = ::File.read src_file
|
1053
|
-
attrs = site.config['asciidoctor'][:attributes]
|
1054
|
-
attrs['pygments-style'] = 'monokai'
|
1055
|
-
integrator.generate_pygments_stylesheet site, attrs
|
1056
|
-
expect(::File.read src_file).not_to eql(src_content)
|
1057
|
-
::Jekyll::StaticFile.reset_cache
|
1058
|
-
site.process
|
1059
|
-
new_out_content = ::File.read out_file
|
1060
|
-
expect(new_out_content).not_to eql(out_content)
|
1061
|
-
expect(new_out_content).to include('background-color: #49483e')
|
1062
|
-
ensure
|
1063
|
-
if ::File.exist? src_file
|
1064
|
-
::File.delete src_file
|
1065
|
-
::Dir.rmdir(::File.dirname src_file)
|
1066
|
-
end
|
1067
|
-
end
|
1068
|
-
end
|
1069
|
-
end
|
1070
|
-
|
1071
|
-
describe 'xhtml syntax' do
|
1072
|
-
let :name do
|
1073
|
-
'xhtml_syntax'
|
1074
|
-
end
|
1075
|
-
|
1076
|
-
before(:each) { site.process }
|
1077
|
-
|
1078
|
-
it 'should output xhtml if asciidoctor backend option is xhtml' do
|
1079
|
-
file = output_file 'home.html'
|
1080
|
-
expect(::File).to exist(file)
|
1081
|
-
contents = ::File.read file
|
1082
|
-
expect(contents).to include('<img src="/images/sunset.jpg" alt="Sunset" width="408" height="230"/>')
|
1083
|
-
end
|
1084
|
-
end
|
1085
|
-
|
1086
|
-
describe 'tocify filter' do
|
1087
|
-
let :name do
|
1088
|
-
'tocify_filter'
|
1089
|
-
end
|
1090
|
-
|
1091
|
-
before(:each) { site.process }
|
1092
|
-
|
1093
|
-
it 'should generate document outline when tocify_asciidoc filter is applied to page.document' do
|
1094
|
-
file = output_file 'index.html'
|
1095
|
-
expect(::File).to exist(file)
|
1096
|
-
contents = ::File.read file
|
1097
|
-
aside = contents.match(/<aside class="page-toc">.*<\/aside>/m)[0]
|
1098
|
-
expect(aside).to include('<ul class="sectlevel1">')
|
1099
|
-
expect(aside).to include('<a href="#major-section-a">Major Section A</a>')
|
1100
|
-
expect(aside).not_to include('Micro Section')
|
1101
|
-
end
|
1102
|
-
end if ::Jekyll::MIN_VERSION_3
|
1103
|
-
end
|