asciidoctor-indir-extension 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8008624df3cd3951c9bf39a65733ad59073c10b7b22176130e0b433c154c798c
4
+ data.tar.gz: 9ddc435e1dd26c8afa34c35daeb082083787854973c3af51be25e2308f00a39f
5
+ SHA512:
6
+ metadata.gz: fbc23965f8dc4f7ceae0c9a4435040d7f5e9cc8f909344d589641c7547fa071cac8d420565b86f3e69f61653bfecb7eb3726cf61126b9f2953e849cc2553ef53
7
+ data.tar.gz: 18d8a3732c413ca72b47aa4d95644f8af6dc12409c46fb56617e97685442eb548a66dffec00f4f84fe74f287a4c3637390c26524747e60c63b55f13136cd65b0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Johannes Harms
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Asciidoctor::IndirExt
2
+
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).
6
+
7
+
8
+ ## Status and Maintenance
9
+
10
+ This is a fork of https://github.com/johannesjh/asciidoctor-indir_ext. I just updated some dependencies to work make it work with the latest asciidoc version
11
+
12
+
13
+ ## Installation
14
+
15
+ If using bundler, add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'asciidoctor-indir_ext'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle install
24
+
25
+
26
+ If you do not wish to use bundler, install as:
27
+
28
+ $ gem install asciidoctor-indir_ext
29
+
30
+
31
+ ## Usage
32
+
33
+ 1. In the beginning of a subdocument, add this line:
34
+ `ifndef::indir[:indir: .]`
35
+
36
+ 2. Include images like this:
37
+ `image::{indir}/images/example.svg[]`
38
+
39
+ 3. When compiling a master document (that includes other subdocuments), require this extension.
40
+
41
+ For example:
42
+
43
+ ```bash
44
+ bundle exec asciidoctor -r asciidoctor-indir_ext master.adoc
45
+ ```
46
+
47
+
48
+ ...or without bundler:
49
+
50
+ ```bash
51
+ asciidoctor -r asciidoctor-indir_ext master.adoc
52
+ ```
53
+
54
+ 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.
55
+
56
+
57
+
58
+ ## Development
59
+
60
+ It is possible to start a docker container using `docker-compose run --rm dev bash`.
61
+ This allows to run the following commands inside the docker container
62
+ and thus avoids messing with the local system setup.
63
+
64
+ * Run `bundle install` to install dependencies
65
+ * To list all available rake tasks, run `bundle exec rake -T`
66
+ * To build a gem package on your local machine, run `bundle exec rake build`
67
+ * To install this gem onto your local machine, run `bundle exec rake install`
68
+ * 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)
69
+
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/johannesjh/asciidoctor-indir_ext.
74
+
75
+
76
+
77
+ ## Credits
78
+
79
+ 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.
80
+
81
+ 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.
82
+
83
+
84
+ ## License
85
+
86
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,36 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "asciidoctor/indir_ext/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "asciidoctor-indir-extension"
8
+ spec.version = Asciidoctor::IndirExt::VERSION
9
+ spec.authors = ["pustekuchen91"]
10
+ spec.email = ["pustekuchen91@users.noreply.github.com"]
11
+
12
+ spec.summary = "An Asciidoctor extension that adds a variable `indir`, which always points to the directory of the currently included asciidoc file"
13
+ spec.description = %q(This Asciidoctor extension exposes a variable `indir`, which holds the path to the directory where the current asciidoc file is located.
14
+ The value of this variable changes to always reflect the location of the current, included subdocument.
15
+ (Note, this is in contrast to the `docfile` variable, which remains the same throughout an entire document).)
16
+ spec.homepage = "https://github.com/pustekuchen91/asciidoctor-indir_ext"
17
+ spec.license = "MIT"
18
+
19
+ spec.metadata = {
20
+ 'bug_tracker_uri' => 'https://github.com/pustekuchen91/asciidoctor-indir_ext/issues',
21
+ 'source_code_uri' => 'https://github.com/pustekuchen91/asciidoctor-indir_ext'
22
+ }
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ spec.files = Dir['lib/**/*', '*.gemspec', 'LICENSE*', 'README*']
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_runtime_dependency 'asciidoctor', '>= 2.0.20', '< 3.0.0'
29
+ spec.add_runtime_dependency 'concurrent-ruby', '~> 1.2.2'
30
+ spec.add_runtime_dependency 'asciidoctor-include-ext', '~> 0.4.0'
31
+
32
+ spec.add_development_dependency 'asciidoctor-pdf', '~> 2.3' # to build a pdf of the example folder
33
+ spec.add_development_dependency "bundler", "~> 2.0"
34
+ spec.add_development_dependency "rake", "~> 12.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ end
@@ -0,0 +1,46 @@
1
+ require 'asciidoctor/include_ext/include_processor'
2
+
3
+ module Asciidoctor
4
+ module IndirExt
5
+ ##
6
+ # Asciidoctor extension that adds a variable "indir", pointing at the directory of included asciidoc files.
7
+ class IndirIncludeProcessor < Asciidoctor::IncludeExt::IncludeProcessor
8
+ def initialize(*args, &block)
9
+ # temporary storage helper that won't be frozen by Asciidoctor
10
+ @tmp = { }
11
+ super()
12
+ end
13
+
14
+ def process(document, reader, target, attributes)
15
+ @tmp[:document] = document
16
+ @tmp[:reader] = reader
17
+ super
18
+ end
19
+
20
+ def read_lines(filename, selector)
21
+ # read content using functionality from super
22
+ content = super(filename, selector)
23
+
24
+ # Ignore non-asciidoc files
25
+ if not ['.asciidoc', '.adoc', '.ad', '.asc', '.txt'].include? File.extname(filename) then return content end
26
+
27
+ # split content into a list of lines if it has been provided as string
28
+ if content.is_a? String then content = content.lines end
29
+
30
+ # Set variables at the beginning of the included content
31
+ included_docfile = filename
32
+ included_docdir = ::File.dirname filename
33
+ content.unshift ''
34
+ content.unshift %(:indir: #{included_docdir})
35
+
36
+ # Reset the variables at the end of the included content
37
+ parent_docfile = @tmp[:reader].include_stack&.dig(-1, 1) || (@tmp[:document].attr 'docfile')
38
+ parent_docdir = ::File.dirname parent_docfile
39
+ content << ''
40
+ content << %(:indir: #{parent_docdir})
41
+
42
+ return content
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ module Asciidoctor
2
+ module IndirExt
3
+ VERSION = "0.1.5"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ require_relative 'indir_ext/extension'
2
+
3
+ Asciidoctor::Extensions.register do
4
+ include_processor Asciidoctor::IndirExt::IndirIncludeProcessor
5
+ end
@@ -0,0 +1,2 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'asciidoctor/indir_ext'
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asciidoctor-indir-extension
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - pustekuchen91
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-12-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: asciidoctor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.20
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.20
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: concurrent-ruby
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 1.2.2
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 1.2.2
47
+ - !ruby/object:Gem::Dependency
48
+ name: asciidoctor-include-ext
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.4.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.4.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: asciidoctor-pdf
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.3'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.3'
75
+ - !ruby/object:Gem::Dependency
76
+ name: bundler
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '2.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '12.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '12.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.0'
117
+ description: |-
118
+ This Asciidoctor extension exposes a variable `indir`, which holds the path to the directory where the current asciidoc file is located.
119
+ The value of this variable changes to always reflect the location of the current, included subdocument.
120
+ (Note, this is in contrast to the `docfile` variable, which remains the same throughout an entire document).
121
+ email:
122
+ - pustekuchen91@users.noreply.github.com
123
+ executables: []
124
+ extensions: []
125
+ extra_rdoc_files: []
126
+ files:
127
+ - LICENSE.txt
128
+ - README.md
129
+ - asciidoctor-indir_ext.gemspec
130
+ - lib/asciidoctor-indir-extension.rb
131
+ - lib/asciidoctor/indir_ext.rb
132
+ - lib/asciidoctor/indir_ext/extension.rb
133
+ - lib/asciidoctor/indir_ext/version.rb
134
+ homepage: https://github.com/pustekuchen91/asciidoctor-indir_ext
135
+ licenses:
136
+ - MIT
137
+ metadata:
138
+ bug_tracker_uri: https://github.com/pustekuchen91/asciidoctor-indir_ext/issues
139
+ source_code_uri: https://github.com/pustekuchen91/asciidoctor-indir_ext
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubygems_version: 3.1.6
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: An Asciidoctor extension that adds a variable `indir`, which always points
159
+ to the directory of the currently included asciidoc file
160
+ test_files: []