asciidoctor 1.5.6.2 → 1.5.7

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.

Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +330 -143
  3. data/README-fr.adoc +441 -0
  4. data/README-jp.adoc +418 -0
  5. data/README-zh_CN.adoc +430 -0
  6. data/README.adoc +454 -0
  7. data/Rakefile +57 -0
  8. data/asciidoctor.gemspec +7 -1
  9. data/data/locale/attributes-ar.adoc +22 -0
  10. data/data/locale/attributes-bg.adoc +22 -0
  11. data/data/locale/attributes-ca.adoc +22 -0
  12. data/data/locale/attributes-cs.adoc +22 -0
  13. data/data/locale/attributes-da.adoc +22 -0
  14. data/data/locale/attributes-de.adoc +22 -0
  15. data/data/locale/attributes-en.adoc +23 -0
  16. data/data/locale/attributes-es.adoc +22 -0
  17. data/data/locale/attributes-fa.adoc +22 -0
  18. data/data/locale/attributes-fi.adoc +22 -0
  19. data/data/locale/attributes-fr.adoc +22 -0
  20. data/data/locale/attributes-hu.adoc +22 -0
  21. data/data/locale/attributes-id.adoc +22 -0
  22. data/data/locale/attributes-it.adoc +22 -0
  23. data/data/locale/attributes-ja.adoc +22 -0
  24. data/data/locale/attributes-kr.adoc +22 -0
  25. data/data/locale/attributes-nb.adoc +22 -0
  26. data/data/locale/attributes-nl.adoc +22 -0
  27. data/data/locale/attributes-nn.adoc +22 -0
  28. data/data/locale/attributes-pl.adoc +22 -0
  29. data/data/locale/attributes-pt.adoc +22 -0
  30. data/data/locale/attributes-pt_BR.adoc +22 -0
  31. data/data/locale/attributes-ro.adoc +22 -0
  32. data/data/locale/attributes-ru.adoc +22 -0
  33. data/data/locale/attributes-sr.adoc +22 -0
  34. data/data/locale/attributes-sr_Latn.adoc +22 -0
  35. data/data/locale/attributes-tr.adoc +22 -0
  36. data/data/locale/attributes-uk.adoc +22 -0
  37. data/data/locale/attributes-zh_CN.adoc +22 -0
  38. data/data/locale/attributes-zh_TW.adoc +22 -0
  39. data/data/locale/attributes.adoc +8 -649
  40. data/data/stylesheets/asciidoctor-default.css +77 -72
  41. data/features/xref.feature +366 -7
  42. data/lib/asciidoctor.rb +107 -93
  43. data/lib/asciidoctor/abstract_block.rb +247 -239
  44. data/lib/asciidoctor/abstract_node.rb +56 -58
  45. data/lib/asciidoctor/block.rb +3 -3
  46. data/lib/asciidoctor/callouts.rb +1 -1
  47. data/lib/asciidoctor/cli/invoker.rb +36 -9
  48. data/lib/asciidoctor/cli/options.rb +63 -25
  49. data/lib/asciidoctor/converter.rb +23 -13
  50. data/lib/asciidoctor/converter/base.rb +4 -0
  51. data/lib/asciidoctor/converter/docbook45.rb +16 -9
  52. data/lib/asciidoctor/converter/docbook5.rb +115 -97
  53. data/lib/asciidoctor/converter/factory.rb +29 -31
  54. data/lib/asciidoctor/converter/html5.rb +229 -192
  55. data/lib/asciidoctor/converter/manpage.rb +72 -50
  56. data/lib/asciidoctor/converter/template.rb +12 -12
  57. data/lib/asciidoctor/core_ext.rb +5 -1
  58. data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +6 -0
  59. data/lib/asciidoctor/document.rb +168 -77
  60. data/lib/asciidoctor/extensions.rb +79 -47
  61. data/lib/asciidoctor/helpers.rb +33 -11
  62. data/lib/asciidoctor/inline.rb +3 -2
  63. data/lib/asciidoctor/list.rb +2 -1
  64. data/lib/asciidoctor/logging.rb +122 -0
  65. data/lib/asciidoctor/parser.rb +406 -382
  66. data/lib/asciidoctor/path_resolver.rb +169 -162
  67. data/lib/asciidoctor/reader.rb +166 -121
  68. data/lib/asciidoctor/section.rb +45 -28
  69. data/lib/asciidoctor/stylesheets.rb +13 -5
  70. data/lib/asciidoctor/substitutors.rb +328 -254
  71. data/lib/asciidoctor/table.rb +105 -48
  72. data/lib/asciidoctor/timings.rb +34 -6
  73. data/lib/asciidoctor/version.rb +1 -1
  74. data/man/asciidoctor.1 +41 -23
  75. data/man/asciidoctor.adoc +14 -8
  76. data/test/api_test.rb +1004 -0
  77. data/test/attributes_test.rb +241 -50
  78. data/test/blocks_test.rb +549 -124
  79. data/test/converter_test.rb +170 -78
  80. data/test/document_test.rb +208 -767
  81. data/test/extensions_test.rb +188 -53
  82. data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +1 -1
  83. data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +1 -1
  84. data/test/fixtures/file-with-missing-include.adoc +1 -0
  85. data/test/fixtures/include-file.jsx +8 -0
  86. data/test/fixtures/lists.adoc +96 -0
  87. data/test/fixtures/other-chapters.adoc +11 -0
  88. data/test/fixtures/outer-include.adoc +5 -0
  89. data/test/fixtures/sample.asciidoc +5 -1
  90. data/test/fixtures/subdir/index.adoc +3 -0
  91. data/test/fixtures/subdir/inner-include.adoc +3 -0
  92. data/test/fixtures/subdir/middle-include.adoc +5 -0
  93. data/test/fixtures/tagged-class-enclosed.rb +0 -1
  94. data/test/fixtures/unclosed-tag.adoc +3 -0
  95. data/test/fixtures/unexpected-end-tag.adoc +4 -0
  96. data/test/invoker_test.rb +101 -40
  97. data/test/links_test.rb +266 -72
  98. data/test/lists_test.rb +243 -45
  99. data/test/logger_test.rb +211 -0
  100. data/test/manpage_test.rb +124 -6
  101. data/test/options_test.rb +46 -1
  102. data/test/paragraphs_test.rb +23 -10
  103. data/test/parser_test.rb +30 -1
  104. data/test/paths_test.rb +115 -33
  105. data/test/preamble_test.rb +1 -1
  106. data/test/reader_test.rb +337 -81
  107. data/test/sections_test.rb +656 -72
  108. data/test/substitutions_test.rb +182 -57
  109. data/test/tables_test.rb +324 -57
  110. data/test/test_helper.rb +77 -32
  111. data/test/text_test.rb +7 -7
  112. metadata +67 -3
@@ -1,4 +1,4 @@
1
- aside id=@id class=(attr 'role')
1
+ aside id=id class="#{role}"
2
2
  - if title?
3
3
  header
4
4
  h1=title
@@ -0,0 +1 @@
1
+ include::no-such-file.adoc[]
@@ -0,0 +1,8 @@
1
+ const element = (
2
+ <div>
3
+ <h1>Hello, Programmer!</h1>
4
+ <!-- tag::snippet[] -->
5
+ <p>Welcome to the club.</p>
6
+ <!-- end::snippet[] -->
7
+ </div>
8
+ )
@@ -0,0 +1,96 @@
1
+ = Document Title
2
+ Doc Writer <thedoc@asciidoctor.org>
3
+
4
+ Preamble paragraph.
5
+
6
+ NOTE: This is test, only a test.
7
+
8
+ == Lists
9
+
10
+ .Unordered, basic
11
+ * Edgar Allen Poe
12
+ * Sheri S. Tepper
13
+ * Bill Bryson
14
+
15
+ .Unordered, max nesting
16
+ * level 1
17
+ ** level 2
18
+ *** level 3
19
+ **** level 4
20
+ ***** level 5
21
+ * level 1
22
+
23
+ .Checklist
24
+ - [*] checked
25
+ - [x] also checked
26
+ - [ ] not checked
27
+ - normal list item
28
+
29
+ .Ordered, basic
30
+ . Step 1
31
+ . Step 2
32
+ . Step 3
33
+
34
+ .Ordered, nested
35
+ . Step 1
36
+ . Step 2
37
+ .. Step 2a
38
+ .. Step 2b
39
+ . Step 3
40
+
41
+ .Ordered, max nesting
42
+ . level 1
43
+ .. level 2
44
+ ... level 3
45
+ .... level 4
46
+ ..... level 5
47
+ . level 1
48
+
49
+ .Labeled, single-line
50
+ first term:: definition of first term
51
+ section term:: definition of second term
52
+
53
+ .Labeled, multi-line
54
+ first term::
55
+ definition of first term
56
+ second term::
57
+ definition of second term
58
+
59
+ .Q&A
60
+ [qanda]
61
+ What is Asciidoctor?::
62
+ An implementation of the AsciiDoc processor in Ruby.
63
+ What is the answer to the Ultimate Question?:: 42
64
+
65
+ .Mixed
66
+ Operating Systems::
67
+ Linux:::
68
+ . Fedora
69
+ * Desktop
70
+ . Ubuntu
71
+ * Desktop
72
+ * Server
73
+ BSD:::
74
+ . FreeBSD
75
+ . NetBSD
76
+
77
+ Cloud Providers::
78
+ PaaS:::
79
+ . OpenShift
80
+ . CloudBees
81
+ IaaS:::
82
+ . Amazon EC2
83
+ . Rackspace
84
+
85
+ .Unordered, complex
86
+ * level 1
87
+ ** level 2
88
+ *** level 3
89
+ This is a new line inside an unordered list using {plus} symbol.
90
+ We can even force content to start on a separate line... +
91
+ Amazing, isn't it?
92
+ **** level 4
93
+ +
94
+ The {plus} symbol is on a new line.
95
+
96
+ ***** level 5
@@ -0,0 +1,11 @@
1
+ // tag::ch2[]
2
+ [#ch2]
3
+ == Chapter 2
4
+
5
+ The plot thickens.
6
+ // end::ch2[]
7
+
8
+ [#ch3]
9
+ == Chapter 3
10
+
11
+ The plot runs its course, predictably.
@@ -0,0 +1,5 @@
1
+ first line of outer
2
+
3
+ include::subdir/middle-include.adoc[]
4
+
5
+ last line of outer
@@ -19,8 +19,12 @@ NOTE: This is test, only a test.
19
19
 
20
20
  *Section B* paragraph.
21
21
 
22
+ |===
23
+ |a |b |c
24
+ |1 |2 |3
25
+ |===
26
+
22
27
  .Section B list
23
28
  * Item 1
24
29
  * Item 2
25
30
  * Item 3
26
-
@@ -0,0 +1,3 @@
1
+ = Sample Document
2
+
3
+ content
@@ -0,0 +1,3 @@
1
+ first line of inner
2
+
3
+ last line of inner
@@ -0,0 +1,5 @@
1
+ first line of middle
2
+
3
+ include::inner-include.adoc[]
4
+
5
+ last line of middle
@@ -17,7 +17,6 @@ class Dog
17
17
  'woof woof'
18
18
  #end::bark-other[]
19
19
  #tag::bark-all[]
20
- #tag::bark-all[]
21
20
  end
22
21
  #end::bark-all[]
23
22
  end
@@ -0,0 +1,3 @@
1
+ x
2
+ // tag::a[]
3
+ a
@@ -0,0 +1,4 @@
1
+ // tag::a[]
2
+ a
3
+ // end::a[]
4
+ // end::a[]
@@ -33,8 +33,8 @@ context 'Invoker' do
33
33
  end
34
34
 
35
35
  test 'should set implicit doc info attributes' do
36
- sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc'))
37
- sample_filedir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
36
+ sample_filepath = fixture_path 'sample.asciidoc'
37
+ sample_filedir = fixturedir
38
38
  invoker = invoke_cli_to_buffer %w(-o /dev/null), sample_filepath
39
39
  doc = invoker.document
40
40
  assert_equal 'sample', doc.attr('docname')
@@ -48,7 +48,7 @@ context 'Invoker' do
48
48
  end
49
49
 
50
50
  test 'should allow docdate and doctime to be overridden' do
51
- sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc'))
51
+ sample_filepath = fixture_path 'sample.asciidoc'
52
52
  invoker = invoke_cli_to_buffer %w(-o /dev/null -a docdate=2015-01-01 -a doctime=10:00:00-07:00), sample_filepath
53
53
  doc = invoker.document
54
54
  assert doc.attr?('docdate', '2015-01-01')
@@ -86,7 +86,7 @@ context 'Invoker' do
86
86
  end
87
87
 
88
88
  test 'should accept document from stdin and write to output file' do
89
- sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html'))
89
+ sample_outpath = fixture_path 'sample-output.html'
90
90
  begin
91
91
  invoker = invoke_cli(%W(-s -o #{sample_outpath}), '-') { 'content' }
92
92
  doc = invoker.document
@@ -111,13 +111,13 @@ context 'Invoker' do
111
111
  end
112
112
 
113
113
  test 'should fail if input file matches specified output file' do
114
- sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc'))
114
+ sample_outpath = fixture_path 'sample.asciidoc'
115
115
  invoker = invoke_cli_to_buffer %W(-o #{sample_outpath}), 'sample.asciidoc'
116
116
  assert_match(/input file and output file cannot be the same/, invoker.read_error)
117
117
  end
118
118
 
119
119
  test 'should accept input from named pipe and output to stdout' do
120
- sample_inpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-pipe.adoc'))
120
+ sample_inpath = fixture_path 'sample-pipe.adoc'
121
121
  begin
122
122
  %x(mkfifo #{sample_inpath})
123
123
  write_thread = Thread.new do
@@ -133,7 +133,7 @@ context 'Invoker' do
133
133
  end if RUBY_MIN_VERSION_1_9 && !windows?
134
134
 
135
135
  test 'should allow docdir to be specified when input is a string' do
136
- expected_docdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
136
+ expected_docdir = fixturedir
137
137
  invoker = invoke_cli_to_buffer(%w(-s --base-dir test/fixtures -o /dev/null), '-') { 'content' }
138
138
  doc = invoker.document
139
139
  assert_equal expected_docdir, doc.attr('docdir')
@@ -141,7 +141,7 @@ context 'Invoker' do
141
141
  end
142
142
 
143
143
  test 'should display version and exit' do
144
- expected = %(Asciidoctor #{Asciidoctor::VERSION} [http://asciidoctor.org]\nRuntime Environment (#{RUBY_DESCRIPTION}))
144
+ expected = %(Asciidoctor #{Asciidoctor::VERSION} [https://asciidoctor.org]\nRuntime Environment (#{RUBY_DESCRIPTION}))
145
145
  ['--version', '-V'].each do |switch|
146
146
  actual = nil
147
147
  redirect_streams do |out, err|
@@ -179,6 +179,18 @@ context 'Invoker' do
179
179
  assert_equal '', warnings
180
180
  end
181
181
 
182
+ test 'should return non-zero exit code if failure level is reached' do
183
+ input = <<-EOS
184
+ 2. second
185
+ 3. third
186
+ EOS
187
+ exit_code, messages = redirect_streams do |_, err|
188
+ [invoke_cli(%w(-q --failure-level=WARN -o /dev/null), '-') { input }.code, err.string]
189
+ end
190
+ assert_equal 1, exit_code
191
+ assert messages.empty?
192
+ end
193
+
182
194
  test 'should report usage if no input file given' do
183
195
  redirect_streams do |out, err|
184
196
  invoke_cli [], nil
@@ -189,7 +201,7 @@ context 'Invoker' do
189
201
  test 'should report error if input file does not exist' do
190
202
  redirect_streams do |out, err|
191
203
  invoker = invoke_cli [], 'missing_file.asciidoc'
192
- assert_match(/input file .* missing or cannot be read/, err.string)
204
+ assert_match(/input file .* is missing/, err.string)
193
205
  assert_equal 1, invoker.code
194
206
  end
195
207
  end
@@ -197,13 +209,13 @@ context 'Invoker' do
197
209
  test 'should treat extra arguments as files' do
198
210
  redirect_streams do |out, err|
199
211
  invoker = invoke_cli %w(-o /dev/null extra arguments sample.asciidoc), nil
200
- assert_match(/input file .* missing or cannot be read/, err.string)
212
+ assert_match(/input file .* is missing/, err.string)
201
213
  assert_equal 1, invoker.code
202
214
  end
203
215
  end
204
216
 
205
217
  test 'should output to file name based on input file name' do
206
- sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.html'))
218
+ sample_outpath = fixture_path 'sample.html'
207
219
  begin
208
220
  invoker = invoke_cli
209
221
  doc = invoker.document
@@ -222,8 +234,8 @@ context 'Invoker' do
222
234
  end
223
235
 
224
236
  test 'should output to file in destination directory if set' do
225
- destination_path = File.expand_path(File.join(File.dirname(__FILE__), 'test_output'))
226
- sample_outpath = File.join(destination_path, 'sample.html')
237
+ destination_path = File.join testdir, 'test_output'
238
+ sample_outpath = File.join destination_path, 'sample.html'
227
239
  begin
228
240
  FileUtils.mkdir_p(destination_path)
229
241
  # QUESTION should -D be relative to working directory or source directory?
@@ -238,8 +250,25 @@ context 'Invoker' do
238
250
  end
239
251
  end
240
252
 
253
+ test 'should preserve directory structure in destination directory if source directory is set' do
254
+ sample_inpath = 'subdir/index.adoc'
255
+ destination_path = 'test_output'
256
+ destination_subdir_path = File.join destination_path, 'subdir'
257
+ sample_outpath = File.join destination_subdir_path, 'index.html'
258
+ begin
259
+ FileUtils.mkdir_p(destination_path)
260
+ invoke_cli %W(-D #{destination_path} -R test/fixtures), sample_inpath
261
+ assert File.directory?(destination_subdir_path)
262
+ assert File.exist?(sample_outpath)
263
+ ensure
264
+ FileUtils.rm_f(sample_outpath)
265
+ FileUtils.rmdir(destination_subdir_path)
266
+ FileUtils.rmdir(destination_path)
267
+ end
268
+ end
269
+
241
270
  test 'should output to file specified' do
242
- sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html'))
271
+ sample_outpath = fixture_path 'sample-output.html'
243
272
  begin
244
273
  invoker = invoke_cli %W(-o #{sample_outpath})
245
274
  doc = invoker.document
@@ -251,9 +280,9 @@ context 'Invoker' do
251
280
  end
252
281
 
253
282
  test 'should copy default stylesheet to target directory if linkcss is specified' do
254
- sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html'))
255
- asciidoctor_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'asciidoctor.css'))
256
- coderay_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'coderay-asciidoctor.css'))
283
+ sample_outpath = fixture_path 'sample-output.html'
284
+ asciidoctor_stylesheet = fixture_path 'asciidoctor.css'
285
+ coderay_stylesheet = fixture_path 'coderay-asciidoctor.css'
257
286
  begin
258
287
  invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a source-highlighter=coderay)
259
288
  invoker.document
@@ -268,8 +297,8 @@ context 'Invoker' do
268
297
  end
269
298
 
270
299
  test 'should not copy default stylesheet to target directory if linkcss is set and copycss is unset' do
271
- sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html'))
272
- default_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'asciidoctor.css'))
300
+ sample_outpath = fixture_path 'sample-output.html'
301
+ default_stylesheet = fixture_path 'asciidoctor.css'
273
302
  begin
274
303
  invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a copycss!)
275
304
  invoker.document
@@ -282,7 +311,7 @@ context 'Invoker' do
282
311
  end
283
312
 
284
313
  test 'should copy custom stylesheet to target directory if stylesheet and linkcss is specified' do
285
- destdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'output'))
314
+ destdir = fixture_path 'output'
286
315
  sample_outpath = File.join destdir, 'sample-output.html'
287
316
  stylesdir = File.join destdir, 'styles'
288
317
  custom_stylesheet = File.join stylesdir, 'custom.css'
@@ -300,7 +329,7 @@ context 'Invoker' do
300
329
  end
301
330
 
302
331
  test 'should not copy custom stylesheet to target directory if stylesheet and linkcss are set and copycss is unset' do
303
- destdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'output'))
332
+ destdir = fixture_path 'output'
304
333
  sample_outpath = File.join destdir, 'sample-output.html'
305
334
  stylesdir = File.join destdir, 'styles'
306
335
  custom_stylesheet = File.join stylesdir, 'custom.css'
@@ -318,7 +347,7 @@ context 'Invoker' do
318
347
  end
319
348
 
320
349
  test 'should not copy custom stylesheet to target directory if stylesdir is a URI' do
321
- destdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'output'))
350
+ destdir = fixture_path 'output'
322
351
  sample_outpath = File.join destdir, 'sample-output.html'
323
352
  stylesdir = File.join destdir, 'http:'
324
353
  begin
@@ -334,8 +363,8 @@ context 'Invoker' do
334
363
  end
335
364
 
336
365
  test 'should render all passed files' do
337
- basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html'))
338
- sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.html'))
366
+ basic_outpath = fixture_path 'basic.html'
367
+ sample_outpath = fixture_path 'sample.html'
339
368
  begin
340
369
  invoke_cli_with_filenames [], %w(basic.asciidoc sample.asciidoc)
341
370
  assert File.exist?(basic_outpath)
@@ -347,9 +376,9 @@ context 'Invoker' do
347
376
  end
348
377
 
349
378
  test 'options should not be modified when processing multiple files' do
350
- destination_path = File.expand_path(File.join(File.dirname(__FILE__), 'test_output'))
351
- basic_outpath = File.join(destination_path, 'basic.htm')
352
- sample_outpath = File.join(destination_path, 'sample.htm')
379
+ destination_path = File.join testdir, 'test_output'
380
+ basic_outpath = File.join destination_path, 'basic.htm'
381
+ sample_outpath = File.join destination_path, 'sample.htm'
353
382
  begin
354
383
  invoke_cli_with_filenames %w(-D test/test_output -a outfilesuffix=.htm), %w(basic.asciidoc sample.asciidoc)
355
384
  assert File.exist?(basic_outpath)
@@ -362,7 +391,7 @@ context 'Invoker' do
362
391
  end
363
392
 
364
393
  test 'should render all files that matches a glob expression' do
365
- basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html'))
394
+ basic_outpath = fixture_path 'basic.html'
366
395
  begin
367
396
  invoke_cli_to_buffer [], "ba*.asciidoc"
368
397
  assert File.exist?(basic_outpath)
@@ -372,8 +401,8 @@ context 'Invoker' do
372
401
  end
373
402
 
374
403
  test 'should render all files that matches an absolute path glob expression' do
375
- basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html'))
376
- glob = File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures', 'ba*.asciidoc')
404
+ basic_outpath = fixture_path 'basic.html'
405
+ glob = fixture_path 'ba*.asciidoc'
377
406
  # test Windows using backslash-style pathname
378
407
  if File::ALT_SEPARATOR == '\\'
379
408
  glob = glob.tr '/', '\\'
@@ -394,6 +423,38 @@ context 'Invoker' do
394
423
  assert_xpath '/*[@id="preamble"]', output, 1
395
424
  end
396
425
 
426
+ test 'should write page for each alternate manname' do
427
+ outdir = fixturedir
428
+ outfile_1 = File.join outdir, 'eve.1'
429
+ outfile_2 = File.join outdir, 'islifeform.1'
430
+ input = <<-EOS
431
+ = eve(1)
432
+ Andrew Stanton
433
+ v1.0.0
434
+ :doctype: manpage
435
+ :manmanual: EVE
436
+ :mansource: EVE
437
+
438
+ == NAME
439
+
440
+ eve, islifeform - analyzes an image to determine if it's a picture of a life form
441
+
442
+ == SYNOPSIS
443
+
444
+ *eve* ['OPTION']... 'FILE'...
445
+ EOS
446
+
447
+ begin
448
+ invoke_cli(%W(-b manpage -o #{outfile_1}), '-') { input }
449
+ assert File.exist?(outfile_1)
450
+ assert File.exist?(outfile_2)
451
+ assert_equal '.so eve.1', (IO.read outfile_2).chomp
452
+ ensure
453
+ FileUtils.rm_f outfile_1
454
+ FileUtils.rm_f outfile_2
455
+ end
456
+ end
457
+
397
458
  test 'should output a trailing endline to stdout' do
398
459
  invoker = nil
399
460
  output = nil
@@ -467,18 +528,18 @@ context 'Invoker' do
467
528
  end
468
529
 
469
530
  test 'should locate custom templates based on template dir, template engine and backend' do
470
- custom_backend_root = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends'))
531
+ custom_backend_root = fixture_path 'custom-backends'
471
532
  invoker = invoke_cli_to_buffer %W(-E haml -T #{custom_backend_root} -o -)
472
533
  doc = invoker.document
473
- assert doc.converter.is_a? Asciidoctor::Converter::CompositeConverter
534
+ assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter
474
535
  selected = doc.converter.find_converter 'paragraph'
475
- assert selected.is_a? Asciidoctor::Converter::TemplateConverter
476
- assert selected.templates['paragraph'].is_a? Tilt::HamlTemplate
536
+ assert_kind_of Asciidoctor::Converter::TemplateConverter, selected
537
+ assert_kind_of Tilt::HamlTemplate, selected.templates['paragraph']
477
538
  end
478
539
 
479
540
  test 'should load custom templates from multiple template directories' do
480
- custom_backend_1 = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends/haml/html5'))
481
- custom_backend_2 = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends/haml/html5-tweaks'))
541
+ custom_backend_1 = fixture_path 'custom-backends/haml/html5'
542
+ custom_backend_2 = fixture_path 'custom-backends/haml/html5-tweaks'
482
543
  invoker = invoke_cli_to_buffer %W(-T #{custom_backend_1} -T #{custom_backend_2} -o - -s)
483
544
  output = invoker.read_output
484
545
  assert_css '.paragraph', output, 0
@@ -568,7 +629,7 @@ context 'Invoker' do
568
629
  end
569
630
 
570
631
  test 'should force default external encoding to UTF-8' do
571
- executable = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'asciidoctor'))
632
+ executable = File.join ASCIIDOCTOR_PROJECT_DIR, 'bin', 'asciidoctor'
572
633
  input_path = fixture_path 'encoding.asciidoc'
573
634
  old_lang = ENV['LANG']
574
635
  ENV['LANG'] = 'US-ASCII'
@@ -586,7 +647,7 @@ context 'Invoker' do
586
647
  refute_empty stdout_lines
587
648
  stdout_lines.each {|l| l.force_encoding Encoding::UTF_8 } if Asciidoctor::FORCE_ENCODING
588
649
  stdout_str = stdout_lines.join
589
- assert stdout_str.include?('Codierungen sind verrückt auf älteren Versionen von Ruby')
650
+ assert_includes stdout_str, 'Codierungen sind verrückt auf älteren Versionen von Ruby'
590
651
  ensure
591
652
  ENV['LANG'] = old_lang
592
653
  end
@@ -611,7 +672,7 @@ context 'Invoker' do
611
672
  old_source_date_epoch = ENV.delete 'SOURCE_DATE_EPOCH'
612
673
  begin
613
674
  ENV['SOURCE_DATE_EPOCH'] = '1234123412'
614
- sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc'))
675
+ sample_filepath = fixture_path 'sample.asciidoc'
615
676
  invoker = invoke_cli_to_buffer %w(-o /dev/null), sample_filepath
616
677
  doc = invoker.document
617
678
  assert_equal '2009-02-08', (doc.attr 'docdate')
@@ -633,7 +694,7 @@ context 'Invoker' do
633
694
  old_source_date_epoch = ENV.delete 'SOURCE_DATE_EPOCH'
634
695
  begin
635
696
  ENV['SOURCE_DATE_EPOCH'] = 'aaaaaaaa'
636
- sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc'))
697
+ sample_filepath = fixture_path 'sample.asciidoc'
637
698
  assert_equal 1, (invoke_cli_to_buffer %w(-o /dev/null), sample_filepath).code
638
699
  ensure
639
700
  if old_source_date_epoch