middleman-asciidoc 1.0.0.rc.7 → 1.0.0.rc.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +15 -9
- data/README.adoc +63 -13
- data/features/asciidoc-pages.feature +11 -1
- data/features/support/env.rb +4 -0
- data/fixtures/asciidoc-pages-app/config-page-attributes-abbrev.rb +2 -0
- data/fixtures/asciidoc-pages-app/source/layouts/inspect-page-data.erb +3 -1
- data/lib/middleman-asciidoc/extension.rb +11 -2
- data/lib/middleman-asciidoc/template.rb +24 -0
- data/lib/middleman-asciidoc/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa72cd0510e5297fab150560bad9f8442cc6d7c096b10251f660ab841d686107
|
4
|
+
data.tar.gz: 9fae6c014ec4b90ee98f8ec24f40eee7167f822d129001578f80cc138bc1d043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4726cd97933cce73a7dda15de14f1a22a42c2f822f91b8b2d337669e48610c8428cffd6531c1464ab172f29510eeb677734b7fa4bc64aa1c35743e8de1099cc3
|
7
|
+
data.tar.gz: 65e8dfa84591fac199e070ef733b34e4d1600c31b31801b6febcf95f21e0627883dbd5b62bdb9bb0fc7bc5c602574a82b075611fce9527873ce27b2064bba797
|
data/Gemfile
CHANGED
@@ -11,21 +11,27 @@ git 'https://github.com/mojavelinux/middleman.git', branch: 'jruby-compat-fix' d
|
|
11
11
|
end if RUBY_ENGINE == 'jruby'
|
12
12
|
|
13
13
|
# Build and doc tools
|
14
|
-
gem 'rake', '~>
|
15
|
-
gem 'yard', '~> 0.8', require: false
|
14
|
+
gem 'rake', '~> 12.3.0', require: false
|
16
15
|
|
17
16
|
# Test tools
|
18
|
-
gem '
|
19
|
-
gem '
|
20
|
-
|
17
|
+
gem 'aruba', '~> 0.14.0', require: false
|
18
|
+
gem 'capybara', '~> 2.16.0', require: false
|
19
|
+
if (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.2.0')
|
20
|
+
gem 'cucumber', '~> 2.99.0', require: false
|
21
|
+
else
|
22
|
+
gem 'cucumber', '~> 3.1.0', require: false
|
23
|
+
end
|
21
24
|
|
22
25
|
# Code coverage tools
|
23
|
-
gem 'simplecov', require: false
|
26
|
+
gem 'simplecov', '~> 0.15.0', require: false
|
24
27
|
|
25
28
|
# Additional libraries for testing
|
26
29
|
# Middleman itself (use for testing against development version)
|
27
30
|
#gem 'middleman-core', :github => 'middleman/middleman', :branch => 'master'
|
28
|
-
gem 'middleman-blog', '~> 4.0', require: false
|
31
|
+
gem 'middleman-blog', '~> 4.0.2', require: false
|
29
32
|
# NOTE middleman-cli required by middleman-blog
|
30
|
-
|
31
|
-
gem '
|
33
|
+
if (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.2.0')
|
34
|
+
gem 'middleman-cli', '~> 4.0.0', require: false
|
35
|
+
else
|
36
|
+
gem 'middleman-cli', '~> 4.2.0', require: false
|
37
|
+
end
|
data/README.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= AsciiDoc Extension for Middleman (powered by Asciidoctor)
|
2
2
|
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
|
3
|
-
v1.0.0.rc.
|
3
|
+
v1.0.0.rc.8, 2017-12-28
|
4
4
|
// Settings:
|
5
5
|
:idprefix:
|
6
6
|
:idseparator: -
|
@@ -34,15 +34,12 @@ endif::[]
|
|
34
34
|
:badge-gem: https://img.shields.io/gem/v/middleman-asciidoc.svg?label=gem
|
35
35
|
:uri-build: https://travis-ci.org/middleman/middleman-asciidoc
|
36
36
|
:badge-build: https://img.shields.io/travis/middleman/middleman-asciidoc/master.svg
|
37
|
-
:uri-deps: https://gemnasium.com/middleman/middleman-asciidoc
|
38
|
-
:badge-deps: https://img.shields.io/gemnasium/middleman/middleman-asciidoc.svg
|
39
37
|
//:uri-codequality: https://codeclimate.com/github/middleman/middleman-asciidoc
|
40
38
|
//:badge-codequality: https://codeclimate.com/github/middleman/middleman-asciidoc.png
|
41
39
|
|
42
40
|
ifdef::status[]
|
43
41
|
image:{badge-gem}[Gem Version Badge,link={uri-gem}]
|
44
42
|
image:{badge-build}[Build Status Badge,link={uri-build}]
|
45
|
-
image:{badge-deps}[Dependency Status Badge,link={uri-deps}]
|
46
43
|
//image:{badge-codequality}[Code Quality Badge,link={uri-codequality}]
|
47
44
|
endif::[]
|
48
45
|
|
@@ -115,7 +112,7 @@ end
|
|
115
112
|
The following option keys can be used to configure this extension.
|
116
113
|
With the exception of `layout`, these option keys map directly to options in the Asciidoctor API.
|
117
114
|
|
118
|
-
attributes (type: Hash or Array, default: [])::
|
115
|
+
attributes (type: Hash or String Array, default: [])::
|
119
116
|
Custom AsciiDoc attributes to pass to the processor.
|
120
117
|
The following built-in attributes are automatically appended to this collection.
|
121
118
|
(You can remove a built-in attribute by passing a custom attribute with the corresponding name prefixed with `-`).
|
@@ -147,14 +144,52 @@ If not specified, defaults to the document directory (i.e., `:docdir`).
|
|
147
144
|
To set the base directory to the source directory, use the keyword `:source` or the expression `app.source_dir`.
|
148
145
|
To leave the base directory undefined, use the value `nil`.
|
149
146
|
|
147
|
+
layout (type: String or Symbol, default: nil)::
|
148
|
+
The name of the default layout for AsciiDoc-based pages (pages processed by this extension, not including blog articles if a blog layout is specified).
|
149
|
+
|
150
150
|
safe (type: Symbol, default: :safe)::
|
151
151
|
The safe mode level under which to run the AsciiDoc processor.
|
152
152
|
|
153
|
-
|
154
|
-
|
153
|
+
template_dirs (type: String or String Array, default: nil)::
|
154
|
+
One or more directory paths (relative to the site root) where Asciidoctor converter templates should be discovered.
|
155
|
+
Asciidoctor templates can be used to customize the HTML generated for each node in the Asciidoctor document tree.
|
156
|
+
|
157
|
+
template_engine (type: String or Symbol, default: nil)::
|
158
|
+
The template engine filter to apply when scanning for Asciidoctor converter templates.
|
159
|
+
For example, to only discover Slim templates, set this to `:slim`.
|
160
|
+
|
161
|
+
template_engine_options (type: Hash, default: nil)::
|
162
|
+
Additional options to pass to the template engine when invoking the Asciidoctor converter templates.
|
163
|
+
Options must be indexed by the template engine name (e.g., `:slim`).
|
155
164
|
|
156
165
|
TIP: The full set of options can be seen on your preview server's config page at the path [.path]_/__middleman/config/_.
|
157
166
|
|
167
|
+
=== Configuring Specific Pages
|
168
|
+
|
169
|
+
You can pass extra attributes and other options to the AsciiDoc processor for a given page (or set of pages) using the `:renderer_options` option of the `page` directive (where the "`renderer`" is the AsciiDoc processor):
|
170
|
+
|
171
|
+
[source,ruby]
|
172
|
+
----
|
173
|
+
page 'manual', renderer_options: {
|
174
|
+
attributes: { 'sectanchors' => '' }
|
175
|
+
}
|
176
|
+
----
|
177
|
+
|
178
|
+
NOTE: The first argument to the `page` directive is the page ID.
|
179
|
+
The page ID is computed by starting with the path of the source file relative to the source directory, then removing the template extension (i.e., the AsciiDoc extension), then removing the `.html` extension, if present.
|
180
|
+
For example, the page ID for both [.path]_home.adoc_ and [.path]_home.html.adoc_ is `home`.
|
181
|
+
|
182
|
+
WARNING: Attributes passed to the page directive must be specified as a Hash and receive no additional processing.
|
183
|
+
|
184
|
+
You can add extra attributes to a page more concisely using the `:attributes` option on the page directive:
|
185
|
+
|
186
|
+
[source,ruby]
|
187
|
+
----
|
188
|
+
page 'manual', attributes: { 'sectanchors' => '' }
|
189
|
+
----
|
190
|
+
|
191
|
+
The `:attributes` option on the page directive takes precedence over the `:attributes` option in `:renderer_options`.
|
192
|
+
|
158
193
|
== Creating Pages
|
159
194
|
|
160
195
|
Each AsciiDoc file in the source directory (except for files that begin with `+_+` or which are located in a directory that begins with `+_+`) becomes a page in the site.
|
@@ -229,7 +264,7 @@ Alternately, you can set a default layout just for AsciiDoc-based pages (pages p
|
|
229
264
|
activate :asciidoc, layout: :name_of_layout
|
230
265
|
----
|
231
266
|
|
232
|
-
Finally, you can set the layout for a specific page or group of pages using the page directive.
|
267
|
+
Finally, you can set the layout for a specific page or group of pages using the `page` directive.
|
233
268
|
This is an alternate way to define front matter for a page.
|
234
269
|
|
235
270
|
[source,ruby]
|
@@ -237,10 +272,6 @@ This is an alternate way to define front matter for a page.
|
|
237
272
|
page 'home', layout: :name_of_layout
|
238
273
|
----
|
239
274
|
|
240
|
-
NOTE: The first argument to the `page` function is the page ID.
|
241
|
-
The page ID is computed starting from the path of the source file relative to the source directory, then removing the template extension (i.e., the AsciiDoc extension), then removing the `.html` extension, if present.
|
242
|
-
For example, the page ID for both [.path]_home.adoc_ and [.path]_home.html.adoc_ is `home`.
|
243
|
-
|
244
275
|
TIP: When you define the layout in [.path]_config.rb_, you can specify the value either as a String or a Symbol.
|
245
276
|
|
246
277
|
If you don't set the layout in [.path]_config.rb_, the default layout is considered unset.
|
@@ -284,6 +315,25 @@ You can do so in an ERB template using:
|
|
284
315
|
|
285
316
|
Other processor options, such as `:attributes`, are available from the `current_page.options[:renderer_options]` variable path.
|
286
317
|
|
318
|
+
==== Accessing the AsciiDoc Document From a Layout
|
319
|
+
|
320
|
+
You can access the document model for the current AsciiDoc-based page from the page layout as follows:
|
321
|
+
|
322
|
+
----
|
323
|
+
<%= current_page.data.document %>
|
324
|
+
----
|
325
|
+
|
326
|
+
This object is an instance of `Asciidoctor::Document`.
|
327
|
+
It can be used, for instance, to output a table of contents for the current page:
|
328
|
+
|
329
|
+
----
|
330
|
+
<% if (doc = current_page.data.document) %>
|
331
|
+
<%= doc.converter.convert doc, 'outline', toclevels: 3 %>
|
332
|
+
<% end %>
|
333
|
+
----
|
334
|
+
|
335
|
+
For more information about this API, refer to the http://www.rubydoc.info/gems/asciidoctor/Asciidoctor/Document[API documentation].
|
336
|
+
|
287
337
|
=== Ignoring a Page
|
288
338
|
|
289
339
|
In addition to the normal ignore filter in Middleman, you can also control whether a page is ignored from AsciiDoc.
|
@@ -490,7 +540,7 @@ In your site's [.path]_config.rb_ file, configure Asciidoctor to load the templa
|
|
490
540
|
|
491
541
|
[source,ruby]
|
492
542
|
----
|
493
|
-
activate :asciidoc, template_dirs: source/_asciidoc_templates
|
543
|
+
activate :asciidoc, template_dirs: 'source/_asciidoc_templates'
|
494
544
|
----
|
495
545
|
|
496
546
|
=== Step {counter:step}: Compose a Template
|
@@ -423,7 +423,7 @@ Feature: AsciiDoc Support
|
|
423
423
|
When I go to "/page-data.html"
|
424
424
|
Then I should see:
|
425
425
|
"""
|
426
|
-
<pre>{"id"=>"page-data", "title"=>"Page Data", "v-chrarray"=>["a", "b", "c"], "v-dblquote"=>"\"", "v-empty"=>"", "v-false"=>false, "v-hash"=>{"a"=>"a", "b"=>"b", "c"=>"c"}, "v-null"=>nil, "v-num"=>1, "v-numarray"=>[1, 2, 3], "v-quote"=>"'", "v-true"=>true}</pre>
|
426
|
+
<pre>{"document"=>"Page Data", "id"=>"page-data", "title"=>"Page Data", "v-chrarray"=>["a", "b", "c"], "v-dblquote"=>"\"", "v-empty"=>"", "v-false"=>false, "v-hash"=>{"a"=>"a", "b"=>"b", "c"=>"c"}, "v-null"=>nil, "v-num"=>1, "v-numarray"=>[1, 2, 3], "v-quote"=>"'", "v-true"=>true}</pre>
|
427
427
|
"""
|
428
428
|
|
429
429
|
Scenario: Promoting standard AsciiDoc attributes to page data
|
@@ -740,6 +740,16 @@ Feature: AsciiDoc Support
|
|
740
740
|
<h2 id="_section_a"><a class="anchor" href="#_section_a"></a>Section A</h2>
|
741
741
|
"""
|
742
742
|
|
743
|
+
Scenario: Setting custom attributes for a specific page abbrev
|
744
|
+
Given a fixture app "asciidoc-pages-app"
|
745
|
+
And app "asciidoc-pages-app" is using config "page-attributes-abbrev"
|
746
|
+
And the Server is running
|
747
|
+
When I go to "/with-sections.html"
|
748
|
+
Then I should see:
|
749
|
+
"""
|
750
|
+
<h2 id="_section_a"><a class="anchor" href="#_section_a"></a>Section A</h2>
|
751
|
+
"""
|
752
|
+
|
743
753
|
Scenario: Using custom templates to convert AsciiDoc document nodes to HTML
|
744
754
|
Given a fixture app "asciidoc-pages-app"
|
745
755
|
And a file named "config.rb" with:
|
data/features/support/env.rb
CHANGED
@@ -4,4 +4,8 @@ require 'simplecov' if ENV['COVERAGE'] == 'true'
|
|
4
4
|
ENV['TEST'] = 'true'
|
5
5
|
require 'middleman-core'
|
6
6
|
require 'middleman-core/step_definitions'
|
7
|
+
module SilenceArubaDeprecations
|
8
|
+
def deprecated msg; end
|
9
|
+
end
|
10
|
+
Aruba::Platforms::UnixPlatform.prepend SilenceArubaDeprecations
|
7
11
|
require File.join PROJECT_ROOT_PATH, 'lib', 'middleman-asciidoc'
|
@@ -4,6 +4,8 @@
|
|
4
4
|
<title><%= current_resource.data.title %></title>
|
5
5
|
</head>
|
6
6
|
<body>
|
7
|
-
<pre
|
7
|
+
<pre>{<%= current_resource.data.keys.sort.map {|k|
|
8
|
+
%("#{k}"=>#{(k == 'document' ? current_resource.data[k].doctitle : (JSON.load current_resource.data[k].to_json)).inspect })
|
9
|
+
} * ', ' %>}</pre>
|
8
10
|
</body>
|
9
11
|
</html>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'asciidoctor' unless defined? Asciidoctor
|
2
|
+
require 'middleman-asciidoc/template'
|
2
3
|
|
3
4
|
module Middleman
|
4
5
|
module AsciiDoc
|
@@ -97,9 +98,17 @@ module Middleman
|
|
97
98
|
page_attrs['docdir'] = (dir = ::File.dirname path)
|
98
99
|
page_attrs['docname'] = ::File.basename path, (page_attrs['docfilesuffix'] = ::File.extname path)
|
99
100
|
end
|
100
|
-
|
101
|
-
|
101
|
+
# handle options set using the page directive
|
102
|
+
# :attributes key on page directive takes precedence over :attributes key in :asciidoc option
|
103
|
+
initial_page_attrs = resource.options.delete :attributes
|
104
|
+
if ::Hash === (page_asciidoc_opts = resource.options.delete :asciidoc)
|
105
|
+
if ::Hash === initial_page_attrs ||
|
106
|
+
::Hash === (initial_page_attrs = page_asciidoc_opts.delete :attributes)
|
107
|
+
page_attrs = initial_page_attrs.merge page_attrs
|
108
|
+
end
|
109
|
+
page_asciidoc_opts[:attributes] = page_attrs
|
102
110
|
else
|
111
|
+
page_attrs = initial_page_attrs.merge page_attrs if ::Hash === initial_page_attrs
|
103
112
|
page_asciidoc_opts = { attributes: page_attrs }
|
104
113
|
end
|
105
114
|
opts, page = { renderer_options: page_asciidoc_opts }, {}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Enhance the default template for AsciiDoc to make the Asciidoctor::Document
|
2
|
+
# instance accessible to the current page via the variable path
|
3
|
+
# `current_page.data.document`.
|
4
|
+
module Middleman; module AsciiDoc
|
5
|
+
module Template
|
6
|
+
DEFAULT_OPTIONS = { header_footer: false }
|
7
|
+
|
8
|
+
def prepare
|
9
|
+
@document = ::Asciidoctor.load data, (DEFAULT_OPTIONS.merge options)
|
10
|
+
if ::Middleman::TemplateContext === (ctx = options[:context])
|
11
|
+
ctx.current_page.data.document = @document
|
12
|
+
end
|
13
|
+
@output = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def evaluate scope, locals
|
17
|
+
@output ||= @document.convert
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if (template_class = ::Tilt[:adoc])
|
22
|
+
template_class.send :prepend, Template
|
23
|
+
end
|
24
|
+
end; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-asciidoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.rc.
|
4
|
+
version: 1.0.0.rc.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- fixtures/asciidoc-blog-app/source/layouts/article.erb
|
76
76
|
- fixtures/asciidoc-blog-app/source/layouts/asciidoc_page.erb
|
77
77
|
- fixtures/asciidoc-pages-app/config-global-layout.rb
|
78
|
+
- fixtures/asciidoc-pages-app/config-page-attributes-abbrev.rb
|
78
79
|
- fixtures/asciidoc-pages-app/config-page-attributes.rb
|
79
80
|
- fixtures/asciidoc-pages-app/config-page-layout.rb
|
80
81
|
- fixtures/asciidoc-pages-app/config-set-asciidoc.rb
|
@@ -117,6 +118,7 @@ files:
|
|
117
118
|
- lib/middleman-asciidoc.rb
|
118
119
|
- lib/middleman-asciidoc/extension.rb
|
119
120
|
- lib/middleman-asciidoc/middleman_extension.rb
|
121
|
+
- lib/middleman-asciidoc/template.rb
|
120
122
|
- lib/middleman-asciidoc/version.rb
|
121
123
|
- middleman-asciidoc.gemspec
|
122
124
|
homepage: https://github.com/middleman/middleman-asciidoc
|
@@ -139,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
141
|
version: 1.3.1
|
140
142
|
requirements: []
|
141
143
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.7.
|
144
|
+
rubygems_version: 2.7.4
|
143
145
|
signing_key:
|
144
146
|
specification_version: 4
|
145
147
|
summary: AsciiDoc support for Middleman
|
@@ -166,6 +168,7 @@ test_files:
|
|
166
168
|
- fixtures/asciidoc-blog-app/source/layouts/article.erb
|
167
169
|
- fixtures/asciidoc-blog-app/source/layouts/asciidoc_page.erb
|
168
170
|
- fixtures/asciidoc-pages-app/config-global-layout.rb
|
171
|
+
- fixtures/asciidoc-pages-app/config-page-attributes-abbrev.rb
|
169
172
|
- fixtures/asciidoc-pages-app/config-page-attributes.rb
|
170
173
|
- fixtures/asciidoc-pages-app/config-page-layout.rb
|
171
174
|
- fixtures/asciidoc-pages-app/config-set-asciidoc.rb
|