middleman-asciidoc 1.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +4 -0
- data/.gitignore +5 -0
- data/.ruby-version +1 -0
- data/.travis.yml +13 -0
- data/CHANGELOG.adoc +14 -0
- data/CONTRIBUTING.adoc +77 -0
- data/Gemfile +19 -0
- data/LICENSE.adoc +23 -0
- data/README.adoc +110 -0
- data/Rakefile +36 -0
- data/features/asciidoc.feature +247 -0
- data/features/support/env.rb +5 -0
- data/fixtures/asciidoc-app/config.rb +1 -0
- data/fixtures/asciidoc-app/source/_include.adoc +1 -0
- data/fixtures/asciidoc-app/source/code.adoc +3 -0
- data/fixtures/asciidoc-app/source/custom-attribute.adoc +4 -0
- data/fixtures/asciidoc-app/source/custom-imagesdir.adoc +3 -0
- data/fixtures/asciidoc-app/source/gallery.adoc +1 -0
- data/fixtures/asciidoc-app/source/hello-no-layout.adoc +2 -0
- data/fixtures/asciidoc-app/source/hello-with-extension.html.adoc +4 -0
- data/fixtures/asciidoc-app/source/hello-with-front-matter.adoc +5 -0
- data/fixtures/asciidoc-app/source/hello-with-layout.adoc +2 -0
- data/fixtures/asciidoc-app/source/hello-with-title.adoc +5 -0
- data/fixtures/asciidoc-app/source/hello.adoc +4 -0
- data/fixtures/asciidoc-app/source/images/tiger.gif +0 -0
- data/fixtures/asciidoc-app/source/layouts/default.erb +9 -0
- data/fixtures/asciidoc-app/source/manual/_chapters/ch01.adoc +3 -0
- data/fixtures/asciidoc-app/source/manual/index.adoc +4 -0
- data/fixtures/asciidoc-app/source/master.adoc +3 -0
- data/lib/middleman-asciidoc.rb +7 -0
- data/lib/middleman-asciidoc/extension.rb +125 -0
- data/lib/middleman-asciidoc/middleman_extension.rb +1 -0
- data/lib/middleman-asciidoc/version.rb +5 -0
- data/middleman-asciidoc.gemspec +24 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fc3455f0e1c583f75954af62f8621b8c08305350
|
4
|
+
data.tar.gz: c496012990146cc6c64acdbe4e87c0717d73e25a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eeaf70b416b9a8193e49159837265644d9a1ba2db52e5482128bbe9669f859439f3dc0985441f00866a822ec1584defd97b51c14f90cf14670806b3da0afde24
|
7
|
+
data.tar.gz: d27d350a0dcecca3edac3ba3d9bae9cb381faaa3e1f14f271b66eee95d91fef7fccb939a97017eef7adcb24c86de0f25027646791b365a54b793038254de409e
|
data/.bundle/config
ADDED
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.0
|
data/.travis.yml
ADDED
data/CHANGELOG.adoc
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
= Middleman AsciiDoc Changelog
|
2
|
+
|
3
|
+
== 1.0.0 (pending) - @mojavelinux
|
4
|
+
|
5
|
+
* Split AsciiDoc support out of Middleman core into its own extension.
|
6
|
+
|
7
|
+
//^
|
8
|
+
Distribution Packages::
|
9
|
+
|
10
|
+
* http://rubygems.org/gems/middleman-asciidoc[RubyGem (middleman-asciidoc)]
|
11
|
+
|
12
|
+
https://github.com/middleman/middleman-asciidoc/issues?q=milestone%3Av1.0.0[issues resolved] |
|
13
|
+
https://github.com/middleman/middleman-asciidoc/releases/tag/v1.0.0[git tag] |
|
14
|
+
https://github.com/middleman/middleman-asciidoc/compare/1e7871a3237320239f31da10d982174f84497daa...v1.0.0[full diff]
|
data/CONTRIBUTING.adoc
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
= Contributing
|
2
|
+
:uri-free-software: http://www.fsf.org/licensing/essays/free-sw.html
|
3
|
+
:uri-repo: https://github.com/middleman/middleman-asciidoc
|
4
|
+
:uri-issues: {uri-repo}/issues
|
5
|
+
:uri-fork: http://help.github.com/fork-a-repo/
|
6
|
+
:uri-branch: http://learn.github.com/p/branching.html
|
7
|
+
:uri-pr: http://help.github.com/send-pull-requests/
|
8
|
+
|
9
|
+
In the spirit of {uri-free-software}[free software], *everyone* is encouraged to help improve this project.
|
10
|
+
This guide suggests ways to get involved and covers the workflow the development team uses for submitting and managing contributions.
|
11
|
+
|
12
|
+
== Get involved
|
13
|
+
|
14
|
+
Thanks for stopping by!
|
15
|
+
Now's your chance to get involved.
|
16
|
+
Here are some ways _you_ can contribute:
|
17
|
+
|
18
|
+
- Use alpha, beta, and prerelease versions
|
19
|
+
* We love testers!
|
20
|
+
- Report bugs
|
21
|
+
* Don't be shy. Let us know when things aren't working. Don't suffer in silence.
|
22
|
+
- Suggest new features
|
23
|
+
* Innovation FTW!
|
24
|
+
- Write, edit or review documentation
|
25
|
+
* Others want to know how it works too. Once you figure it out, please share!
|
26
|
+
- Add specifications (i.e., cucumber tests)
|
27
|
+
- Write code
|
28
|
+
* *No patch is too small!* (e.g., fix typos, add comments, clean up inconsistent whitespace)
|
29
|
+
- Refactor code
|
30
|
+
- Resolve {uri-issues}[issues]
|
31
|
+
- Review open pull requests
|
32
|
+
|
33
|
+
== Our development process
|
34
|
+
|
35
|
+
This section covers the workflow the development team uses when making contributions.
|
36
|
+
If you follow these recommendations, you'll maximize the chance of your contribution being accepted in a timely manner.
|
37
|
+
|
38
|
+
=== Submitting an issue
|
39
|
+
|
40
|
+
We use the {uri-issues}[GitHub issue tracker] to track bugs and features.
|
41
|
+
Before submitting a bug report or feature request, check to make sure an issue hasn't already been submitted for it.
|
42
|
+
|
43
|
+
When submitting a bug report, please include any details that may be necessary to reproduce the bug, including the version of the gem, the version of Ruby you are using and your operating system.
|
44
|
+
Ideally, a bug report should include a pull request with a failing cucumber test.
|
45
|
+
|
46
|
+
=== Submitting a pull request (GitHub Flow)
|
47
|
+
|
48
|
+
. {uri-fork}[Fork the repository.]
|
49
|
+
+
|
50
|
+
[subs=attributes+]
|
51
|
+
$ git clone {uri-repo}
|
52
|
+
|
53
|
+
. {uri-branch}[Create a branch to manage your changes.]
|
54
|
+
|
55
|
+
$ git checkout -b issue-n -t origin/master
|
56
|
+
+
|
57
|
+
Please name the branch `issue-n` (where "n" is the issue number).
|
58
|
+
|
59
|
+
. Implement your change and add a cucumber test to verify it.
|
60
|
+
. Run the tests.
|
61
|
+
|
62
|
+
$ bundle exec rake cucumber
|
63
|
+
+
|
64
|
+
If your tests don't pass, return to step 3.
|
65
|
+
|
66
|
+
. Add, commit, and push your changes.
|
67
|
+
* Your commit message should start with `resolves #n` (where "n" is the issue number)
|
68
|
+
* When your change is merged, the issue will be automatically closed.
|
69
|
+
. {uri-pr}[Submit a pull request.]
|
70
|
+
|
71
|
+
=== Message to project maintainers
|
72
|
+
|
73
|
+
If you're a project maintainer, please follow the GitHub Flow instead of pushing directly to master, especially when resolving an issue.
|
74
|
+
And please make sure to push the branch to your own fork when creating a pull request, not the upstream repository.
|
75
|
+
|
76
|
+
You can merge your own pull request, but please allow a period of time for commit (24 hours is the general rule of thumb).
|
77
|
+
This timeout period provides an opportunity for code review and encourages participation.
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Runtime dependencies are defined in middleman-asciidoc.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# Build and doc tools
|
7
|
+
gem 'rake', '~> 10.3', require: false
|
8
|
+
gem 'yard', '~> 0.8', require: false
|
9
|
+
|
10
|
+
# Test tools
|
11
|
+
gem 'cucumber', '~> 2.0', require: false
|
12
|
+
gem 'aruba', '~> 0.7.4', require: false
|
13
|
+
|
14
|
+
# Code quality tools
|
15
|
+
gem 'cane', platforms: [:mri_19, :mri_20], require: false
|
16
|
+
|
17
|
+
# Middleman itself (use for testing against development version)
|
18
|
+
#gem 'middleman-core', :github => 'middleman/middleman', :branch => 'master'
|
19
|
+
gem 'listen', '~> 3.0.0', require: false # see https://github.com/middleman/middleman/pull/1891
|
data/LICENSE.adoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
.MIT License
|
2
|
+
....
|
3
|
+
Copyright (C) 2014-2016 Dan Allen and the Asciidoctor Project
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
....
|
data/README.adoc
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
= AsciiDoc Support for Middleman 4
|
2
|
+
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
|
3
|
+
v1.0.0.rc.1, 2016-05-16
|
4
|
+
// Settings:
|
5
|
+
:idprefix:
|
6
|
+
:idseparator: -
|
7
|
+
ifndef::env-github[:icons: font]
|
8
|
+
ifdef::env-github[]
|
9
|
+
:status:
|
10
|
+
:outfilesuffix: .adoc
|
11
|
+
:note-caption: :paperclip:
|
12
|
+
endif::[]
|
13
|
+
// URIs:
|
14
|
+
:uri-repo: https://github.com/middleman/middleman-asciidoc
|
15
|
+
:uri-middleman: https://middlemanapp.com
|
16
|
+
:uri-asciidoc: http://asciidoc.org
|
17
|
+
:uri-asciidoctor: http://asciidoctor.org
|
18
|
+
:uri-gem: https://rubygems.org/gems/middleman-asciidoc
|
19
|
+
:badge-gem: https://badge.fury.io/rb/middleman-asciidoc.png
|
20
|
+
:uri-buildstatus: http://travis-ci.org/middleman/middleman-asciidoc
|
21
|
+
:badge-buildstatus: https://travis-ci.org/middleman/middleman-asciidoc.png
|
22
|
+
:uri-depstatus: https://gemnasium.com/middleman/middleman-asciidoc
|
23
|
+
:badge-depstatus: https://gemnasium.com/middleman/middleman-asciidoc.png?travis
|
24
|
+
:uri-codequality: https://codeclimate.com/github/middleman/middleman-asciidoc
|
25
|
+
:badge-codequality: https://codeclimate.com/github/middleman/middleman-asciidoc.png
|
26
|
+
|
27
|
+
Middleman AsciiDoc (gem: *middleman-asciidoc*) is an extension for the {uri-middleman}[Middleman] static site generator that adds support for the {uri-asciidoc}[AsciiDoc] markup language powered by {uri-asciidoctor}[Asciidoctor].
|
28
|
+
|
29
|
+
NOTE: This extension is designed for Middleman >= 4.0.0.
|
30
|
+
Prior to Middleman 4, AsciiDoc support was provided by Middleman out of the box.
|
31
|
+
|
32
|
+
ifdef::status[]
|
33
|
+
image:{badge-gem}[Gem Version,link={uri-gem}]
|
34
|
+
image:{badge-buildstatus}[Build Status,link={uri-buildstatus}]
|
35
|
+
image:{badge-depstatus}[Dependency Status,link={badge-depstatus}]
|
36
|
+
//image:{badge-codequality}[Code Quality,link={badge-codequality}]
|
37
|
+
endif::[]
|
38
|
+
|
39
|
+
== Installation
|
40
|
+
|
41
|
+
If you're just getting started, install the Middleman gem:
|
42
|
+
|
43
|
+
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install middleman
|
44
|
+
|
45
|
+
then generate a new project:
|
46
|
+
|
47
|
+
$ middleman init MY_PROJECT
|
48
|
+
|
49
|
+
If you're working with an existing project, you can skip the previous steps.
|
50
|
+
|
51
|
+
Finally, add `gem 'middleman-asciidoc'` to your [path]_Gemfile_ and run `bundle`.
|
52
|
+
|
53
|
+
NOTE: Each AsciiDoc file in the source directory (except files that begin with `+_+` or are in a directory that begins with `+_+`) becomes a page in the site.
|
54
|
+
AsciiDoc files can have the file extension `.adoc` or `.html.adoc`.
|
55
|
+
These extensions are stripped and replaced with the value of the `outfilesuffix` attribute, which defaults to `.html`.
|
56
|
+
(For details, see the discussion in https://github.com/middleman/middleman-asciidoc/issues/7[issue #7]).
|
57
|
+
|
58
|
+
== Configuration
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
activate :asciidoc
|
62
|
+
```
|
63
|
+
|
64
|
+
You can also pass AsciiDoc configuration options to the underlying Asciidoctor processor:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
activate :asciidoc, attributes: %w(foo=bar)
|
68
|
+
```
|
69
|
+
|
70
|
+
The full set of options can be seen on your preview server's config page at the path [path]_/__middleman/config/_.
|
71
|
+
|
72
|
+
== Community
|
73
|
+
|
74
|
+
The official community forum for Middleman can be found at http://forum.middlemanapp.com.
|
75
|
+
For questions related to this extension or general questions about AsciiDoc, please post to the Asciidoctor discussion list at http://discuss.asciidoctor.org.
|
76
|
+
|
77
|
+
== Bug reports
|
78
|
+
|
79
|
+
Github Issues are used for managing bug reports and feature requests.
|
80
|
+
If you run into issues, please search the issues and submit new problems in the project's https://github.com/middleman/middleman-asciidoc/issues[issue tracker].
|
81
|
+
|
82
|
+
The best way to get quick responses to your issues and swift fixes to your bugs is to submit detailed bug reports, include test cases and respond to developer questions in a timely manner.
|
83
|
+
Even better, if you know Ruby, you can submit https://help.github.com/articles/using-pull-requests[pull requests] containing Cucumber Features which describe how your feature should work or exploit the bug you are submitting.
|
84
|
+
|
85
|
+
== How to run tests
|
86
|
+
|
87
|
+
The tests are based on Cucumber.
|
88
|
+
Here's how to clone the project and run the tests.
|
89
|
+
|
90
|
+
. Clone the repository:
|
91
|
+
|
92
|
+
$ git clone https://github.com/middleman/middleman-asciidoc.git && cd middleman-asciidoc
|
93
|
+
|
94
|
+
. Install Bundler (if not already installed):
|
95
|
+
|
96
|
+
$ gem install bundler
|
97
|
+
|
98
|
+
. Run Bundler (from the project root) to install the gem dependencies:
|
99
|
+
|
100
|
+
$ bundle
|
101
|
+
|
102
|
+
. Run test cases (based on Cucumber) using Rake:
|
103
|
+
|
104
|
+
$ bundle exec rake cucumber
|
105
|
+
|
106
|
+
== Copyright
|
107
|
+
|
108
|
+
Copyright (C) 2014-2016 Dan Allen and the Asciidoctor Project.
|
109
|
+
Free use of this software is granted under the terms of the MIT License.
|
110
|
+
For the full text of the license, see the <<LICENSE.adoc#,LICENSE>> file.
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
rescue LoadError => e
|
4
|
+
warn.message
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'cucumber/rake/task'
|
8
|
+
|
9
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
10
|
+
exempt_tags = ''
|
11
|
+
exempt_tags << '--tags ~@nojava ' if RUBY_PLATFORM == 'java'
|
12
|
+
t.cucumber_opts = %(--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'})
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'rake/clean'
|
16
|
+
|
17
|
+
task :test => ['cucumber']
|
18
|
+
task :default => ['test', 'build']
|
19
|
+
|
20
|
+
begin
|
21
|
+
require 'cane/rake_task'
|
22
|
+
|
23
|
+
desc 'Run cane to check quality metrics'
|
24
|
+
Cane::RakeTask.new(:quality) do |cane|
|
25
|
+
cane.no_style = true
|
26
|
+
cane.no_doc = true
|
27
|
+
cane.abc_glob = 'lib/middleman-asciidoc/**/*.rb'
|
28
|
+
end
|
29
|
+
rescue LoadError
|
30
|
+
# warn 'cane not available, quality task not provided.'
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Build HTML documentation'
|
34
|
+
task :doc do
|
35
|
+
sh 'bundle exec yard'
|
36
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
Feature: AsciiDoc Support
|
2
|
+
In order to test included AsciiDoc support
|
3
|
+
|
4
|
+
Scenario: Rendering html
|
5
|
+
Given the Server is running at "asciidoc-app"
|
6
|
+
When I go to "/hello.html"
|
7
|
+
Then I should see:
|
8
|
+
"""
|
9
|
+
<div class="paragraph">
|
10
|
+
<p>Hello, AsciiDoc!
|
11
|
+
Middleman, I am in you.</p>
|
12
|
+
</div>
|
13
|
+
"""
|
14
|
+
|
15
|
+
Scenario: Rendering html with double file extension
|
16
|
+
Given the Server is running at "asciidoc-app"
|
17
|
+
When I go to "/hello-with-extension.html"
|
18
|
+
Then I should see:
|
19
|
+
"""
|
20
|
+
<div class="paragraph">
|
21
|
+
<p>Hello, AsciiDoc!
|
22
|
+
Middleman, I am in you.</p>
|
23
|
+
</div>
|
24
|
+
"""
|
25
|
+
|
26
|
+
Scenario: Rendering html with default layout
|
27
|
+
Given a fixture app "asciidoc-app"
|
28
|
+
And a file named "config.rb" with:
|
29
|
+
"""
|
30
|
+
activate :asciidoc
|
31
|
+
set :layout, :default
|
32
|
+
"""
|
33
|
+
Given the Server is running at "asciidoc-app"
|
34
|
+
When I go to "/hello.html"
|
35
|
+
Then I should see:
|
36
|
+
"""
|
37
|
+
<!DOCTYPE html>
|
38
|
+
<html>
|
39
|
+
<head>
|
40
|
+
<title>Fallback</title>
|
41
|
+
</head>
|
42
|
+
<body>
|
43
|
+
<div class="paragraph">
|
44
|
+
<p>Hello, AsciiDoc!
|
45
|
+
Middleman, I am in you.</p>
|
46
|
+
</div>
|
47
|
+
</body>
|
48
|
+
</html>
|
49
|
+
"""
|
50
|
+
|
51
|
+
Scenario: Rendering html with explicit layout
|
52
|
+
Given the Server is running at "asciidoc-app"
|
53
|
+
When I go to "/hello-with-layout.html"
|
54
|
+
Then I should see:
|
55
|
+
"""
|
56
|
+
<!DOCTYPE html>
|
57
|
+
<html>
|
58
|
+
<head>
|
59
|
+
<title>Fallback</title>
|
60
|
+
</head>
|
61
|
+
<body>
|
62
|
+
<div class="paragraph">
|
63
|
+
<p>Hello, AsciiDoc!</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
67
|
+
"""
|
68
|
+
|
69
|
+
Scenario: Rendering html with no layout
|
70
|
+
Given the Server is running at "asciidoc-app"
|
71
|
+
When I go to "/hello-no-layout.html"
|
72
|
+
Then I should see:
|
73
|
+
"""
|
74
|
+
<div class="paragraph">
|
75
|
+
<p>Hello, AsciiDoc!</p>
|
76
|
+
</div>
|
77
|
+
"""
|
78
|
+
|
79
|
+
Scenario: Rendering html using title from document
|
80
|
+
Given the Server is running at "asciidoc-app"
|
81
|
+
When I go to "/hello-with-title.html"
|
82
|
+
Then I should see:
|
83
|
+
"""
|
84
|
+
<!DOCTYPE html>
|
85
|
+
<html>
|
86
|
+
<head>
|
87
|
+
<title>Page Title</title>
|
88
|
+
</head>
|
89
|
+
<body>
|
90
|
+
<h1>Page Title</h1>
|
91
|
+
<div class="paragraph">
|
92
|
+
<p>Hello, AsciiDoc!</p>
|
93
|
+
</div>
|
94
|
+
</body>
|
95
|
+
</html>
|
96
|
+
"""
|
97
|
+
Scenario: Rendering html using title from document
|
98
|
+
Given the Server is running at "asciidoc-app"
|
99
|
+
When I go to "/hello-with-title.html"
|
100
|
+
Then I should see:
|
101
|
+
"""
|
102
|
+
<!DOCTYPE html>
|
103
|
+
<html>
|
104
|
+
<head>
|
105
|
+
<title>Page Title</title>
|
106
|
+
</head>
|
107
|
+
<body>
|
108
|
+
<h1>Page Title</h1>
|
109
|
+
<div class="paragraph">
|
110
|
+
<p>Hello, AsciiDoc!</p>
|
111
|
+
</div>
|
112
|
+
</body>
|
113
|
+
</html>
|
114
|
+
"""
|
115
|
+
|
116
|
+
Scenario: Rendering html with title and layout from front matter
|
117
|
+
Given the Server is running at "asciidoc-app"
|
118
|
+
When I go to "/hello-with-front-matter.html"
|
119
|
+
Then I should see:
|
120
|
+
"""
|
121
|
+
<!DOCTYPE html>
|
122
|
+
<html>
|
123
|
+
<head>
|
124
|
+
<title>Page Title</title>
|
125
|
+
</head>
|
126
|
+
<body>
|
127
|
+
<div class="paragraph">
|
128
|
+
<p>Hello, AsciiDoc!</p>
|
129
|
+
</div>
|
130
|
+
</body>
|
131
|
+
</html>
|
132
|
+
"""
|
133
|
+
|
134
|
+
Scenario: Including a file relative to source root
|
135
|
+
Given the Server is running at "asciidoc-app"
|
136
|
+
When I go to "/master.html"
|
137
|
+
Then I should see:
|
138
|
+
"""
|
139
|
+
<div class="literalblock">
|
140
|
+
<div class="content">
|
141
|
+
<pre>I'm included content.</pre>
|
142
|
+
</div>
|
143
|
+
"""
|
144
|
+
|
145
|
+
Scenario: Including a file relative to document in subdirectory
|
146
|
+
Given the Server is running at "asciidoc-app"
|
147
|
+
When I go to "/manual/index.html"
|
148
|
+
Then I should see:
|
149
|
+
"""
|
150
|
+
<h1>Manual</h1>
|
151
|
+
<div class="sect1">
|
152
|
+
<h2 id="_chapter_01">Chapter 01</h2>
|
153
|
+
<div class="sectionbody">
|
154
|
+
<div class="paragraph">
|
155
|
+
<p>content</p>
|
156
|
+
</div>
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
"""
|
160
|
+
|
161
|
+
Scenario: Including a file relative to document in subdirectory when base_dir is set
|
162
|
+
Given a fixture app "asciidoc-app"
|
163
|
+
And a file named "config.rb" with:
|
164
|
+
"""
|
165
|
+
activate :asciidoc, base_dir: app.source_dir.expand_path
|
166
|
+
"""
|
167
|
+
Given the Server is running at "asciidoc-app"
|
168
|
+
When I go to "/manual/index.html"
|
169
|
+
Then I should see:
|
170
|
+
"""
|
171
|
+
<p>Unresolved directive in <stdin> - include::_chapters/ch01.adoc[]</p>
|
172
|
+
"""
|
173
|
+
|
174
|
+
Scenario: Linking to an image
|
175
|
+
Given the Server is running at "asciidoc-app"
|
176
|
+
When I go to "/gallery.html"
|
177
|
+
Then I should see:
|
178
|
+
"""
|
179
|
+
<div class="imageblock">
|
180
|
+
<div class="content">
|
181
|
+
<img src="/images/tiger.gif" alt="tiger">
|
182
|
+
</div>
|
183
|
+
"""
|
184
|
+
|
185
|
+
Scenario: Linking to an image with a custom imagesdir
|
186
|
+
Given the Server is running at "asciidoc-app"
|
187
|
+
When I go to "/custom-imagesdir.html"
|
188
|
+
Then I should see:
|
189
|
+
"""
|
190
|
+
<div class="imageblock">
|
191
|
+
<div class="content">
|
192
|
+
<img src="img/tiger.gif" alt="tiger">
|
193
|
+
</div>
|
194
|
+
"""
|
195
|
+
|
196
|
+
Scenario: imagesdir configuration should override imagesdir defined in page
|
197
|
+
Given a fixture app "asciidoc-app"
|
198
|
+
And a file named "config.rb" with:
|
199
|
+
"""
|
200
|
+
activate :asciidoc, attributes: %w(imagesdir=/img)
|
201
|
+
"""
|
202
|
+
Given the Server is running at "asciidoc-app"
|
203
|
+
When I go to "/custom-imagesdir.html"
|
204
|
+
Then I should see:
|
205
|
+
"""
|
206
|
+
<div class="imageblock">
|
207
|
+
<div class="content">
|
208
|
+
<img src="/img/tiger.gif" alt="tiger">
|
209
|
+
</div>
|
210
|
+
"""
|
211
|
+
|
212
|
+
Scenario: Configuring custom AsciiDoc attributes as Array
|
213
|
+
Given a fixture app "asciidoc-app"
|
214
|
+
And a file named "config.rb" with:
|
215
|
+
"""
|
216
|
+
activate :asciidoc, attributes: %w(foo=bar)
|
217
|
+
"""
|
218
|
+
Given the Server is running at "asciidoc-app"
|
219
|
+
When I go to "/custom-attribute.html"
|
220
|
+
Then I should see "bar"
|
221
|
+
|
222
|
+
Scenario: Configuring custom AsciiDoc attributes as Hash
|
223
|
+
Given a fixture app "asciidoc-app"
|
224
|
+
And a file named "config.rb" with:
|
225
|
+
"""
|
226
|
+
activate :asciidoc, attributes: { 'foo' => 'bar' }
|
227
|
+
"""
|
228
|
+
Given the Server is running at "asciidoc-app"
|
229
|
+
When I go to "/custom-attribute.html"
|
230
|
+
Then I should see "bar"
|
231
|
+
|
232
|
+
Scenario: Highlighting source code
|
233
|
+
Given a fixture app "asciidoc-app"
|
234
|
+
And a file named "config.rb" with:
|
235
|
+
"""
|
236
|
+
activate :asciidoc, attributes: %w(source-highlighter=html-pipeline)
|
237
|
+
"""
|
238
|
+
Given the Server is running at "asciidoc-app"
|
239
|
+
When I go to "/code.html"
|
240
|
+
Then I should see:
|
241
|
+
"""
|
242
|
+
<div class="listingblock">
|
243
|
+
<div class="content">
|
244
|
+
<pre lang="ruby"><code>puts "Is this mic on?"</code></pre>
|
245
|
+
</div>
|
246
|
+
</div>
|
247
|
+
"""
|
@@ -0,0 +1 @@
|
|
1
|
+
activate :asciidoc
|
@@ -0,0 +1 @@
|
|
1
|
+
I'm included content.
|
@@ -0,0 +1 @@
|
|
1
|
+
image::tiger.gif[]
|
Binary file
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'asciidoctor' unless defined? Asciidoctor
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module AsciiDoc
|
5
|
+
class AsciiDocExtension < ::Middleman::Extension
|
6
|
+
IMPLICIT_ATTRIBUTES = {
|
7
|
+
'env' => 'site',
|
8
|
+
'env-site' => '',
|
9
|
+
'site-gen' => 'middleman',
|
10
|
+
'site-gen-middleman' => '',
|
11
|
+
'builder' => 'middleman',
|
12
|
+
'builder-middleman' => '',
|
13
|
+
'middleman-version' => ::Middleman::VERSION
|
14
|
+
}
|
15
|
+
option :attributes, [], 'Custom AsciiDoc attributes (Hash or Array)'
|
16
|
+
option :backend, :html5, 'Moniker used to select output format (Symbol)'
|
17
|
+
option :base_dir, nil, 'Base directory to use for the current AsciiDoc document; if nil, defaults to docdir (String)'
|
18
|
+
option :safe, :safe, 'Safe mode level (Symbol)'
|
19
|
+
|
20
|
+
def initialize app, options_hash = {}, &block
|
21
|
+
super
|
22
|
+
app.config.define_setting :asciidoc, {}, 'AsciiDoc processor options (Hash)'
|
23
|
+
# NOTE support global :asciidoc_attributes setting for backwards compatibility
|
24
|
+
app.config.define_setting :asciidoc_attributes, [], 'Custom AsciiDoc attributes (Hash or Array)'
|
25
|
+
end
|
26
|
+
|
27
|
+
# NOTE options passed to activate take precedence (e.g., activate :asciidoc, attributes: ['foo=bar'])
|
28
|
+
def after_configuration
|
29
|
+
if app.config.setting(:asciidoc).value_set?
|
30
|
+
warn 'Using `set :asciidoc` to define options is deprecated. Please define options on `activate :asciidoc` instead.'
|
31
|
+
end
|
32
|
+
app.config[:asciidoc].tap do |cfg|
|
33
|
+
attributes = {}
|
34
|
+
if cfg.key? :attributes
|
35
|
+
attributes.update(attrs_as_hash cfg[:attributes])
|
36
|
+
attributes['!imagesdir'] = attributes.delete 'imagesdir!' if attributes.key? 'imagesdir!'
|
37
|
+
end
|
38
|
+
if options.setting(:attributes).value_set?
|
39
|
+
attributes.update(attrs_as_hash options[:attributes])
|
40
|
+
elsif app.config.setting(:asciidoc_attributes).value_set?
|
41
|
+
attributes.update(attrs_as_hash app.config[:asciidoc_attributes])
|
42
|
+
end
|
43
|
+
unless (attributes.key? 'imagesdir') || (attributes.key? '!imagesdir')
|
44
|
+
attributes['imagesdir'] = %(#{File.join((app.config[:http_prefix] || '/').chomp('/'), app.config[:images_dir])}@)
|
45
|
+
end
|
46
|
+
cfg[:attributes] = attributes.update IMPLICIT_ATTRIBUTES
|
47
|
+
cfg[:base_dir] = (dir = options[:base_dir]) ? dir.to_s : dir if options.setting(:base_dir).value_set?
|
48
|
+
# QUESTION ^ should we call expand_path on :base_dir if non-nil?
|
49
|
+
cfg[:backend] = options[:backend] if options.setting(:backend).value_set?
|
50
|
+
cfg[:backend] = (cfg[:backend] || :html5).to_sym
|
51
|
+
cfg[:safe] = options[:safe] if options.setting(:safe).value_set?
|
52
|
+
cfg[:safe] = (cfg[:safe] || :safe).to_sym
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def manipulate_resource_list(resources)
|
57
|
+
default_page_layout = app.config[:layout] == :_auto_layout ? '' : app.config[:layout]
|
58
|
+
asciidoctor_opts = app.config[:asciidoc].merge parse_header_only: true
|
59
|
+
use_docdir_as_base_dir = asciidoctor_opts[:base_dir].nil?
|
60
|
+
resources.each do |resource|
|
61
|
+
next unless (path = resource.source_file).present? && (path.end_with? '.adoc')
|
62
|
+
|
63
|
+
# read AsciiDoc header only to set page options and data
|
64
|
+
# header values can be accessed via app.data.page.<name> in the layout
|
65
|
+
asciidoctor_opts[:attributes]['page-layout'] = %(#{resource.options[:layout] || default_page_layout}@)
|
66
|
+
asciidoctor_opts[:base_dir] = (::File.dirname path) if use_docdir_as_base_dir
|
67
|
+
doc = Asciidoctor.load_file path, asciidoctor_opts
|
68
|
+
opts = {}
|
69
|
+
page = {}
|
70
|
+
|
71
|
+
opts[:base_dir] = asciidoctor_opts[:base_dir] if use_docdir_as_base_dir
|
72
|
+
|
73
|
+
# NOTE page layout value cascades from site config -> front matter -> page-layout header attribute
|
74
|
+
if doc.attr? 'page-layout'
|
75
|
+
if (layout = doc.attr 'page-layout').empty?
|
76
|
+
opts[:layout] = :_auto_layout
|
77
|
+
else
|
78
|
+
opts[:layout] = layout
|
79
|
+
end
|
80
|
+
opts[:layout_engine] = doc.attr 'page-layout-engine' if doc.attr? 'page-layout-engine'
|
81
|
+
else
|
82
|
+
opts[:layout] = false
|
83
|
+
opts[:header_footer] = true
|
84
|
+
end
|
85
|
+
|
86
|
+
doc.attributes.each do |(key,val)|
|
87
|
+
case key
|
88
|
+
when 'doctitle'
|
89
|
+
page[:title] = val
|
90
|
+
when 'author', 'email', 'date'
|
91
|
+
page[key.to_sym] = val
|
92
|
+
when 'revdate'
|
93
|
+
page[:date] ||= val
|
94
|
+
else
|
95
|
+
if (key.start_with? 'page-') && !(key.start_with? 'page-layout')
|
96
|
+
page[key[5..-1].to_sym] = val
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# QUESTION should we use resource.ext == doc.outfilesuffix instead?
|
102
|
+
unless resource.destination_path.end_with? doc.outfilesuffix
|
103
|
+
# NOTE we must use << or else the layout gets disabled
|
104
|
+
resource.destination_path << doc.outfilesuffix
|
105
|
+
end
|
106
|
+
|
107
|
+
resource.add_metadata options: opts, page: page
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def attrs_as_hash attrs
|
112
|
+
if Hash === attrs
|
113
|
+
attrs
|
114
|
+
else
|
115
|
+
Array(attrs).inject({}) do |accum, entry|
|
116
|
+
k, v = entry.split '=', 2
|
117
|
+
k = %(!#{k.chop}) if k.end_with? '!'
|
118
|
+
accum[k] = v || ''
|
119
|
+
accum
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'middleman-asciidoc'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'middleman-asciidoc/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'middleman-asciidoc'
|
7
|
+
s.version = Middleman::AsciiDoc::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
|
10
|
+
s.summary = 'AsciiDoc support for Middleman'
|
11
|
+
s.description = 'AsciiDoc rendering and metadata support for Middleman'
|
12
|
+
|
13
|
+
s.authors = ['Dan Allen']
|
14
|
+
s.email = ['dan.j.allen@gmail.com']
|
15
|
+
s.homepage = 'https://github.com/middleman/middleman-asciidoc'
|
16
|
+
s.license = 'MIT'
|
17
|
+
|
18
|
+
s.files = `git ls-files -z`.split "\0"
|
19
|
+
s.test_files = `git ls-files -z -- {fixtures,features}/*`.split "\0"
|
20
|
+
s.require_paths = ['lib']
|
21
|
+
|
22
|
+
s.add_runtime_dependency 'middleman-core', '~> 4.0'
|
23
|
+
s.add_runtime_dependency 'asciidoctor', '>= 1.5.0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-asciidoc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.rc.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dan Allen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: middleman-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: asciidoctor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.0
|
41
|
+
description: AsciiDoc rendering and metadata support for Middleman
|
42
|
+
email:
|
43
|
+
- dan.j.allen@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".bundle/config"
|
49
|
+
- ".gitignore"
|
50
|
+
- ".ruby-version"
|
51
|
+
- ".travis.yml"
|
52
|
+
- CHANGELOG.adoc
|
53
|
+
- CONTRIBUTING.adoc
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.adoc
|
56
|
+
- README.adoc
|
57
|
+
- Rakefile
|
58
|
+
- features/asciidoc.feature
|
59
|
+
- features/support/env.rb
|
60
|
+
- fixtures/asciidoc-app/config.rb
|
61
|
+
- fixtures/asciidoc-app/source/_include.adoc
|
62
|
+
- fixtures/asciidoc-app/source/code.adoc
|
63
|
+
- fixtures/asciidoc-app/source/custom-attribute.adoc
|
64
|
+
- fixtures/asciidoc-app/source/custom-imagesdir.adoc
|
65
|
+
- fixtures/asciidoc-app/source/gallery.adoc
|
66
|
+
- fixtures/asciidoc-app/source/hello-no-layout.adoc
|
67
|
+
- fixtures/asciidoc-app/source/hello-with-extension.html.adoc
|
68
|
+
- fixtures/asciidoc-app/source/hello-with-front-matter.adoc
|
69
|
+
- fixtures/asciidoc-app/source/hello-with-layout.adoc
|
70
|
+
- fixtures/asciidoc-app/source/hello-with-title.adoc
|
71
|
+
- fixtures/asciidoc-app/source/hello.adoc
|
72
|
+
- fixtures/asciidoc-app/source/images/tiger.gif
|
73
|
+
- fixtures/asciidoc-app/source/layouts/default.erb
|
74
|
+
- fixtures/asciidoc-app/source/manual/_chapters/ch01.adoc
|
75
|
+
- fixtures/asciidoc-app/source/manual/index.adoc
|
76
|
+
- fixtures/asciidoc-app/source/master.adoc
|
77
|
+
- lib/middleman-asciidoc.rb
|
78
|
+
- lib/middleman-asciidoc/extension.rb
|
79
|
+
- lib/middleman-asciidoc/middleman_extension.rb
|
80
|
+
- lib/middleman-asciidoc/version.rb
|
81
|
+
- middleman-asciidoc.gemspec
|
82
|
+
homepage: https://github.com/middleman/middleman-asciidoc
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.3.1
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.5.1
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: AsciiDoc support for Middleman
|
106
|
+
test_files:
|
107
|
+
- features/asciidoc.feature
|
108
|
+
- features/support/env.rb
|
109
|
+
- fixtures/asciidoc-app/config.rb
|
110
|
+
- fixtures/asciidoc-app/source/_include.adoc
|
111
|
+
- fixtures/asciidoc-app/source/code.adoc
|
112
|
+
- fixtures/asciidoc-app/source/custom-attribute.adoc
|
113
|
+
- fixtures/asciidoc-app/source/custom-imagesdir.adoc
|
114
|
+
- fixtures/asciidoc-app/source/gallery.adoc
|
115
|
+
- fixtures/asciidoc-app/source/hello-no-layout.adoc
|
116
|
+
- fixtures/asciidoc-app/source/hello-with-extension.html.adoc
|
117
|
+
- fixtures/asciidoc-app/source/hello-with-front-matter.adoc
|
118
|
+
- fixtures/asciidoc-app/source/hello-with-layout.adoc
|
119
|
+
- fixtures/asciidoc-app/source/hello-with-title.adoc
|
120
|
+
- fixtures/asciidoc-app/source/hello.adoc
|
121
|
+
- fixtures/asciidoc-app/source/images/tiger.gif
|
122
|
+
- fixtures/asciidoc-app/source/layouts/default.erb
|
123
|
+
- fixtures/asciidoc-app/source/manual/_chapters/ch01.adoc
|
124
|
+
- fixtures/asciidoc-app/source/manual/index.adoc
|
125
|
+
- fixtures/asciidoc-app/source/master.adoc
|
126
|
+
has_rdoc:
|