asciidoctor 0.1.0 → 0.1.1
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.
- data/README.asciidoc +11 -2
- data/asciidoctor.gemspec +3 -2
- data/lib/asciidoctor.rb +95 -62
- data/lib/asciidoctor/abstract_block.rb +7 -5
- data/lib/asciidoctor/abstract_node.rb +63 -15
- data/lib/asciidoctor/attribute_list.rb +3 -1
- data/lib/asciidoctor/backends/base_template.rb +17 -7
- data/lib/asciidoctor/backends/docbook45.rb +182 -150
- data/lib/asciidoctor/backends/html5.rb +138 -110
- data/lib/asciidoctor/block.rb +21 -18
- data/lib/asciidoctor/callouts.rb +3 -1
- data/lib/asciidoctor/cli/invoker.rb +3 -3
- data/lib/asciidoctor/cli/options.rb +6 -6
- data/lib/asciidoctor/debug.rb +7 -6
- data/lib/asciidoctor/document.rb +197 -25
- data/lib/asciidoctor/errors.rb +1 -1
- data/lib/asciidoctor/helpers.rb +29 -0
- data/lib/asciidoctor/inline.rb +11 -4
- data/lib/asciidoctor/lexer.rb +338 -182
- data/lib/asciidoctor/list_item.rb +14 -12
- data/lib/asciidoctor/reader.rb +423 -206
- data/lib/asciidoctor/renderer.rb +59 -15
- data/lib/asciidoctor/section.rb +7 -4
- data/lib/asciidoctor/substituters.rb +536 -511
- data/lib/asciidoctor/table.rb +473 -472
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +23 -14
- data/man/asciidoctor.ad +13 -7
- data/test/attributes_test.rb +42 -8
- data/test/blocks_test.rb +161 -1
- data/test/document_test.rb +134 -16
- data/test/invoker_test.rb +14 -6
- data/test/lexer_test.rb +45 -18
- data/test/lists_test.rb +79 -0
- data/test/paragraphs_test.rb +9 -1
- data/test/reader_test.rb +456 -19
- data/test/sections_test.rb +19 -0
- data/test/substitutions_test.rb +14 -12
- data/test/tables_test.rb +10 -10
- metadata +3 -5
data/test/sections_test.rb
CHANGED
@@ -473,6 +473,25 @@ Details
|
|
473
473
|
assert_xpath '(//h2)[2][text()="Appendix B: Migration"]', output, 1
|
474
474
|
end
|
475
475
|
|
476
|
+
test 'should not number level 4 section' do
|
477
|
+
input = <<-EOS
|
478
|
+
:numbered:
|
479
|
+
|
480
|
+
== Level_1
|
481
|
+
|
482
|
+
=== Level_2
|
483
|
+
|
484
|
+
==== Level_3
|
485
|
+
|
486
|
+
===== Level_4
|
487
|
+
|
488
|
+
text
|
489
|
+
EOS
|
490
|
+
output = render_embedded_string input
|
491
|
+
assert_xpath '//h5', output, 1
|
492
|
+
assert_xpath '//h5[text()="Level_4"]', output, 1
|
493
|
+
end
|
494
|
+
|
476
495
|
test 'should not number special sections or subsections' do
|
477
496
|
input = <<-EOS
|
478
497
|
:numbered:
|
data/test/substitutions_test.rb
CHANGED
@@ -314,27 +314,29 @@ context 'Substitutions' do
|
|
314
314
|
|
315
315
|
test 'a single-line image macro should be interpreted as an image' do
|
316
316
|
para = block_from_string('image:tiger.png[]')
|
317
|
-
assert_equal %{<span class="image"
|
317
|
+
assert_equal %{<span class="image"><img src="tiger.png" alt="tiger"></span>}, para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
|
318
318
|
end
|
319
319
|
|
320
320
|
test 'a single-line image macro with text should be interpreted as an image with alt text' do
|
321
321
|
para = block_from_string('image:tiger.png[Tiger]')
|
322
|
-
assert_equal %{<span class="image"
|
322
|
+
assert_equal %{<span class="image"><img src="tiger.png" alt="Tiger"></span>}, para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
|
323
323
|
end
|
324
324
|
|
325
325
|
test 'a single-line image macro with text and dimensions should be interpreted as an image with alt text and dimensions' do
|
326
326
|
para = block_from_string('image:tiger.png[Tiger, 200, 100]')
|
327
|
-
assert_equal %{<span class="image"
|
327
|
+
assert_equal %{<span class="image"><img src="tiger.png" alt="Tiger" width="200" height="100"></span>},
|
328
|
+
para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
|
328
329
|
end
|
329
330
|
|
330
331
|
test 'a single-line image macro with text and link should be interpreted as a linked image with alt text' do
|
331
332
|
para = block_from_string('image:tiger.png[Tiger, link="http://en.wikipedia.org/wiki/Tiger"]')
|
332
|
-
assert_equal %{<span class="image"
|
333
|
+
assert_equal %{<span class="image"><a class="image" href="http://en.wikipedia.org/wiki/Tiger"><img src="tiger.png" alt="Tiger"></a></span>},
|
334
|
+
para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
|
333
335
|
end
|
334
336
|
|
335
337
|
test 'a single-line footnote macro should be registered and rendered as a footnote' do
|
336
338
|
para = block_from_string('Sentence text footnote:[An example footnote.].')
|
337
|
-
assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" href="#_footnote_1" title="View footnote."
|
339
|
+
assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
|
338
340
|
assert_equal 1, para.document.references[:footnotes].size
|
339
341
|
footnote = para.document.references[:footnotes].first
|
340
342
|
assert_equal 1, footnote.index
|
@@ -344,7 +346,7 @@ context 'Substitutions' do
|
|
344
346
|
|
345
347
|
test 'a multi-line footnote macro should be registered and rendered as a footnote' do
|
346
348
|
para = block_from_string("Sentence text footnote:[An example footnote\nwith wrapped text.].")
|
347
|
-
assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" href="#_footnote_1" title="View footnote."
|
349
|
+
assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
|
348
350
|
assert_equal 1, para.document.references[:footnotes].size
|
349
351
|
footnote = para.document.references[:footnotes].first
|
350
352
|
assert_equal 1, footnote.index
|
@@ -354,12 +356,12 @@ context 'Substitutions' do
|
|
354
356
|
|
355
357
|
test 'a footnote macro can be directly adjacent to preceding word' do
|
356
358
|
para = block_from_string('Sentence textfootnote:[An example footnote.].')
|
357
|
-
assert_equal %(Sentence text<span class="footnote">[<a id="_footnoteref_1" href="#_footnote_1" title="View footnote."
|
359
|
+
assert_equal %(Sentence text<span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
|
358
360
|
end
|
359
361
|
|
360
362
|
test 'a footnote macro may contain a macro' do
|
361
363
|
para = block_from_string('Share your code. footnote:[http://github.com[GitHub]]')
|
362
|
-
assert_equal %(Share your code. <span class="footnote">[<a id="_footnoteref_1" href="#_footnote_1" title="View footnote."
|
364
|
+
assert_equal %(Share your code. <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>), para.sub_macros(para.buffer.join)
|
363
365
|
assert_equal 1, para.document.references[:footnotes].size
|
364
366
|
footnote1 = para.document.references[:footnotes][0]
|
365
367
|
assert_equal '<a href="http://github.com">GitHub</a>', footnote1.text
|
@@ -367,7 +369,7 @@ context 'Substitutions' do
|
|
367
369
|
|
368
370
|
test 'should increment index of subsequent footnote macros' do
|
369
371
|
para = block_from_string("Sentence text footnote:[An example footnote.]. Sentence text footnote:[Another footnote.].")
|
370
|
-
assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" href="#_footnote_1" title="View footnote."
|
372
|
+
assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>. Sentence text <span class="footnote">[<a id="_footnoteref_2" class="footnote" href="#_footnote_2" title="View footnote.">2</a>]</span>.), para.sub_macros(para.buffer.join)
|
371
373
|
assert_equal 2, para.document.references[:footnotes].size
|
372
374
|
footnote1 = para.document.references[:footnotes][0]
|
373
375
|
assert_equal 1, footnote1.index
|
@@ -381,7 +383,7 @@ context 'Substitutions' do
|
|
381
383
|
|
382
384
|
test 'a footnoteref macro with id and single-line text should be registered and rendered as a footnote' do
|
383
385
|
para = block_from_string('Sentence text footnoteref:[ex1, An example footnote.].')
|
384
|
-
assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" href="#_footnote_1" title="View footnote."
|
386
|
+
assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
|
385
387
|
assert_equal 1, para.document.references[:footnotes].size
|
386
388
|
footnote = para.document.references[:footnotes].first
|
387
389
|
assert_equal 1, footnote.index
|
@@ -391,7 +393,7 @@ context 'Substitutions' do
|
|
391
393
|
|
392
394
|
test 'a footnoteref macro with id and multi-line text should be registered and rendered as a footnote' do
|
393
395
|
para = block_from_string("Sentence text footnoteref:[ex1, An example footnote\nwith wrapped text.].")
|
394
|
-
assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" href="#_footnote_1" title="View footnote."
|
396
|
+
assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
|
395
397
|
assert_equal 1, para.document.references[:footnotes].size
|
396
398
|
footnote = para.document.references[:footnotes].first
|
397
399
|
assert_equal 1, footnote.index
|
@@ -401,7 +403,7 @@ context 'Substitutions' do
|
|
401
403
|
|
402
404
|
test 'a footnoteref macro with id should refer to footnoteref with same id' do
|
403
405
|
para = block_from_string('Sentence text footnoteref:[ex1, An example footnote.]. Sentence text footnoteref:[ex1].')
|
404
|
-
assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" href="#_footnote_1" title="View footnote."
|
406
|
+
assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>. Sentence text <span class="footnoteref">[<a class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
|
405
407
|
assert_equal 1, para.document.references[:footnotes].size
|
406
408
|
footnote = para.document.references[:footnotes].first
|
407
409
|
assert_equal 1, footnote.index
|
data/test/tables_test.rb
CHANGED
@@ -14,8 +14,8 @@ context 'Tables' do
|
|
14
14
|
cells = [%w(A B C), %w(a b c), %w(1 2 3)]
|
15
15
|
output = render_embedded_string input
|
16
16
|
assert_css 'table', output, 1
|
17
|
-
assert_css 'table.tableblock.frame-all.grid-all[style
|
18
|
-
assert_css 'table > colgroup > col[style
|
17
|
+
assert_css 'table.tableblock.frame-all.grid-all[style*="width: 100%"]', output, 1
|
18
|
+
assert_css 'table > colgroup > col[style*="width: 33%"]', output, 3
|
19
19
|
assert_css 'table tr', output, 3
|
20
20
|
assert_css 'table > tbody > tr', output, 3
|
21
21
|
assert_css 'table td', output, 9
|
@@ -233,13 +233,13 @@ I am getting in shape!
|
|
233
233
|
EOS
|
234
234
|
output = render_embedded_string input
|
235
235
|
assert_css 'table', output, 1
|
236
|
-
assert_css 'table[style
|
236
|
+
assert_css 'table[style*="width: 80%"]', output, 1
|
237
237
|
assert_xpath '/table/caption[@class="title"][text()="Table 1. Horizontal and vertical source data"]', output, 1
|
238
238
|
assert_css 'table > colgroup > col', output, 4
|
239
|
-
assert_css 'table > colgroup > col:nth-child(1)[@style
|
240
|
-
assert_css 'table > colgroup > col:nth-child(2)[@style
|
241
|
-
assert_css 'table > colgroup > col:nth-child(3)[@style
|
242
|
-
assert_css 'table > colgroup > col:nth-child(4)[@style
|
239
|
+
assert_css 'table > colgroup > col:nth-child(1)[@style*="width: 17%"]', output, 1
|
240
|
+
assert_css 'table > colgroup > col:nth-child(2)[@style*="width: 11%"]', output, 1
|
241
|
+
assert_css 'table > colgroup > col:nth-child(3)[@style*="width: 11%"]', output, 1
|
242
|
+
assert_css 'table > colgroup > col:nth-child(4)[@style*="width: 58%"]', output, 1
|
243
243
|
assert_css 'table > thead', output, 1
|
244
244
|
assert_css 'table > thead > tr', output, 1
|
245
245
|
assert_css 'table > thead > tr > th', output, 4
|
@@ -264,7 +264,7 @@ d|9 2+>|10
|
|
264
264
|
EOS
|
265
265
|
output = render_embedded_string input
|
266
266
|
assert_css 'table', output, 1
|
267
|
-
assert_css 'table > colgroup > col[style
|
267
|
+
assert_css 'table > colgroup > col[style*="width: 25%"]', output, 4
|
268
268
|
assert_css 'table > tbody > tr', output, 4
|
269
269
|
assert_css 'table > tbody > tr > td', output, 10
|
270
270
|
assert_css 'table > tbody > tr:nth-child(1) > td', output, 4
|
@@ -452,7 +452,7 @@ nobody:x:99:99:Nobody:/:/sbin/nologin
|
|
452
452
|
EOS
|
453
453
|
output = render_embedded_string input
|
454
454
|
assert_css 'table', output, 1
|
455
|
-
assert_css 'table > colgroup > col[style
|
455
|
+
assert_css 'table > colgroup > col[style*="width: 14%"]', output, 7
|
456
456
|
assert_css 'table > tbody > tr', output, 6
|
457
457
|
assert_xpath '//tr[4]/td[5]/p/text()', output, 0
|
458
458
|
assert_xpath '//tr[3]/td[5]/p[text()="MySQL:Server"]', output, 1
|
@@ -475,7 +475,7 @@ air, moon roof, loaded",4799.00
|
|
475
475
|
EOS
|
476
476
|
output = render_embedded_string input
|
477
477
|
assert_css 'table', output, 1
|
478
|
-
assert_css 'table > colgroup > col[style
|
478
|
+
assert_css 'table > colgroup > col[style*="width: 20%"]', output, 5
|
479
479
|
assert_css 'table > thead > tr', output, 1
|
480
480
|
assert_css 'table > tbody > tr', output, 4
|
481
481
|
assert_xpath '((//tbody/tr)[1]/td)[4]/p[text()="ac, abs, moon"]', output, 1
|
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: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-02-
|
14
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: coderay
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- lib/asciidoctor/debug.rb
|
188
188
|
- lib/asciidoctor/document.rb
|
189
189
|
- lib/asciidoctor/errors.rb
|
190
|
+
- lib/asciidoctor/helpers.rb
|
190
191
|
- lib/asciidoctor/inline.rb
|
191
192
|
- lib/asciidoctor/lexer.rb
|
192
193
|
- lib/asciidoctor/list_item.rb
|
@@ -237,9 +238,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
237
238
|
- - ! '>='
|
238
239
|
- !ruby/object:Gem::Version
|
239
240
|
version: '0'
|
240
|
-
segments:
|
241
|
-
- 0
|
242
|
-
hash: 789385371494558772
|
243
241
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
242
|
none: false
|
245
243
|
requirements:
|