asciidoctor 1.5.6.1 → 1.5.6.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.adoc +36 -2
- data/CONTRIBUTING.adoc +15 -1
- data/Gemfile +9 -1
- data/{LICENSE.adoc → LICENSE} +3 -4
- data/Rakefile +0 -83
- data/asciidoctor.gemspec +3 -5
- data/lib/asciidoctor.rb +1 -1
- data/lib/asciidoctor/abstract_node.rb +145 -145
- data/lib/asciidoctor/document.rb +12 -16
- data/lib/asciidoctor/extensions.rb +13 -0
- data/lib/asciidoctor/path_resolver.rb +53 -24
- data/lib/asciidoctor/reader.rb +95 -88
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +5 -5
- data/man/asciidoctor.adoc +2 -2
- data/test/extensions_test.rb +55 -1
- data/test/links_test.rb +15 -0
- data/test/sections_test.rb +4 -4
- data/test/substitutions_test.rb +2 -2
- data/test/test_helper.rb +4 -4
- metadata +7 -39
- data/README-fr.adoc +0 -423
- data/README-jp.adoc +0 -408
- data/README-zh_CN.adoc +0 -427
- data/README.adoc +0 -422
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f10e996f01e533b8275c7800b7ce6a8c69d429d0454e8e01cce5c69316344d09
|
4
|
+
data.tar.gz: e4c1ef809b961b43a27d078c3066b2ad4ecdebc9338a40b7359073e33ad352ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22fb1fac684b21d3710c1063fef30603a65c0a8e222a89401811a6caee7942702db606cf21403bf3869dfb43e388a56aff8f5cdcbb0d2e3a4ec34915c0952a6b
|
7
|
+
data.tar.gz: 85eb15b1ea8e731e29c21af82468e24f09975c28b101809e90096c9e83cd291429961c989ef528c7cf8f5cf7867935257f9ab7212f8857cb99384a0f93d1ab5e
|
data/CHANGELOG.adoc
CHANGED
@@ -14,6 +14,41 @@ This document provides a high-level view of the changes introduced in Asciidocto
|
|
14
14
|
For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
|
15
15
|
|
16
16
|
// tag::compact[]
|
17
|
+
== 1.5.6.2 (2018-03-20) - @mojavelinux
|
18
|
+
|
19
|
+
Bug fixes::
|
20
|
+
|
21
|
+
* fix match for multiple xref macros w/ implicit text in same line (#2450)
|
22
|
+
* PathResolver#root? returns true for absolute URL in browser env (#2595)
|
23
|
+
|
24
|
+
Improvements / Refactoring::
|
25
|
+
|
26
|
+
* resolve include target correctly in browser (xmlhttprequest IO module) (#2599, #2602)
|
27
|
+
* extract method to resolve include path (allowing Asciidoctor.js to override) (#2610)
|
28
|
+
* don't expand docdir value passed to API (#2518)
|
29
|
+
* check mandatory attributes when creating an image block (#2349)
|
30
|
+
* drop is_ prefix from boolean methods in PathResolver (PR #2587)
|
31
|
+
* change Reader#replace_next_line to return true
|
32
|
+
* organize methods in AbstractNode
|
33
|
+
|
34
|
+
Build / Infrastructure::
|
35
|
+
|
36
|
+
* clean up dependencies
|
37
|
+
* add Ruby 2.5.0 to CI build matrix (PR #2528)
|
38
|
+
* update nokogiri to 1.8.0 for ruby >= 2.1 (PR #2380)
|
39
|
+
|
40
|
+
Distribution Packages::
|
41
|
+
|
42
|
+
* http://rubygems.org/gems/asciidoctor[RubyGem (asciidoctor)]
|
43
|
+
* https://apps.fedoraproject.org/packages/rubygem-asciidoctor[Fedora (rubygem-asciidoctor)]
|
44
|
+
* http://packages.debian.org/sid/asciidoctor[Debian (asciidoctor)]
|
45
|
+
* http://packages.ubuntu.com/saucy/asciidoctor[Ubuntu (asciidoctor)]
|
46
|
+
|
47
|
+
https://github.com/asciidoctor/asciidoctor/issues?q=milestone%3Av1.5.6.2[issues resolved] |
|
48
|
+
https://github.com/asciidoctor/asciidoctor/releases/tag/v1.5.6.2[git tag] |
|
49
|
+
https://github.com/asciidoctor/asciidoctor/compare/v1.5.6.1...v1.5.6.2[full diff]
|
50
|
+
// end::compact[]
|
51
|
+
|
17
52
|
== 1.5.6.1 (2017-07-23) - @mojavelinux
|
18
53
|
|
19
54
|
Bug fixes::
|
@@ -64,7 +99,6 @@ Distribution Packages::
|
|
64
99
|
https://github.com/asciidoctor/asciidoctor/issues?q=milestone%3Av1.5.6.1[issues resolved] |
|
65
100
|
https://github.com/asciidoctor/asciidoctor/releases/tag/v1.5.6.1[git tag] |
|
66
101
|
https://github.com/asciidoctor/asciidoctor/compare/v1.5.6...v1.5.6.1[full diff]
|
67
|
-
// end::compact[]
|
68
102
|
|
69
103
|
== 1.5.6 (2017-07-12) - @mojavelinux
|
70
104
|
|
@@ -634,7 +668,7 @@ Enhancements::
|
|
634
668
|
* match implicit URLs that use the file scheme (#853)
|
635
669
|
* added sectnumlevels to control depth of section numbering (#549)
|
636
670
|
* add hardbreaks option to block (#630)
|
637
|
-
*
|
671
|
+
* substitute attribute references in manname
|
638
672
|
* warn on reference to missing attribute if attribute-missing is "warn"
|
639
673
|
* only enable toc macro if toc is enabled and toc-placement attribute has the value macro (#706)
|
640
674
|
* add sectnums attribute as alternative alias to numbered attribute (#684)
|
data/CONTRIBUTING.adoc
CHANGED
@@ -13,10 +13,12 @@ ifdef::env-github,env-browser[:outfilesuffix: .adoc]
|
|
13
13
|
:uri-branch-help: {uri-fork-help}#create-branches
|
14
14
|
:uri-pr-help: {uri-help-base}/using-pull-requests
|
15
15
|
:uri-gist: https://gist.github.com
|
16
|
+
:uri-yard: https://yardoc.org
|
17
|
+
:uri-tomdoc: http://tomdoc.org
|
16
18
|
|
17
19
|
== License Agreement
|
18
20
|
|
19
|
-
By contributing changes to this repository, you agree to license your contributions under the
|
21
|
+
By contributing changes to this repository, you agree to license your contributions under the MIT license.
|
20
22
|
This ensures your contributions have the same license as the project and that the community is free to use your contributions.
|
21
23
|
You also assert that you are the original author of the work that you are contributing unless otherwise stated.
|
22
24
|
|
@@ -163,6 +165,18 @@ Now you can execute the `asciidoctor` command from any folder as follows:
|
|
163
165
|
|
164
166
|
$ asciidoctor-dev README.adoc
|
165
167
|
|
168
|
+
== Building the API Documentation
|
169
|
+
|
170
|
+
The API documentation is written in the {uri-tomdoc}[TomDoc] dialect and built using {uri-yard}[Yard].
|
171
|
+
|
172
|
+
The options for Yard are configured in the [.path]_.yardopts_ file at the root of the project.
|
173
|
+
|
174
|
+
To build the API documentation locally, run the following command:
|
175
|
+
|
176
|
+
$ bundle exec yard
|
177
|
+
|
178
|
+
The documentation will be built into the [.path]_rdoc_ folder.
|
179
|
+
|
166
180
|
== Supporting Additional Ruby Versions
|
167
181
|
|
168
182
|
If you would like this library to support another Ruby version, you may volunteer to be a maintainer.
|
data/Gemfile
CHANGED
@@ -11,6 +11,7 @@ group :development do
|
|
11
11
|
gem 'cucumber', '~> 1.3.0'
|
12
12
|
gem 'nokogiri', '~> 1.5.0'
|
13
13
|
gem 'slim', '~> 2.1.0'
|
14
|
+
gem 'tilt', '2.0.7'
|
14
15
|
else
|
15
16
|
gem 'nokogiri', '~> 1.6.0'
|
16
17
|
gem 'slim', '<= 3.0.7'
|
@@ -18,10 +19,17 @@ group :development do
|
|
18
19
|
else
|
19
20
|
gem 'nokogiri', '~> 1.6.0'
|
20
21
|
end
|
22
|
+
elsif ruby_version < (Gem::Version.new '2.2.0')
|
23
|
+
gem 'nokogiri', '~> 1.7.0' if Gem::Platform.local =~ 'x86-mingw32' || Gem::Platform.local =~ 'x64-mingw32'
|
21
24
|
end
|
22
25
|
gem 'racc', '~> 1.4.0' if RUBY_VERSION == '2.1.0' && RUBY_ENGINE == 'rbx'
|
23
26
|
end
|
24
27
|
|
28
|
+
group :doc do
|
29
|
+
gem 'yard'
|
30
|
+
gem 'yard-tomdoc'
|
31
|
+
end
|
32
|
+
|
25
33
|
# enable this group to use Guard for continuous testing
|
26
34
|
# after removing comments, run `bundle install` then `guard`
|
27
35
|
#group :guardtest do
|
@@ -32,7 +40,7 @@ end
|
|
32
40
|
#end
|
33
41
|
|
34
42
|
group :ci do
|
35
|
-
gem 'simplecov', '~> 0.
|
43
|
+
gem 'simplecov', '~> 0.14.1'
|
36
44
|
if ENV['SHIPPABLE']
|
37
45
|
gem 'simplecov-csv', '~> 0.1.3'
|
38
46
|
gem 'ci_reporter', '~> 2.0.0'
|
data/{LICENSE.adoc → LICENSE}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Copyright (C) 2012-
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (C) 2012-2018 Dan Allen, Ryan Waldron and the Asciidoctor Project
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
THE SOFTWARE.
|
22
|
-
....
|
data/Rakefile
CHANGED
@@ -63,50 +63,6 @@ namespace :test do
|
|
63
63
|
task :all => [:test, :features]
|
64
64
|
end
|
65
65
|
|
66
|
-
=begin
|
67
|
-
begin
|
68
|
-
require 'rdoc/task'
|
69
|
-
RDoc::Task.new do |rdoc|
|
70
|
-
rdoc.rdoc_dir = 'rdoc'
|
71
|
-
rdoc.title = "Asciidoctor #{Asciidoctor::VERSION}"
|
72
|
-
rdoc.markup = 'tomdoc' if rdoc.respond_to?(:markup)
|
73
|
-
rdoc.rdoc_files.include('LICENSE.adoc', 'lib/**/*.rb')
|
74
|
-
end
|
75
|
-
rescue LoadError
|
76
|
-
end
|
77
|
-
=end
|
78
|
-
|
79
|
-
begin
|
80
|
-
require 'yard'
|
81
|
-
require 'yard-tomdoc'
|
82
|
-
require './lib/asciidoctor'
|
83
|
-
|
84
|
-
# Prevent YARD from breaking command statements in literal paragraphs
|
85
|
-
class CommandBlockPostprocessor < Asciidoctor::Extensions::Postprocessor
|
86
|
-
def process document, output
|
87
|
-
output.gsub(/<pre>\$ (.+?)<\/pre>/m, '<pre class="command code"><span class="const">$</span> \1</pre>')
|
88
|
-
end
|
89
|
-
end
|
90
|
-
Asciidoctor::Extensions.register do
|
91
|
-
postprocessor CommandBlockPostprocessor
|
92
|
-
end
|
93
|
-
|
94
|
-
# register .adoc extension for AsciiDoc markup helper
|
95
|
-
YARD::Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS[:asciidoc] = %w(adoc)
|
96
|
-
YARD::Rake::YardocTask.new do |yard|
|
97
|
-
yard.files = %w(
|
98
|
-
lib/**/*.rb
|
99
|
-
-
|
100
|
-
CHANGELOG.adoc
|
101
|
-
LICENSE.adoc
|
102
|
-
)
|
103
|
-
# --no-highlight enabled to prevent verbatim blocks in AsciiDoc that begin with $ from being dropped
|
104
|
-
# need to patch htmlify method to not attempt to syntax highlight blocks (or fix what's wrong)
|
105
|
-
yard.options = (IO.readlines '.yardopts').map {|l| l.chomp.delete('"').split ' ', 2 }.flatten if ::File.file? '.yardopts'
|
106
|
-
end
|
107
|
-
rescue LoadError
|
108
|
-
end
|
109
|
-
|
110
66
|
begin
|
111
67
|
require 'bundler/gem_tasks'
|
112
68
|
|
@@ -126,42 +82,3 @@ desc 'Open an irb session preloaded with this library'
|
|
126
82
|
task :console do
|
127
83
|
sh 'bundle console', :verbose => false
|
128
84
|
end
|
129
|
-
|
130
|
-
namespace :build do
|
131
|
-
desc 'Trigger builds for all dependent projects on Travis CI'
|
132
|
-
task :dependents do
|
133
|
-
if ENV['TRAVIS'].to_s == 'true'
|
134
|
-
next unless ENV['TRAVIS_PULL_REQUEST'].to_s == 'false' && (ENV['TRAVIS_JOB_NUMBER'].to_s.end_with? '.1')
|
135
|
-
end
|
136
|
-
next unless (token = ENV['TRAVIS_TOKEN'])
|
137
|
-
require 'net/http'
|
138
|
-
%w(
|
139
|
-
asciidoctor/asciidoctor.js
|
140
|
-
asciidoctor/asciidoctorj
|
141
|
-
asciidoctor/asciidoctorj/asciidoctorj-1.6.0
|
142
|
-
asciidoctor/asciidoctor-diagram
|
143
|
-
).each do |project|
|
144
|
-
org, name, branch = project.split '/', 3
|
145
|
-
branch ||= 'master'
|
146
|
-
header = {
|
147
|
-
'Content-Type' => 'application/json',
|
148
|
-
'Accept' => 'application/json',
|
149
|
-
'Travis-API-Version' => '3',
|
150
|
-
'Authorization' => %(token #{token})
|
151
|
-
}
|
152
|
-
if (commit_hash = ENV['TRAVIS_COMMIT'])
|
153
|
-
commit_memo = %( (#{commit_hash.slice 0, 8})\\n\\nhttps://github.com/#{ENV['TRAVIS_REPO_SLUG'] || 'asciidoctor/asciidoctor'}/commit/#{commit_hash})
|
154
|
-
end
|
155
|
-
payload = %({ "request": { "branch": "#{branch}", "message": "Build triggered by Asciidoctor#{commit_memo}" } })
|
156
|
-
(http = Net::HTTP.new 'api.travis-ci.org', 443).use_ssl = true
|
157
|
-
request = Net::HTTP::Post.new %(/repo/#{org}%2F#{name}/requests), header
|
158
|
-
request.body = payload
|
159
|
-
response = http.request request
|
160
|
-
if response.code == '202'
|
161
|
-
puts %(Successfully triggered build on #{project} repository)
|
162
|
-
else
|
163
|
-
warn %(Unable to trigger build on #{project} repository: #{response.code} - #{response.message})
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
data/asciidoctor.gemspec
CHANGED
@@ -17,13 +17,13 @@ Gem::Specification.new do |s|
|
|
17
17
|
rescue
|
18
18
|
Dir['**/*']
|
19
19
|
end
|
20
|
-
s.files = files.grep(/^(?:(?:data|lib|man)\/.+|Gemfile|Rakefile|(?:CHANGELOG|
|
20
|
+
s.files = files.grep(/^(?:(?:data|lib|man)\/.+|Gemfile|Rakefile|LICENSE|(?:CHANGELOG|CONTRIBUTINGREADME(?:-\w+)?)\.adoc|#{s.name}\.gemspec)$/)
|
21
21
|
s.executables = files.grep(/^bin\//).map {|f| File.basename f }
|
22
22
|
s.require_paths = ['lib']
|
23
23
|
s.test_files = files.grep(/^(?:(?:features|test)\/.+)$/)
|
24
24
|
s.has_rdoc = true
|
25
25
|
s.rdoc_options = ['--charset=UTF-8']
|
26
|
-
s.extra_rdoc_files = ['CHANGELOG.adoc', 'CONTRIBUTING.adoc', 'LICENSE
|
26
|
+
s.extra_rdoc_files = ['CHANGELOG.adoc', 'CONTRIBUTING.adoc', 'LICENSE']
|
27
27
|
|
28
28
|
# asciimath is needed for testing AsciiMath in DocBook backend
|
29
29
|
s.add_development_dependency 'asciimath', '~> 1.0.0'
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_development_dependency 'erubis', '~> 2.7.0'
|
35
35
|
# haml is needed for testing custom templates
|
36
36
|
s.add_development_dependency 'haml', '~> 5.0.0'
|
37
|
-
s.add_development_dependency 'nokogiri', '~> 1.
|
37
|
+
s.add_development_dependency 'nokogiri', '~> 1.8.0'
|
38
38
|
s.add_development_dependency 'rake', '~> 10.0.0'
|
39
39
|
s.add_development_dependency 'rspec-expectations', '~> 2.14.0'
|
40
40
|
# slim is needed for testing custom templates
|
@@ -42,7 +42,5 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.add_development_dependency 'thread_safe', '~> 0.3.0'
|
43
43
|
# tilt is needed for testing custom templates
|
44
44
|
s.add_development_dependency 'tilt', '~> 2.0.0'
|
45
|
-
s.add_development_dependency 'yard', '0.9.8'
|
46
|
-
s.add_development_dependency 'yard-tomdoc', '~> 0.7.0'
|
47
45
|
s.add_development_dependency 'minitest', '~> 5.3.0'
|
48
46
|
end
|
data/lib/asciidoctor.rb
CHANGED
@@ -990,7 +990,7 @@ module Asciidoctor
|
|
990
990
|
#
|
991
991
|
# NOTE special characters have already been escaped, hence the entity references
|
992
992
|
# NOTE { is included in start characters to support target that begins with attribute reference in title content
|
993
|
-
InlineXrefMacroRx = %r(\\?(?:<<([#{CC_WORD}#/.:{]#{CC_ALL}*?)>>|xref:([#{CC_WORD}#/.:{]#{CC_ALL}*?)\[(#{CC_ALL}*?[^\\])
|
993
|
+
InlineXrefMacroRx = %r(\\?(?:<<([#{CC_WORD}#/.:{]#{CC_ALL}*?)>>|xref:([#{CC_WORD}#/.:{]#{CC_ALL}*?)\[(?:\]|(#{CC_ALL}*?[^\\])\])))m
|
994
994
|
|
995
995
|
## Layout
|
996
996
|
|
@@ -52,19 +52,25 @@ class AbstractNode
|
|
52
52
|
nil
|
53
53
|
end
|
54
54
|
|
55
|
-
# Public:
|
55
|
+
# Public: Get the Asciidoctor::Converter instance being used to convert the
|
56
|
+
# current Asciidoctor::Document.
|
57
|
+
def converter
|
58
|
+
@document.converter
|
59
|
+
end
|
60
|
+
|
61
|
+
# Public: Returns whether this {AbstractNode} is an instance of {Block}
|
56
62
|
#
|
57
63
|
# Returns [Boolean]
|
58
|
-
def
|
64
|
+
def block?
|
59
65
|
# :nocov:
|
60
66
|
raise ::NotImplementedError
|
61
67
|
# :nocov:
|
62
68
|
end
|
63
69
|
|
64
|
-
# Public: Returns whether this {AbstractNode} is an instance of {
|
70
|
+
# Public: Returns whether this {AbstractNode} is an instance of {Inline}
|
65
71
|
#
|
66
72
|
# Returns [Boolean]
|
67
|
-
def
|
73
|
+
def inline?
|
68
74
|
# :nocov:
|
69
75
|
raise ::NotImplementedError
|
70
76
|
# :nocov:
|
@@ -144,16 +150,6 @@ class AbstractNode
|
|
144
150
|
@attributes.delete name
|
145
151
|
end
|
146
152
|
|
147
|
-
# TODO document me
|
148
|
-
def set_option(name)
|
149
|
-
if @attributes.key? 'options'
|
150
|
-
@attributes['options'] = %(#{@attributes['options']},#{name})
|
151
|
-
else
|
152
|
-
@attributes['options'] = name
|
153
|
-
end
|
154
|
-
@attributes[%(#{name}-option)] = ''
|
155
|
-
end
|
156
|
-
|
157
153
|
# Public: A convenience method to check if the specified option attribute is
|
158
154
|
# enabled on the current node.
|
159
155
|
#
|
@@ -167,6 +163,16 @@ class AbstractNode
|
|
167
163
|
@attributes.key? %(#{name}-option)
|
168
164
|
end
|
169
165
|
|
166
|
+
# TODO document me
|
167
|
+
def set_option(name)
|
168
|
+
if @attributes.key? 'options'
|
169
|
+
@attributes['options'] = %(#{@attributes['options']},#{name})
|
170
|
+
else
|
171
|
+
@attributes['options'] = name
|
172
|
+
end
|
173
|
+
@attributes[%(#{name}-option)] = ''
|
174
|
+
end
|
175
|
+
|
170
176
|
# Public: Update the attributes of this node with the new values in
|
171
177
|
# the attributes argument.
|
172
178
|
#
|
@@ -181,10 +187,16 @@ class AbstractNode
|
|
181
187
|
nil
|
182
188
|
end
|
183
189
|
|
184
|
-
# Public:
|
185
|
-
|
186
|
-
|
187
|
-
|
190
|
+
# Public: A convenience method that returns the value of the role attribute
|
191
|
+
def role
|
192
|
+
@attributes['role'] || @document.attributes['role']
|
193
|
+
end
|
194
|
+
|
195
|
+
# Public: A convenience method that returns the role names as an Array
|
196
|
+
#
|
197
|
+
# Returns the role names as an Array or an empty Array if the role attribute is absent.
|
198
|
+
def roles
|
199
|
+
(val = @attributes['role'] || @document.attributes['role']).nil_or_empty? ? [] : val.split
|
188
200
|
end
|
189
201
|
|
190
202
|
# Public: A convenience method that checks if the role attribute is specified
|
@@ -196,11 +208,6 @@ class AbstractNode
|
|
196
208
|
end
|
197
209
|
end
|
198
210
|
|
199
|
-
# Public: A convenience method that returns the value of the role attribute
|
200
|
-
def role
|
201
|
-
@attributes['role'] || @document.attributes['role']
|
202
|
-
end
|
203
|
-
|
204
211
|
# Public: A convenience method that checks if the specified role is present
|
205
212
|
# in the list of roles on this node
|
206
213
|
def has_role?(name)
|
@@ -208,13 +215,6 @@ class AbstractNode
|
|
208
215
|
(val = @attributes['role'] || @document.attributes['role']).nil_or_empty? ? false : %( #{val} ).include?(%( #{name} ))
|
209
216
|
end
|
210
217
|
|
211
|
-
# Public: A convenience method that returns the role names as an Array
|
212
|
-
#
|
213
|
-
# Returns the role names as an Array or an empty Array if the role attribute is absent.
|
214
|
-
def roles
|
215
|
-
(val = @attributes['role'] || @document.attributes['role']).nil_or_empty? ? [] : val.split
|
216
|
-
end
|
217
|
-
|
218
218
|
# Public: A convenience method that adds the given role directly to this node
|
219
219
|
#
|
220
220
|
# Returns a Boolean indicating whether the role was added.
|
@@ -249,16 +249,16 @@ class AbstractNode
|
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
|
-
# Public: A convenience method that checks if the reftext attribute is defined.
|
253
|
-
def reftext?
|
254
|
-
@attributes.key? 'reftext'
|
255
|
-
end
|
256
|
-
|
257
252
|
# Public: A convenience method that returns the value of the reftext attribute with substitutions applied.
|
258
253
|
def reftext
|
259
254
|
(val = @attributes['reftext']) ? (apply_reftext_subs val) : nil
|
260
255
|
end
|
261
256
|
|
257
|
+
# Public: A convenience method that checks if the reftext attribute is defined.
|
258
|
+
def reftext?
|
259
|
+
@attributes.key? 'reftext'
|
260
|
+
end
|
261
|
+
|
262
262
|
# Public: Construct a reference or data URI to an icon image for the
|
263
263
|
# specified icon name.
|
264
264
|
#
|
@@ -290,24 +290,6 @@ class AbstractNode
|
|
290
290
|
end
|
291
291
|
end
|
292
292
|
|
293
|
-
# Public: Construct a URI reference to the target media.
|
294
|
-
#
|
295
|
-
# If the target media is a URI reference, then leave it untouched.
|
296
|
-
#
|
297
|
-
# The target media is resolved relative to the directory retrieved from the
|
298
|
-
# specified attribute key, if provided.
|
299
|
-
#
|
300
|
-
# The return value can be safely used in a media tag (img, audio, video).
|
301
|
-
#
|
302
|
-
# target - A String reference to the target media
|
303
|
-
# asset_dir_key - The String attribute key used to lookup the directory where
|
304
|
-
# the media is located (default: 'imagesdir')
|
305
|
-
#
|
306
|
-
# Returns A String reference for the target media
|
307
|
-
def media_uri(target, asset_dir_key = 'imagesdir')
|
308
|
-
normalize_web_path target, (asset_dir_key ? @document.attr(asset_dir_key) : nil)
|
309
|
-
end
|
310
|
-
|
311
293
|
# Public: Construct a URI reference or data URI to the target image.
|
312
294
|
#
|
313
295
|
# If the target image is a URI reference, then leave it untouched.
|
@@ -345,6 +327,24 @@ class AbstractNode
|
|
345
327
|
end
|
346
328
|
end
|
347
329
|
|
330
|
+
# Public: Construct a URI reference to the target media.
|
331
|
+
#
|
332
|
+
# If the target media is a URI reference, then leave it untouched.
|
333
|
+
#
|
334
|
+
# The target media is resolved relative to the directory retrieved from the
|
335
|
+
# specified attribute key, if provided.
|
336
|
+
#
|
337
|
+
# The return value can be safely used in a media tag (img, audio, video).
|
338
|
+
#
|
339
|
+
# target - A String reference to the target media
|
340
|
+
# asset_dir_key - The String attribute key used to lookup the directory where
|
341
|
+
# the media is located (default: 'imagesdir')
|
342
|
+
#
|
343
|
+
# Returns A String reference for the target media
|
344
|
+
def media_uri(target, asset_dir_key = 'imagesdir')
|
345
|
+
normalize_web_path target, (asset_dir_key ? @document.attr(asset_dir_key) : nil)
|
346
|
+
end
|
347
|
+
|
348
348
|
# Public: Generate a data URI that can be used to embed an image in the output document
|
349
349
|
#
|
350
350
|
# First, and foremost, the target image path is cleaned if the document safe mode level
|
@@ -418,44 +418,70 @@ class AbstractNode
|
|
418
418
|
end
|
419
419
|
end
|
420
420
|
|
421
|
-
# Public:
|
421
|
+
# Public: Normalize the asset file or directory to a concrete and rinsed path
|
422
422
|
#
|
423
|
-
#
|
424
|
-
#
|
425
|
-
|
426
|
-
|
423
|
+
# Delegates to normalize_system_path, with the start path set to the value of
|
424
|
+
# the base_dir instance variable on the Document object.
|
425
|
+
def normalize_asset_path(asset_ref, asset_name = 'path', autocorrect = true)
|
426
|
+
normalize_system_path(asset_ref, @document.base_dir, nil,
|
427
|
+
:target_name => asset_name, :recover => autocorrect)
|
428
|
+
end
|
429
|
+
|
430
|
+
# Public: Resolve and normalize a secure path from the target and start paths
|
431
|
+
# using the PathResolver.
|
427
432
|
#
|
428
|
-
#
|
429
|
-
#
|
430
|
-
#
|
431
|
-
#
|
432
|
-
#
|
433
|
-
#
|
434
|
-
#
|
435
|
-
#
|
436
|
-
#
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
433
|
+
# See {PathResolver#system_path} for details.
|
434
|
+
#
|
435
|
+
# The most important functionality in this method is to prevent resolving a
|
436
|
+
# path outside of the jail (which defaults to the directory of the source
|
437
|
+
# file, stored in the base_dir instance variable on Document) if the document
|
438
|
+
# safe level is set to SafeMode::SAFE or greater (a condition which is true
|
439
|
+
# by default).
|
440
|
+
#
|
441
|
+
# target - the String target path
|
442
|
+
# start - the String start (i.e., parent) path
|
443
|
+
# jail - the String jail path to confine the resolved path
|
444
|
+
# opts - an optional Hash of options to control processing (default: {}):
|
445
|
+
# * :recover is used to control whether the processor should auto-recover
|
446
|
+
# when an illegal path is encountered
|
447
|
+
# * :target_name is used in messages to refer to the path being resolved
|
448
|
+
#
|
449
|
+
# raises a SecurityError if a jail is specified and the resolved path is
|
450
|
+
# outside the jail.
|
451
|
+
#
|
452
|
+
# Returns the [String] path resolved from the start and target paths, with any
|
453
|
+
# parent references resolved and self references removed. If a jail is provided,
|
454
|
+
# this path will be guaranteed to be contained within the jail.
|
455
|
+
def normalize_system_path target, start = nil, jail = nil, opts = {}
|
456
|
+
path_resolver = (@path_resolver ||= PathResolver.new)
|
457
|
+
if (doc = @document).safe < SafeMode::SAFE
|
458
|
+
if start
|
459
|
+
start = ::File.join doc.base_dir, start unless path_resolver.root? start
|
450
460
|
else
|
451
|
-
|
452
|
-
data = nil
|
461
|
+
start = doc.base_dir
|
453
462
|
end
|
454
463
|
else
|
455
|
-
|
456
|
-
|
464
|
+
start = doc.base_dir unless start
|
465
|
+
jail = doc.base_dir unless jail
|
466
|
+
end
|
467
|
+
path_resolver.system_path target, start, jail, opts
|
468
|
+
end
|
469
|
+
|
470
|
+
# Public: Normalize the web path using the PathResolver.
|
471
|
+
#
|
472
|
+
# See {PathResolver#web_path} for details about path resolution and encoding.
|
473
|
+
#
|
474
|
+
# target - the String target path
|
475
|
+
# start - the String start (i.e, parent) path (optional, default: nil)
|
476
|
+
# preserve_uri_target - a Boolean indicating whether target should be preserved if contains a URI (default: true)
|
477
|
+
#
|
478
|
+
# Returns the resolved [String] path
|
479
|
+
def normalize_web_path(target, start = nil, preserve_uri_target = true)
|
480
|
+
if preserve_uri_target && (Helpers.uriish? target)
|
481
|
+
uri_encode_spaces target
|
482
|
+
else
|
483
|
+
(@path_resolver ||= PathResolver.new).web_path target, start
|
457
484
|
end
|
458
|
-
data
|
459
485
|
end
|
460
486
|
|
461
487
|
# Public: Read the contents of the file at the specified path.
|
@@ -486,21 +512,44 @@ class AbstractNode
|
|
486
512
|
end
|
487
513
|
end
|
488
514
|
|
489
|
-
# Public:
|
490
|
-
#
|
491
|
-
# See {PathResolver#web_path} for details about path resolution and encoding.
|
515
|
+
# Public: Resolve the URI or system path to the specified target, then read and return its contents
|
492
516
|
#
|
493
|
-
# target
|
494
|
-
#
|
495
|
-
#
|
517
|
+
# The URI or system path of the target is first resolved. If the resolved path is a URI, read the
|
518
|
+
# contents from the URI if the allow-uri-read attribute is set, enabling caching if the cache-uri
|
519
|
+
# attribute is also set. If the resolved path is not a URI, read the contents of the file from the
|
520
|
+
# file system. If the normalize option is set, the data will be normalized.
|
496
521
|
#
|
497
|
-
#
|
498
|
-
|
499
|
-
|
500
|
-
|
522
|
+
# target - The URI or local path from which to read the data.
|
523
|
+
# opts - a Hash of options to control processing (default: {})
|
524
|
+
# * :label the String label of the target to use in warning messages (default: 'asset')
|
525
|
+
# * :normalize a Boolean that indicates whether the data should be normalized (default: false)
|
526
|
+
# * :start the String relative base path to use when resolving the target (default: nil)
|
527
|
+
# * :warn_on_failure a Boolean that indicates whether warnings are issued if the target cannot be read (default: true)
|
528
|
+
# Returns the contents of the resolved target or nil if the resolved target cannot be read
|
529
|
+
# --
|
530
|
+
# TODO refactor other methods in this class to use this method were possible (repurposing if necessary)
|
531
|
+
def read_contents target, opts = {}
|
532
|
+
doc = @document
|
533
|
+
if (Helpers.uriish? target) || ((start = opts[:start]) && (Helpers.uriish? start) &&
|
534
|
+
(target = (@path_resolver ||= PathResolver.new).web_path target, start))
|
535
|
+
if doc.attr? 'allow-uri-read'
|
536
|
+
Helpers.require_library 'open-uri/cached', 'open-uri-cached' if doc.attr? 'cache-uri'
|
537
|
+
begin
|
538
|
+
data = ::OpenURI.open_uri(target) {|fd| fd.read }
|
539
|
+
data = (Helpers.normalize_lines_from_string data) * LF if opts[:normalize]
|
540
|
+
rescue
|
541
|
+
warn %(asciidoctor: WARNING: could not retrieve contents of #{opts[:label] || 'asset'} at URI: #{target}) if opts.fetch :warn_on_failure, true
|
542
|
+
data = nil
|
543
|
+
end
|
544
|
+
else
|
545
|
+
warn %(asciidoctor: WARNING: cannot retrieve contents of #{opts[:label] || 'asset'} at URI: #{target} (allow-uri-read attribute not enabled)) if opts.fetch :warn_on_failure, true
|
546
|
+
data = nil
|
547
|
+
end
|
501
548
|
else
|
502
|
-
|
549
|
+
target = normalize_system_path target, opts[:start], nil, :target_name => (opts[:label] || 'asset')
|
550
|
+
data = read_asset target, :normalize => opts[:normalize], :warn_on_failure => (opts.fetch :warn_on_failure, true), :label => opts[:label]
|
503
551
|
end
|
552
|
+
data
|
504
553
|
end
|
505
554
|
|
506
555
|
# Internal: URI encode spaces in a String
|
@@ -512,55 +561,6 @@ class AbstractNode
|
|
512
561
|
(str.include? ' ') ? (str.gsub ' ', '%20') : str
|
513
562
|
end
|
514
563
|
|
515
|
-
# Public: Resolve and normalize a secure path from the target and start paths
|
516
|
-
# using the PathResolver.
|
517
|
-
#
|
518
|
-
# See {PathResolver#system_path} for details.
|
519
|
-
#
|
520
|
-
# The most important functionality in this method is to prevent resolving a
|
521
|
-
# path outside of the jail (which defaults to the directory of the source
|
522
|
-
# file, stored in the base_dir instance variable on Document) if the document
|
523
|
-
# safe level is set to SafeMode::SAFE or greater (a condition which is true
|
524
|
-
# by default).
|
525
|
-
#
|
526
|
-
# target - the String target path
|
527
|
-
# start - the String start (i.e., parent) path
|
528
|
-
# jail - the String jail path to confine the resolved path
|
529
|
-
# opts - an optional Hash of options to control processing (default: {}):
|
530
|
-
# * :recover is used to control whether the processor should auto-recover
|
531
|
-
# when an illegal path is encountered
|
532
|
-
# * :target_name is used in messages to refer to the path being resolved
|
533
|
-
#
|
534
|
-
# raises a SecurityError if a jail is specified and the resolved path is
|
535
|
-
# outside the jail.
|
536
|
-
#
|
537
|
-
# Returns the [String] path resolved from the start and target paths, with any
|
538
|
-
# parent references resolved and self references removed. If a jail is provided,
|
539
|
-
# this path will be guaranteed to be contained within the jail.
|
540
|
-
def normalize_system_path target, start = nil, jail = nil, opts = {}
|
541
|
-
path_resolver = (@path_resolver ||= PathResolver.new)
|
542
|
-
if (doc = @document).safe < SafeMode::SAFE
|
543
|
-
if start
|
544
|
-
start = ::File.join doc.base_dir, start unless path_resolver.is_root? start
|
545
|
-
else
|
546
|
-
start = doc.base_dir
|
547
|
-
end
|
548
|
-
else
|
549
|
-
start = doc.base_dir unless start
|
550
|
-
jail = doc.base_dir unless jail
|
551
|
-
end
|
552
|
-
path_resolver.system_path target, start, jail, opts
|
553
|
-
end
|
554
|
-
|
555
|
-
# Public: Normalize the asset file or directory to a concrete and rinsed path
|
556
|
-
#
|
557
|
-
# Delegates to normalize_system_path, with the start path set to the value of
|
558
|
-
# the base_dir instance variable on the Document object.
|
559
|
-
def normalize_asset_path(asset_ref, asset_name = 'path', autocorrect = true)
|
560
|
-
normalize_system_path(asset_ref, @document.base_dir, nil,
|
561
|
-
:target_name => asset_name, :recover => autocorrect)
|
562
|
-
end
|
563
|
-
|
564
564
|
# Public: Check whether the specified String is a URI by
|
565
565
|
# matching it against the Asciidoctor::UriSniffRx regex.
|
566
566
|
#
|