asciidoctor-indir_ext 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -7
- data/asciidoctor-indir_ext.gemspec +3 -3
- data/lib/asciidoctor/indir_ext/extension.rb +0 -39
- data/lib/asciidoctor/indir_ext/version.rb +1 -1
- metadata +15 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e223708a043aee7fe3db6aebe237e727d2074c4b9937ec3261b6d28b4a05185f
|
4
|
+
data.tar.gz: c0a899b375cf0b6bea009353fe30400b9ebafd2fba04f938e6fc391f3c361081
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3012191c5aaaa9d528d7e70784d01306d78050580319632e9a69c160b5b1b0df4b0162fb992a8c40887ad6fe20df56596e56b01934bf1a9ba18a772a619ca4b8
|
7
|
+
data.tar.gz: 4e72e8dfd5c8d36f003b07d1726d76458b5502cfb2d2f26e65bb1068e916301e80fc6dc0f4778276189693f86da3cd37fb906f07ed70dd104bcde3f8e6fa957d
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# Asciidoctor::IndirExt
|
2
2
|
|
3
|
-
|
3
|
+
An Asciidoctor extension that adds a variable `indir`, which always points to the directory of the currently included asciidoc file.
|
4
|
+
|
5
|
+
This extension solves the problem that standard asciidoctor allows [no relative paths in subdocuments](https://github.com/asciidoctor/asciidoctor/issues/650), see [asciidoctor issue #650](https://github.com/asciidoctor/asciidoctor/issues/650).
|
4
6
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
|
-
|
10
|
+
If using bundler, add this line to your application's Gemfile:
|
10
11
|
|
11
12
|
```ruby
|
12
13
|
gem 'asciidoctor-indir_ext'
|
@@ -14,15 +15,40 @@ gem 'asciidoctor-indir_ext'
|
|
14
15
|
|
15
16
|
And then execute:
|
16
17
|
|
17
|
-
$ bundle
|
18
|
+
$ bundle install
|
19
|
+
|
18
20
|
|
19
|
-
|
21
|
+
If you do not wish to use bundler, install as:
|
20
22
|
|
21
23
|
$ gem install asciidoctor-indir_ext
|
22
24
|
|
25
|
+
|
23
26
|
## Usage
|
24
27
|
|
25
|
-
|
28
|
+
1. In the beginning of a subdocument, add this line:
|
29
|
+
`ifndef::indir[:indir: .]`
|
30
|
+
|
31
|
+
2. Include images like this:
|
32
|
+
`image::{indir}/images/example.svg[]`
|
33
|
+
|
34
|
+
3. When compiling a master document (that includes other subdocuments), require this extension.
|
35
|
+
|
36
|
+
For example:
|
37
|
+
|
38
|
+
```bash
|
39
|
+
bundle exec asciidoctor -r asciidoctor-indir_ext master.adoc
|
40
|
+
```
|
41
|
+
|
42
|
+
|
43
|
+
...or without bundler:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
asciidoctor -r asciidoctor-indir_ext master.adoc
|
47
|
+
```
|
48
|
+
|
49
|
+
As a result, the extension provides an `indir` variable, which always points at the directory of the included asciidoc file. This allows image paths like `{indir}/images/example.svg` to be resolved relative to the included subdocument.
|
50
|
+
|
51
|
+
|
26
52
|
|
27
53
|
## Development
|
28
54
|
|
@@ -35,7 +61,16 @@ TODO: Write usage instructions here
|
|
35
61
|
|
36
62
|
## Contributing
|
37
63
|
|
38
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
64
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/johannesjh/asciidoctor-indir_ext.
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
## Credits
|
69
|
+
|
70
|
+
This extension is based on another asciidoctor extension called [jirutka/asciidoctor-include-ext](https://github.com/jirutka/asciidoctor-include-ext), which provides a cleaner implementation of asciidoctor's include processing, and thus makes it easier to overwrite according behavior through an extension.
|
71
|
+
|
72
|
+
Special thanks goes to [@mojavelinux](https://github.com/mojavelinux) for pointing out this solution in [asciidoctor issue #650](https://github.com/asciidoctor/asciidoctor/issues/650) and for providing valuable feedback.
|
73
|
+
|
39
74
|
|
40
75
|
## License
|
41
76
|
|
@@ -25,12 +25,12 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.files = Dir['lib/**/*', '*.gemspec', 'LICENSE*', 'README*']
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
spec.add_runtime_dependency 'asciidoctor', '
|
28
|
+
spec.add_runtime_dependency 'asciidoctor', '>= 1.5.6', '< 3.0.0'
|
29
29
|
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.1.3'
|
30
30
|
spec.add_runtime_dependency 'asciidoctor-include-ext', '~> 0.3.0'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'asciidoctor-pdf', '~> 1.5.0.alpha.16' # to build a pdf of the example folder
|
33
|
-
spec.add_development_dependency "bundler", "~>
|
34
|
-
spec.add_development_dependency "rake", "~>
|
33
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
34
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
35
35
|
spec.add_development_dependency "rspec", "~> 3.0"
|
36
36
|
end
|
@@ -4,45 +4,6 @@ module Asciidoctor
|
|
4
4
|
module IndirExt
|
5
5
|
##
|
6
6
|
# Asciidoctor extension that adds a variable "indir", pointing at the directory of included asciidoc files.
|
7
|
-
#
|
8
|
-
# The indir variable always points at the directory where the current asciidoc file is located.
|
9
|
-
# The value of the indir variable changes to always reflect the location of the current, included subdocument.
|
10
|
-
# (Note: This is in contrast to the docfile variable, which remains the same throughout an entire document).
|
11
|
-
# The indir variable can be used to construct image paths relative to included subdocuments.
|
12
|
-
#
|
13
|
-
# Background:
|
14
|
-
# This extension was created to ease the handling of image paths in nested subdocuments,
|
15
|
-
# see https://github.com/asciidoctor/asciidoctor/issues/650#issuecomment-433946605.
|
16
|
-
#
|
17
|
-
# Motivation:
|
18
|
-
# The usage scenario that motivates this extension is a nested folder structure with asciidoc files,
|
19
|
-
# with images stored next to the asciidoc file where they are used.
|
20
|
-
# For example, an asciidoc file "sub/sub1.adoc" may use an image located at "sub/images/img1.svg".
|
21
|
-
# In this scenario, we want to be able to compile the asciidoc files in two ways,
|
22
|
-
# as standalone documents, and included into a parent document.
|
23
|
-
# The image paths should resolve fine in both cases.
|
24
|
-
#
|
25
|
-
# Intended Usage of the Extension:
|
26
|
-
#
|
27
|
-
# 1. In the beginning of a subdocument, add this line:
|
28
|
-
# ifndef::indir[:indir: .]
|
29
|
-
#
|
30
|
-
# 2. Include images like this:
|
31
|
-
# image::{indir}/images/example.svg[]
|
32
|
-
#
|
33
|
-
# 3. When compiling a master document (that includes other subdocuments), require this extension.
|
34
|
-
# The extension will set the indir variable to always point at the directory of the included asciidoc file,
|
35
|
-
# to that the an image path like "{indir}/images/example.svg" is resolved relative to the included subdocument.
|
36
|
-
#
|
37
|
-
# Note that the subdocuments compile just fine without the extension.
|
38
|
-
# This can be handy to use an editor's built-in preview feature.
|
39
|
-
# The extension is only needed when compiling a master document (that includes other subdocuments).
|
40
|
-
#
|
41
|
-
# Caveats, Future Work:
|
42
|
-
# This extension, once registered, claims to handle any includes
|
43
|
-
# (because it does not overwrite the "handles?" method of its parent class, which always return true).
|
44
|
-
# In consequence, it is difficult to use this extension together with other include processor extensions.
|
45
|
-
# A better solution with finer-grained control could be based on https://github.com/jirutka/asciidoctor-include-ext.
|
46
7
|
class IndirIncludeProcessor < Asciidoctor::IncludeExt::IncludeProcessor
|
47
8
|
def initialize(*args, &block)
|
48
9
|
# temporary storage helper that won't be frozen by Asciidoctor
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-indir_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- johannesjh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.5.6
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 1.5.6
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: concurrent-ruby
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +78,28 @@ dependencies:
|
|
72
78
|
requirements:
|
73
79
|
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
81
|
+
version: '2.0'
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
88
|
+
version: '2.0'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: rake
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
93
|
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
95
|
+
version: '12.0'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
100
|
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
102
|
+
version: '12.0'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: rspec
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
152
|
- !ruby/object:Gem::Version
|
147
153
|
version: '0'
|
148
154
|
requirements: []
|
149
|
-
|
150
|
-
rubygems_version: 2.7.7
|
155
|
+
rubygems_version: 3.0.3
|
151
156
|
signing_key:
|
152
157
|
specification_version: 4
|
153
158
|
summary: An Asciidoctor extension that adds a variable `indir`, which always points
|