asciidoctor 1.5.5 → 1.5.6
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 +4 -4
- data/CHANGELOG.adoc +216 -1
- data/CONTRIBUTING.adoc +2 -2
- data/Gemfile +20 -1
- data/LICENSE.adoc +1 -1
- data/README-fr.adoc +4 -3
- data/README-jp.adoc +11 -10
- data/README-zh_CN.adoc +4 -3
- data/README.adoc +17 -202
- data/Rakefile +41 -25
- data/asciidoctor.gemspec +9 -10
- data/data/locale/attributes.adoc +216 -34
- data/data/stylesheets/asciidoctor-default.css +23 -16
- data/features/step_definitions.rb +15 -19
- data/features/xref.feature +584 -20
- data/lib/asciidoctor.rb +292 -278
- data/lib/asciidoctor/abstract_block.rb +155 -94
- data/lib/asciidoctor/abstract_node.rb +108 -94
- data/lib/asciidoctor/attribute_list.rb +30 -22
- data/lib/asciidoctor/block.rb +7 -7
- data/lib/asciidoctor/cli/invoker.rb +47 -34
- data/lib/asciidoctor/cli/options.rb +22 -11
- data/lib/asciidoctor/converter.rb +3 -3
- data/lib/asciidoctor/converter/base.rb +2 -2
- data/lib/asciidoctor/converter/composite.rb +1 -1
- data/lib/asciidoctor/converter/docbook45.rb +2 -2
- data/lib/asciidoctor/converter/docbook5.rb +132 -87
- data/lib/asciidoctor/converter/factory.rb +0 -1
- data/lib/asciidoctor/converter/html5.rb +116 -98
- data/lib/asciidoctor/converter/manpage.rb +51 -52
- data/lib/asciidoctor/converter/template.rb +47 -36
- data/lib/asciidoctor/core_ext.rb +8 -2
- data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +4 -0
- data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +6 -0
- data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +5 -0
- data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +1 -1
- data/lib/asciidoctor/core_ext/1.8.7/string/{limit.rb → limit_bytesize.rb} +7 -6
- data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +6 -0
- data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +1 -1
- data/lib/asciidoctor/core_ext/nil_or_empty.rb +5 -5
- data/lib/asciidoctor/core_ext/regexp/is_match.rb +3 -0
- data/lib/asciidoctor/core_ext/string/{limit.rb → limit_bytesize.rb} +2 -2
- data/lib/asciidoctor/document.rb +216 -213
- data/lib/asciidoctor/extensions.rb +318 -185
- data/lib/asciidoctor/helpers.rb +35 -35
- data/lib/asciidoctor/inline.rb +32 -1
- data/lib/asciidoctor/list.rb +22 -6
- data/lib/asciidoctor/parser.rb +1008 -1038
- data/lib/asciidoctor/path_resolver.rb +46 -50
- data/lib/asciidoctor/reader.rb +275 -251
- data/lib/asciidoctor/section.rb +86 -58
- data/lib/asciidoctor/stylesheets.rb +6 -6
- data/lib/asciidoctor/substitutors.rb +567 -649
- data/lib/asciidoctor/table.rb +163 -108
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +18 -16
- data/man/asciidoctor.adoc +15 -13
- data/test/attributes_test.rb +138 -22
- data/test/blocks_test.rb +377 -97
- data/test/converter_test.rb +13 -0
- data/test/document_test.rb +244 -34
- data/test/extensions_test.rb +409 -42
- data/test/fixtures/asciidoc_index.txt +521 -0
- data/test/fixtures/basic-docinfo-footer.html +6 -0
- data/test/fixtures/basic-docinfo-footer.xml +8 -0
- data/test/fixtures/basic-docinfo.html +1 -0
- data/test/fixtures/basic-docinfo.xml +4 -0
- data/test/fixtures/basic.asciidoc +5 -0
- data/test/fixtures/chapter-a.adoc +3 -0
- data/test/fixtures/child-include.adoc +5 -0
- data/test/fixtures/circle.svg +9 -0
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +6 -0
- data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +6 -0
- data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +1 -0
- data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +3 -0
- data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +5 -0
- data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +6 -0
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +3 -0
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +5 -0
- data/test/fixtures/custom-docinfodir/basic-docinfo.html +1 -0
- data/test/fixtures/custom-docinfodir/docinfo.html +1 -0
- data/test/fixtures/docinfo-footer.html +1 -0
- data/test/fixtures/docinfo-footer.xml +9 -0
- data/test/fixtures/docinfo.html +1 -0
- data/test/fixtures/docinfo.xml +3 -0
- data/test/fixtures/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +13 -0
- data/test/fixtures/grandchild-include.adoc +3 -0
- data/test/fixtures/hello-asciidoctor.pdf +69 -0
- data/test/fixtures/include-file.asciidoc +24 -0
- data/test/fixtures/include-file.ml +3 -0
- data/test/fixtures/include-file.xml +5 -0
- data/test/fixtures/master.adoc +5 -0
- data/test/fixtures/mismatched-end-tag.adoc +7 -0
- data/test/fixtures/parent-include-restricted.adoc +5 -0
- data/test/fixtures/parent-include.adoc +5 -0
- data/test/fixtures/sample.asciidoc +26 -0
- data/test/fixtures/stylesheets/custom.css +3 -0
- data/test/fixtures/subs-docinfo.html +2 -0
- data/test/fixtures/subs.adoc +7 -0
- data/test/fixtures/tagged-class-enclosed.rb +26 -0
- data/test/fixtures/tagged-class.rb +23 -0
- data/test/fixtures/tip.gif +0 -0
- data/test/invoker_test.rb +82 -4
- data/test/links_test.rb +312 -37
- data/test/lists_test.rb +204 -25
- data/test/manpage_test.rb +191 -4
- data/test/options_test.rb +18 -1
- data/test/paragraphs_test.rb +32 -7
- data/test/parser_test.rb +150 -30
- data/test/paths_test.rb +47 -13
- data/test/preamble_test.rb +1 -1
- data/test/reader_test.rb +366 -126
- data/test/sections_test.rb +203 -56
- data/test/substitutions_test.rb +339 -131
- data/test/tables_test.rb +315 -15
- data/test/test_helper.rb +400 -0
- data/test/text_test.rb +5 -5
- metadata +110 -22
data/test/test_helper.rb
ADDED
@@ -0,0 +1,400 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
ASCIIDOCTOR_PROJECT_DIR = File.dirname File.dirname(__FILE__)
|
3
|
+
Dir.chdir ASCIIDOCTOR_PROJECT_DIR
|
4
|
+
|
5
|
+
if RUBY_VERSION < '1.9'
|
6
|
+
require 'rubygems'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'simplecov' if ENV['COVERAGE'] == 'true'
|
10
|
+
|
11
|
+
require File.join(ASCIIDOCTOR_PROJECT_DIR, 'lib', 'asciidoctor')
|
12
|
+
|
13
|
+
require 'socket'
|
14
|
+
require 'nokogiri'
|
15
|
+
require 'tmpdir'
|
16
|
+
|
17
|
+
autoload :FileUtils, 'fileutils'
|
18
|
+
autoload :Pathname, 'pathname'
|
19
|
+
|
20
|
+
RE_XMLNS_ATTRIBUTE = / xmlns="[^"]+"/
|
21
|
+
RE_DOCTYPE = /\s*<!DOCTYPE (.*)/
|
22
|
+
|
23
|
+
require 'minitest/autorun'
|
24
|
+
|
25
|
+
# Minitest 4 doesn't have Minitest::Test
|
26
|
+
Minitest::Test = MiniTest::Unit::TestCase unless defined? Minitest::Test
|
27
|
+
|
28
|
+
class Minitest::Test
|
29
|
+
def windows?
|
30
|
+
RbConfig::CONFIG['host_os'] =~ /win|ming/
|
31
|
+
end
|
32
|
+
|
33
|
+
def disk_root
|
34
|
+
"#{windows? ? File.expand_path(__FILE__).split('/').first : nil}/"
|
35
|
+
end
|
36
|
+
|
37
|
+
def empty_document options = {}
|
38
|
+
if options[:parse]
|
39
|
+
(Asciidoctor::Document.new [], options).parse
|
40
|
+
else
|
41
|
+
Asciidoctor::Document.new [], options
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def empty_safe_document options = {}
|
46
|
+
options[:safe] = :safe
|
47
|
+
Asciidoctor::Document.new [], options
|
48
|
+
end
|
49
|
+
|
50
|
+
def sample_doc_path(name)
|
51
|
+
name = name.to_s
|
52
|
+
unless name.include?('.')
|
53
|
+
['asciidoc', 'txt'].each do |ext|
|
54
|
+
if File.exist?(fixture_path("#{name}.#{ext}"))
|
55
|
+
name = "#{name}.#{ext}"
|
56
|
+
break
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
fixture_path(name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def fixture_path(name)
|
64
|
+
File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures', name)
|
65
|
+
end
|
66
|
+
|
67
|
+
def example_document(name, opts = {})
|
68
|
+
document_from_string IO.read(sample_doc_path(name)), opts
|
69
|
+
end
|
70
|
+
|
71
|
+
def assert_difference(expression, difference = 1, message = nil, &block)
|
72
|
+
expressions = [expression]
|
73
|
+
|
74
|
+
exps = expressions.map { |e|
|
75
|
+
e.respond_to?(:call) ? e : lambda { eval(e, block.binding) }
|
76
|
+
}
|
77
|
+
before = exps.map { |e| e.call }
|
78
|
+
|
79
|
+
yield
|
80
|
+
|
81
|
+
expressions.zip(exps).each_with_index do |(code, e), i|
|
82
|
+
error = "#{code.inspect} didn't change by #{difference}"
|
83
|
+
error = "#{message}.\n#{error}" if message
|
84
|
+
assert_equal(before[i] + difference, e.call, error)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def xmlnodes_at_css(css, content, count = nil)
|
89
|
+
xmlnodes_at_path(:css, css, content, count)
|
90
|
+
end
|
91
|
+
|
92
|
+
def xmlnodes_at_xpath(xpath, content, count = nil)
|
93
|
+
xmlnodes_at_path(:xpath, xpath, content, count)
|
94
|
+
end
|
95
|
+
|
96
|
+
def xmlnodes_at_path(type, path, content, count = nil)
|
97
|
+
doc = xmldoc_from_string content
|
98
|
+
case type
|
99
|
+
when :xpath
|
100
|
+
namespaces = doc.respond_to?(:root) ? doc.root.namespaces : {}
|
101
|
+
results = doc.xpath("#{path.sub('/', './')}", namespaces)
|
102
|
+
when :css
|
103
|
+
results = doc.css(path)
|
104
|
+
end
|
105
|
+
count == 1 ? results.first : results
|
106
|
+
end
|
107
|
+
|
108
|
+
# Generate an xpath attribute matcher that matches a name in the class attribute
|
109
|
+
def contains_class(name)
|
110
|
+
%(contains(concat(' ', normalize-space(@class), ' '), ' #{name} '))
|
111
|
+
end
|
112
|
+
|
113
|
+
def assert_css(css, content, count = nil)
|
114
|
+
assert_path(:css, css, content, count)
|
115
|
+
end
|
116
|
+
|
117
|
+
def assert_xpath(xpath, content, count = nil)
|
118
|
+
assert_path(:xpath, xpath, content, count)
|
119
|
+
end
|
120
|
+
|
121
|
+
def assert_path(type, path, content, count = nil)
|
122
|
+
case type
|
123
|
+
when :xpath
|
124
|
+
type_name = 'XPath'
|
125
|
+
when :css
|
126
|
+
type_name = 'CSS'
|
127
|
+
end
|
128
|
+
|
129
|
+
results = xmlnodes_at_path type, path, content
|
130
|
+
|
131
|
+
if (count == true || count == false)
|
132
|
+
if (count != results)
|
133
|
+
flunk "#{type_name} #{path} yielded #{results} rather than #{count} for:\n#{content}"
|
134
|
+
else
|
135
|
+
assert true
|
136
|
+
end
|
137
|
+
elsif (count && results.size != count)
|
138
|
+
flunk "#{type_name} #{path} yielded #{results.size} elements rather than #{count} for:\n#{content}"
|
139
|
+
elsif (count.nil? && results.empty?)
|
140
|
+
flunk "#{type_name} #{path} not found in:\n#{content}"
|
141
|
+
else
|
142
|
+
assert true
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def xmldoc_from_string(content)
|
147
|
+
if content.match(RE_XMLNS_ATTRIBUTE)
|
148
|
+
doc = Nokogiri::XML::Document.parse(content)
|
149
|
+
elsif !(doctype_match = content.match(RE_DOCTYPE))
|
150
|
+
doc = Nokogiri::HTML::DocumentFragment.parse(content)
|
151
|
+
elsif doctype_match[1].start_with? 'html'
|
152
|
+
doc = Nokogiri::HTML::Document.parse(content)
|
153
|
+
else
|
154
|
+
doc = Nokogiri::XML::Document.parse(content)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def document_from_string(src, opts = {})
|
159
|
+
assign_default_test_options opts
|
160
|
+
if opts[:parse]
|
161
|
+
(Asciidoctor::Document.new src.lines.entries, opts).parse
|
162
|
+
else
|
163
|
+
Asciidoctor::Document.new src.lines.entries, opts
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def block_from_string(src, opts = {})
|
168
|
+
opts[:header_footer] = false
|
169
|
+
doc = document_from_string src, opts
|
170
|
+
doc.blocks.first
|
171
|
+
end
|
172
|
+
|
173
|
+
def render_string(src, opts = {})
|
174
|
+
keep_namespaces = opts.delete(:keep_namespaces)
|
175
|
+
if keep_namespaces
|
176
|
+
document_from_string(src, opts).render
|
177
|
+
else
|
178
|
+
# this is required because nokogiri is ignorant
|
179
|
+
result = document_from_string(src, opts).render
|
180
|
+
result = result.sub(RE_XMLNS_ATTRIBUTE, '') if result
|
181
|
+
result
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def render_embedded_string(src, opts = {})
|
186
|
+
opts[:header_footer] = false
|
187
|
+
document_from_string(src, opts).render
|
188
|
+
end
|
189
|
+
|
190
|
+
def render_inline_string(src, opts = {})
|
191
|
+
opts[:doctype] = :inline
|
192
|
+
document_from_string(src, opts).render
|
193
|
+
end
|
194
|
+
|
195
|
+
def parse_header_metadata(source, doc = nil)
|
196
|
+
reader = Asciidoctor::Reader.new source.split ::Asciidoctor::LF
|
197
|
+
[::Asciidoctor::Parser.parse_header_metadata(reader, doc), reader]
|
198
|
+
end
|
199
|
+
|
200
|
+
def assign_default_test_options(opts)
|
201
|
+
opts[:header_footer] = true unless opts.key? :header_footer
|
202
|
+
opts[:parse] = true unless opts.key? :parse
|
203
|
+
if opts[:header_footer]
|
204
|
+
# don't embed stylesheet unless test requests the default behavior
|
205
|
+
if opts.has_key? :linkcss_default
|
206
|
+
opts.delete(:linkcss_default)
|
207
|
+
else
|
208
|
+
opts[:attributes] ||= {}
|
209
|
+
opts[:attributes]['linkcss'] = ''
|
210
|
+
end
|
211
|
+
end
|
212
|
+
if (template_dir = ENV['TEMPLATE_DIR'])
|
213
|
+
opts[:template_dir] = template_dir unless opts.has_key? :template_dir
|
214
|
+
#opts[:template_dir] = File.join(File.dirname(__FILE__), '..', '..', 'asciidoctor-backends', 'erb') unless opts.has_key? :template_dir
|
215
|
+
end
|
216
|
+
nil
|
217
|
+
end
|
218
|
+
|
219
|
+
# Decode the numeric character reference, such as 8212, to a Unicode glyph
|
220
|
+
# so it may be used in an XPath expression.
|
221
|
+
#
|
222
|
+
# Examples
|
223
|
+
#
|
224
|
+
# decode_char 60
|
225
|
+
# # => "<"
|
226
|
+
#
|
227
|
+
# Returns the decoded String that corresponds to the numeric character reference
|
228
|
+
def decode_char number
|
229
|
+
[number].pack 'U1'
|
230
|
+
end
|
231
|
+
|
232
|
+
def invoke_cli_with_filenames(argv = [], filenames = [], &block)
|
233
|
+
|
234
|
+
filepaths = Array.new
|
235
|
+
|
236
|
+
filenames.each { |filename|
|
237
|
+
if filenames.nil?|| ::Pathname.new(filename).absolute?
|
238
|
+
filepaths.push(filename)
|
239
|
+
else
|
240
|
+
filepaths.push(File.join(File.dirname(__FILE__), 'fixtures', filename))
|
241
|
+
end
|
242
|
+
}
|
243
|
+
|
244
|
+
invoker = Asciidoctor::Cli::Invoker.new(argv + filepaths)
|
245
|
+
|
246
|
+
invoker.invoke!(&block)
|
247
|
+
invoker
|
248
|
+
end
|
249
|
+
|
250
|
+
def invoke_cli_to_buffer(argv = [], filename = 'sample.asciidoc', &block)
|
251
|
+
invoke_cli(argv, filename, [StringIO.new, StringIO.new], &block)
|
252
|
+
end
|
253
|
+
|
254
|
+
def invoke_cli(argv = [], filename = 'sample.asciidoc', buffers = nil, &block)
|
255
|
+
if filename.nil? || filename == '-' || ::Pathname.new(filename).absolute?
|
256
|
+
filepath = filename
|
257
|
+
else
|
258
|
+
filepath = File.join(File.dirname(__FILE__), 'fixtures', filename)
|
259
|
+
end
|
260
|
+
invoker = Asciidoctor::Cli::Invoker.new(argv + [filepath])
|
261
|
+
if buffers
|
262
|
+
invoker.redirect_streams(*buffers)
|
263
|
+
end
|
264
|
+
invoker.invoke!(&block)
|
265
|
+
invoker
|
266
|
+
end
|
267
|
+
|
268
|
+
def redirect_streams
|
269
|
+
old_stdout, $stdout = $stdout, (tmp_stdout = ::StringIO.new)
|
270
|
+
old_stderr, $stderr = $stderr, (tmp_stderr = ::StringIO.new)
|
271
|
+
yield tmp_stdout, tmp_stderr
|
272
|
+
ensure
|
273
|
+
$stdout, $stderr = old_stdout, old_stderr
|
274
|
+
end
|
275
|
+
|
276
|
+
def resolve_localhost
|
277
|
+
(RUBY_VERSION < '1.9' || RUBY_ENGINE == 'rbx') ? Socket.gethostname :
|
278
|
+
Socket.ip_address_list.find {|addr| addr.ipv4? }.ip_address
|
279
|
+
end
|
280
|
+
|
281
|
+
def using_test_webserver host = resolve_localhost, port = 9876
|
282
|
+
server = TCPServer.new host, port
|
283
|
+
base_dir = File.expand_path File.dirname __FILE__
|
284
|
+
t = Thread.new do
|
285
|
+
while (session = server.accept)
|
286
|
+
request = session.gets
|
287
|
+
resource = nil
|
288
|
+
if (m = /GET (\S+) HTTP\/1\.1$/.match(request.chomp))
|
289
|
+
resource = (resource = m[1]) == '' ? '.' : resource
|
290
|
+
else
|
291
|
+
session.print %(HTTP/1.1 405 Method Not Allowed\r\nContent-Type: text/plain\r\n\r\n)
|
292
|
+
session.print %(405 - Method not allowed\n)
|
293
|
+
session.close
|
294
|
+
break
|
295
|
+
end
|
296
|
+
|
297
|
+
if resource == '/name/asciidoctor'
|
298
|
+
session.print %(HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n)
|
299
|
+
session.print %({"name": "asciidoctor"}\n)
|
300
|
+
elsif File.file?(resource_file = (File.join base_dir, resource))
|
301
|
+
mimetype = if (ext = ::File.extname(resource_file)[1..-1])
|
302
|
+
ext == 'adoc' ? 'text/plain' : %(image/#{ext})
|
303
|
+
else
|
304
|
+
'text/plain'
|
305
|
+
end
|
306
|
+
session.print %(HTTP/1.1 200 OK\r\nContent-Type: #{mimetype}\r\n\r\n)
|
307
|
+
File.open resource_file, 'rb' do |fd|
|
308
|
+
until fd.eof? do
|
309
|
+
buffer = fd.read 256
|
310
|
+
session.write buffer
|
311
|
+
end
|
312
|
+
end
|
313
|
+
else
|
314
|
+
session.print %(HTTP/1.1 404 File Not Found\r\nContent-Type: text/plain\r\n\r\n)
|
315
|
+
session.print %(404 - Resource not found.\n)
|
316
|
+
end
|
317
|
+
session.close
|
318
|
+
end
|
319
|
+
end
|
320
|
+
begin
|
321
|
+
yield
|
322
|
+
ensure
|
323
|
+
begin
|
324
|
+
server.shutdown
|
325
|
+
# "Errno::ENOTCONN: Socket is not connected' is reported on some platforms; call #close instead of #shutdown
|
326
|
+
rescue Errno::ENOTCONN
|
327
|
+
server.close
|
328
|
+
end
|
329
|
+
t.exit
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
###
|
335
|
+
#
|
336
|
+
# Context goodness provided by @citrusbyte's contest.
|
337
|
+
# See https://github.com/citrusbyte/contest
|
338
|
+
#
|
339
|
+
###
|
340
|
+
|
341
|
+
# Contest adds +teardown+, +test+ and +context+ as class methods, and the
|
342
|
+
# instance methods +setup+ and +teardown+ now iterate on the corresponding
|
343
|
+
# blocks. Note that all setup and teardown blocks must be defined with the
|
344
|
+
# block syntax. Adding setup or teardown instance methods defeats the purpose
|
345
|
+
# of this library.
|
346
|
+
class Minitest::Test
|
347
|
+
def self.setup(&block)
|
348
|
+
define_method :setup do
|
349
|
+
super(&block)
|
350
|
+
instance_eval(&block)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
def self.teardown(&block)
|
355
|
+
define_method :teardown do
|
356
|
+
instance_eval(&block)
|
357
|
+
super(&block)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
def self.context(*name, &block)
|
362
|
+
subclass = Class.new(self)
|
363
|
+
remove_tests(subclass)
|
364
|
+
subclass.class_eval(&block) if block_given?
|
365
|
+
const_set(context_name(name.join(" ")), subclass)
|
366
|
+
end
|
367
|
+
|
368
|
+
def self.test(name, &block)
|
369
|
+
define_method(test_name(name), &block)
|
370
|
+
end
|
371
|
+
|
372
|
+
class << self
|
373
|
+
alias_method :should, :test
|
374
|
+
alias_method :describe, :context
|
375
|
+
end
|
376
|
+
|
377
|
+
private
|
378
|
+
|
379
|
+
def self.context_name(name)
|
380
|
+
"Test#{sanitize_name(name).gsub(/(^| )(\w)/) { $2.upcase }}".to_sym
|
381
|
+
end
|
382
|
+
|
383
|
+
def self.test_name(name)
|
384
|
+
"test_#{sanitize_name(name).gsub(/\s+/,'_')}".to_sym
|
385
|
+
end
|
386
|
+
|
387
|
+
def self.sanitize_name(name)
|
388
|
+
name.gsub(/\W+/, ' ').strip
|
389
|
+
end
|
390
|
+
|
391
|
+
def self.remove_tests(subclass)
|
392
|
+
subclass.public_instance_methods.grep(/^test_/).each do |meth|
|
393
|
+
subclass.send(:undef_method, meth.to_sym)
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
def context(*name, &block)
|
399
|
+
Minitest::Test.context(name, &block)
|
400
|
+
end
|
data/test/text_test.rb
CHANGED
@@ -35,7 +35,7 @@ context "Text" do
|
|
35
35
|
input << "[verse]\n"
|
36
36
|
input.concat(File.readlines(sample_doc_path(:encoding)))
|
37
37
|
doc = empty_document
|
38
|
-
reader = Asciidoctor::PreprocessorReader.new doc, input
|
38
|
+
reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
|
39
39
|
block = Asciidoctor::Parser.next_block(reader, doc)
|
40
40
|
assert_xpath '//pre', block.render.gsub(/^\s*\n/, ''), 1
|
41
41
|
end
|
@@ -45,7 +45,7 @@ context "Text" do
|
|
45
45
|
include::fixtures/encoding.asciidoc[tags=romé]
|
46
46
|
EOS
|
47
47
|
doc = empty_safe_document :base_dir => File.expand_path(File.dirname(__FILE__))
|
48
|
-
reader = Asciidoctor::PreprocessorReader.new doc, input
|
48
|
+
reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
|
49
49
|
block = Asciidoctor::Parser.next_block(reader, doc)
|
50
50
|
output = block.render
|
51
51
|
assert_css '.paragraph', output, 1
|
@@ -145,7 +145,7 @@ This line is separated by a horizontal rule...
|
|
145
145
|
bad_variants.each do |variant|
|
146
146
|
good_offsets.each do |offset|
|
147
147
|
input = <<-EOS
|
148
|
-
This line is separated something that is not a horizontal rule...
|
148
|
+
This line is separated by something that is not a horizontal rule...
|
149
149
|
|
150
150
|
#{offset}#{variant}
|
151
151
|
|
@@ -170,7 +170,7 @@ This line is separated something that is not a horizontal rule...
|
|
170
170
|
good_variants.each do |variant|
|
171
171
|
bad_offsets.each do |offset|
|
172
172
|
input = <<-EOS
|
173
|
-
This line is separated something that is not a horizontal rule...
|
173
|
+
This line is separated by something that is not a horizontal rule...
|
174
174
|
|
175
175
|
#{offset}#{variant}
|
176
176
|
|
@@ -187,7 +187,7 @@ This line is separated something that is not a horizontal rule...
|
|
187
187
|
end
|
188
188
|
|
189
189
|
test 'emphasized text with single quote using apostrophe characters' do
|
190
|
-
rsquo =
|
190
|
+
rsquo = decode_char 8217
|
191
191
|
assert_xpath %(//em[text()="Johnny#{rsquo}s"]), render_string(%q(It's 'Johnny's' phone), :attributes => {'compat-mode' => ''})
|
192
192
|
assert_xpath %(//p[text()="It#{rsquo}s 'Johnny#{rsquo}s' phone"]), render_string(%q(It's 'Johnny's' phone))
|
193
193
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: asciimath
|
@@ -21,14 +21,14 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - "~>"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.0.
|
24
|
+
version: 1.0.0
|
25
25
|
type: :development
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - "~>"
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: 1.0.
|
31
|
+
version: 1.0.0
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: coderay
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,14 +49,14 @@ dependencies:
|
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: 2.4.0
|
53
53
|
type: :development
|
54
54
|
prerelease: false
|
55
55
|
version_requirements: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
59
|
+
version: 2.4.0
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: erubis
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,28 +77,28 @@ dependencies:
|
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 5.0.0
|
81
81
|
type: :development
|
82
82
|
prerelease: false
|
83
83
|
version_requirements: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
85
|
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
87
|
+
version: 5.0.0
|
88
88
|
- !ruby/object:Gem::Dependency
|
89
89
|
name: nokogiri
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: 1.
|
94
|
+
version: 1.7.0
|
95
95
|
type: :development
|
96
96
|
prerelease: false
|
97
97
|
version_requirements: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
99
|
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 1.
|
101
|
+
version: 1.7.0
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rake
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,28 +133,28 @@ dependencies:
|
|
133
133
|
requirements:
|
134
134
|
- - "~>"
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version:
|
136
|
+
version: 3.0.0
|
137
137
|
type: :development
|
138
138
|
prerelease: false
|
139
139
|
version_requirements: !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
141
|
- - "~>"
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
143
|
+
version: 3.0.0
|
144
144
|
- !ruby/object:Gem::Dependency
|
145
145
|
name: thread_safe
|
146
146
|
requirement: !ruby/object:Gem::Requirement
|
147
147
|
requirements:
|
148
148
|
- - "~>"
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: 0.3.
|
150
|
+
version: 0.3.0
|
151
151
|
type: :development
|
152
152
|
prerelease: false
|
153
153
|
version_requirements: !ruby/object:Gem::Requirement
|
154
154
|
requirements:
|
155
155
|
- - "~>"
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 0.3.
|
157
|
+
version: 0.3.0
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
name: tilt
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,16 +173,16 @@ dependencies:
|
|
173
173
|
name: yard
|
174
174
|
requirement: !ruby/object:Gem::Requirement
|
175
175
|
requirements:
|
176
|
-
- -
|
176
|
+
- - '='
|
177
177
|
- !ruby/object:Gem::Version
|
178
|
-
version: 0.8
|
178
|
+
version: 0.9.8
|
179
179
|
type: :development
|
180
180
|
prerelease: false
|
181
181
|
version_requirements: !ruby/object:Gem::Requirement
|
182
182
|
requirements:
|
183
|
-
- -
|
183
|
+
- - '='
|
184
184
|
- !ruby/object:Gem::Version
|
185
|
-
version: 0.8
|
185
|
+
version: 0.9.8
|
186
186
|
- !ruby/object:Gem::Dependency
|
187
187
|
name: yard-tomdoc
|
188
188
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,11 +264,16 @@ files:
|
|
264
264
|
- lib/asciidoctor/converter/manpage.rb
|
265
265
|
- lib/asciidoctor/converter/template.rb
|
266
266
|
- lib/asciidoctor/core_ext.rb
|
267
|
+
- lib/asciidoctor/core_ext/1.8.7/hash/key.rb
|
268
|
+
- lib/asciidoctor/core_ext/1.8.7/io/binread.rb
|
269
|
+
- lib/asciidoctor/core_ext/1.8.7/io/write.rb
|
267
270
|
- lib/asciidoctor/core_ext/1.8.7/string/chr.rb
|
268
|
-
- lib/asciidoctor/core_ext/1.8.7/string/
|
271
|
+
- lib/asciidoctor/core_ext/1.8.7/string/limit_bytesize.rb
|
272
|
+
- lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb
|
269
273
|
- lib/asciidoctor/core_ext/1.8.7/symbol/length.rb
|
270
274
|
- lib/asciidoctor/core_ext/nil_or_empty.rb
|
271
|
-
- lib/asciidoctor/core_ext/
|
275
|
+
- lib/asciidoctor/core_ext/regexp/is_match.rb
|
276
|
+
- lib/asciidoctor/core_ext/string/limit_bytesize.rb
|
272
277
|
- lib/asciidoctor/document.rb
|
273
278
|
- lib/asciidoctor/extensions.rb
|
274
279
|
- lib/asciidoctor/helpers.rb
|
@@ -290,6 +295,47 @@ files:
|
|
290
295
|
- test/converter_test.rb
|
291
296
|
- test/document_test.rb
|
292
297
|
- test/extensions_test.rb
|
298
|
+
- test/fixtures/asciidoc_index.txt
|
299
|
+
- test/fixtures/basic-docinfo-footer.html
|
300
|
+
- test/fixtures/basic-docinfo-footer.xml
|
301
|
+
- test/fixtures/basic-docinfo.html
|
302
|
+
- test/fixtures/basic-docinfo.xml
|
303
|
+
- test/fixtures/basic.asciidoc
|
304
|
+
- test/fixtures/chapter-a.adoc
|
305
|
+
- test/fixtures/child-include.adoc
|
306
|
+
- test/fixtures/circle.svg
|
307
|
+
- test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb
|
308
|
+
- test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml
|
309
|
+
- test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml
|
310
|
+
- test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml
|
311
|
+
- test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml
|
312
|
+
- test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim
|
313
|
+
- test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim
|
314
|
+
- test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim
|
315
|
+
- test/fixtures/custom-docinfodir/basic-docinfo.html
|
316
|
+
- test/fixtures/custom-docinfodir/docinfo.html
|
317
|
+
- test/fixtures/docinfo-footer.html
|
318
|
+
- test/fixtures/docinfo-footer.xml
|
319
|
+
- test/fixtures/docinfo.html
|
320
|
+
- test/fixtures/docinfo.xml
|
321
|
+
- test/fixtures/dot.gif
|
322
|
+
- test/fixtures/encoding.asciidoc
|
323
|
+
- test/fixtures/grandchild-include.adoc
|
324
|
+
- test/fixtures/hello-asciidoctor.pdf
|
325
|
+
- test/fixtures/include-file.asciidoc
|
326
|
+
- test/fixtures/include-file.ml
|
327
|
+
- test/fixtures/include-file.xml
|
328
|
+
- test/fixtures/master.adoc
|
329
|
+
- test/fixtures/mismatched-end-tag.adoc
|
330
|
+
- test/fixtures/parent-include-restricted.adoc
|
331
|
+
- test/fixtures/parent-include.adoc
|
332
|
+
- test/fixtures/sample.asciidoc
|
333
|
+
- test/fixtures/stylesheets/custom.css
|
334
|
+
- test/fixtures/subs-docinfo.html
|
335
|
+
- test/fixtures/subs.adoc
|
336
|
+
- test/fixtures/tagged-class-enclosed.rb
|
337
|
+
- test/fixtures/tagged-class.rb
|
338
|
+
- test/fixtures/tip.gif
|
293
339
|
- test/invoker_test.rb
|
294
340
|
- test/links_test.rb
|
295
341
|
- test/lists_test.rb
|
@@ -303,6 +349,7 @@ files:
|
|
303
349
|
- test/sections_test.rb
|
304
350
|
- test/substitutions_test.rb
|
305
351
|
- test/tables_test.rb
|
352
|
+
- test/test_helper.rb
|
306
353
|
- test/text_test.rb
|
307
354
|
homepage: http://asciidoctor.org
|
308
355
|
licenses:
|
@@ -325,7 +372,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
325
372
|
version: '0'
|
326
373
|
requirements: []
|
327
374
|
rubyforge_project:
|
328
|
-
rubygems_version: 2.
|
375
|
+
rubygems_version: 2.6.11
|
329
376
|
signing_key:
|
330
377
|
specification_version: 4
|
331
378
|
summary: An implementation of the AsciiDoc text processor and publishing toolchain
|
@@ -341,6 +388,47 @@ test_files:
|
|
341
388
|
- test/converter_test.rb
|
342
389
|
- test/document_test.rb
|
343
390
|
- test/extensions_test.rb
|
391
|
+
- test/fixtures/asciidoc_index.txt
|
392
|
+
- test/fixtures/basic-docinfo-footer.html
|
393
|
+
- test/fixtures/basic-docinfo-footer.xml
|
394
|
+
- test/fixtures/basic-docinfo.html
|
395
|
+
- test/fixtures/basic-docinfo.xml
|
396
|
+
- test/fixtures/basic.asciidoc
|
397
|
+
- test/fixtures/chapter-a.adoc
|
398
|
+
- test/fixtures/child-include.adoc
|
399
|
+
- test/fixtures/circle.svg
|
400
|
+
- test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb
|
401
|
+
- test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml
|
402
|
+
- test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml
|
403
|
+
- test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml
|
404
|
+
- test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml
|
405
|
+
- test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim
|
406
|
+
- test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim
|
407
|
+
- test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim
|
408
|
+
- test/fixtures/custom-docinfodir/basic-docinfo.html
|
409
|
+
- test/fixtures/custom-docinfodir/docinfo.html
|
410
|
+
- test/fixtures/docinfo-footer.html
|
411
|
+
- test/fixtures/docinfo-footer.xml
|
412
|
+
- test/fixtures/docinfo.html
|
413
|
+
- test/fixtures/docinfo.xml
|
414
|
+
- test/fixtures/dot.gif
|
415
|
+
- test/fixtures/encoding.asciidoc
|
416
|
+
- test/fixtures/grandchild-include.adoc
|
417
|
+
- test/fixtures/hello-asciidoctor.pdf
|
418
|
+
- test/fixtures/include-file.asciidoc
|
419
|
+
- test/fixtures/include-file.ml
|
420
|
+
- test/fixtures/include-file.xml
|
421
|
+
- test/fixtures/master.adoc
|
422
|
+
- test/fixtures/mismatched-end-tag.adoc
|
423
|
+
- test/fixtures/parent-include-restricted.adoc
|
424
|
+
- test/fixtures/parent-include.adoc
|
425
|
+
- test/fixtures/sample.asciidoc
|
426
|
+
- test/fixtures/stylesheets/custom.css
|
427
|
+
- test/fixtures/subs-docinfo.html
|
428
|
+
- test/fixtures/subs.adoc
|
429
|
+
- test/fixtures/tagged-class-enclosed.rb
|
430
|
+
- test/fixtures/tagged-class.rb
|
431
|
+
- test/fixtures/tip.gif
|
344
432
|
- test/invoker_test.rb
|
345
433
|
- test/links_test.rb
|
346
434
|
- test/lists_test.rb
|
@@ -354,5 +442,5 @@ test_files:
|
|
354
442
|
- test/sections_test.rb
|
355
443
|
- test/substitutions_test.rb
|
356
444
|
- test/tables_test.rb
|
445
|
+
- test/test_helper.rb
|
357
446
|
- test/text_test.rb
|
358
|
-
has_rdoc: true
|