asciidoctor-indir_ext 0.1.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deaebfcbdad3175d689bdf46707f0f5d61d3a51935f7b4b45c05c2a6831f0bf4
4
- data.tar.gz: a922b30e24109594f39fa4a3b171e3e0aff1048668432f21ffa5d0ca7e63cc2a
3
+ metadata.gz: afec36eaeb7cebcba3fdf288af272f213cd8a3cc0e89ec1231492e413b961e06
4
+ data.tar.gz: b20855c37bd4d66ea964bf4bd1f21a1bc3de65b20cff2881ae7d7c0811cd7c5e
5
5
  SHA512:
6
- metadata.gz: e10aee525cfd41a87df27c24ab2d8a9ee48be6b63c1bfa2294f4873412f0a1c29f99b6016850f59c8ac1e40fa9477124d224a1dbdc33767a5f7dbca8f70f2487
7
- data.tar.gz: 0ffd97d129fc7664595398159013873d8031cfdf4a9a522a363eb9dc13a9e2ae4d8bf378cf8da5997df437316b691cdba94a0e16925fc270fda76df07d50b734
6
+ metadata.gz: f0eab26a0a303684fab20da49f01c21e85091c43a67c338df6b94862da23d0349729bd4521bc61459209ef0c30d25e15039c2ca9d8a9be5a936d57ba50fe08b1
7
+ data.tar.gz: bc53e474276b2b345435c11f384f442b6200be0aa4d94978c77157db2180f5fb9691b6369cb9c8d73c94118a0b15db0312c94534dc915c02b5b1e5a7c22733ee
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # Asciidoctor::IndirExt
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/asciidoctor/indir_ext`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- Add this line to your application's Gemfile:
10
+ If using bundler, add this line to your application's Gemfile:
10
11
 
11
12
  ```ruby
12
13
  gem 'asciidoctor-indir_ext'
@@ -14,28 +15,66 @@ gem 'asciidoctor-indir_ext'
14
15
 
15
16
  And then execute:
16
17
 
17
- $ bundle
18
+ $ bundle install
19
+
18
20
 
19
- Or install it yourself as:
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
- TODO: Write usage instructions here
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
 
29
- * After checking out the repo, run `bundle install` to install dependencies.
30
- * To list all available rake tasks, run `bundle exec rake -T`.
31
- * To build a gem package on your local machine, run `bundle exec rake build`.
32
- * To install this gem onto your local machine, run `bundle exec rake install`.
33
- * To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
55
+ It is possible to start a docker container using `docker-compose run --rm dev bash`.
56
+ This allows to run the following commands inside the docker container
57
+ and thus avoids messing with the local system setup.
58
+
59
+ * Run `bundle install` to install dependencies
60
+ * To list all available rake tasks, run `bundle exec rake -T`
61
+ * To build a gem package on your local machine, run `bundle exec rake build`
62
+ * To install this gem onto your local machine, run `bundle exec rake install`
63
+ * To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org)
34
64
 
35
65
 
36
66
  ## Contributing
37
67
 
38
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/asciidoctor-indir_ext.
68
+ Bug reports and pull requests are welcome on GitHub at https://github.com/johannesjh/asciidoctor-indir_ext.
69
+
70
+
71
+
72
+ ## Credits
73
+
74
+ 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.
75
+
76
+ 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.
77
+
39
78
 
40
79
  ## License
41
80
 
@@ -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', '~> 1.5.6'
28
+ spec.add_runtime_dependency 'asciidoctor', '>= 1.5.6', '< 3.0.0'
29
29
  spec.add_runtime_dependency 'concurrent-ruby', '~> 1.1.3'
30
- spec.add_runtime_dependency 'asciidoctor-include-ext', '~> 0.3.0'
30
+ spec.add_runtime_dependency 'asciidoctor-include-ext', '~> 0.4.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", "~> 1.16"
34
- spec.add_development_dependency "rake", "~> 10.0"
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,50 +4,11 @@ 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
49
10
  @tmp = { }
50
- super
11
+ super()
51
12
  end
52
13
 
53
14
  def process(document, reader, target, attributes)
@@ -60,6 +21,9 @@ module Asciidoctor
60
21
  # read content using functionality from super
61
22
  content = super(filename, selector)
62
23
 
24
+ # Ignore non-asciidoc files
25
+ if not ['.asciidoc', '.adoc', '.ad', '.asc', '.txt'].include? File.extname(filename) then return content end
26
+
63
27
  # split content into a list of lines if it has been provided as string
64
28
  if content.is_a? String then content = content.lines end
65
29
 
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module IndirExt
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
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.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - johannesjh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-09 00:00:00.000000000 Z
11
+ date: 2022-04-09 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
@@ -44,14 +50,14 @@ dependencies:
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: 0.3.0
53
+ version: 0.4.0
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: 0.3.0
60
+ version: 0.4.0
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: asciidoctor-pdf
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +78,28 @@ dependencies:
72
78
  requirements:
73
79
  - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '1.16'
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: '1.16'
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: '10.0'
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: '10.0'
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
- rubyforge_project:
150
- rubygems_version: 2.7.7
155
+ rubygems_version: 3.1.4
151
156
  signing_key:
152
157
  specification_version: 4
153
158
  summary: An Asciidoctor extension that adds a variable `indir`, which always points