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.

Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +216 -1
  3. data/CONTRIBUTING.adoc +2 -2
  4. data/Gemfile +20 -1
  5. data/LICENSE.adoc +1 -1
  6. data/README-fr.adoc +4 -3
  7. data/README-jp.adoc +11 -10
  8. data/README-zh_CN.adoc +4 -3
  9. data/README.adoc +17 -202
  10. data/Rakefile +41 -25
  11. data/asciidoctor.gemspec +9 -10
  12. data/data/locale/attributes.adoc +216 -34
  13. data/data/stylesheets/asciidoctor-default.css +23 -16
  14. data/features/step_definitions.rb +15 -19
  15. data/features/xref.feature +584 -20
  16. data/lib/asciidoctor.rb +292 -278
  17. data/lib/asciidoctor/abstract_block.rb +155 -94
  18. data/lib/asciidoctor/abstract_node.rb +108 -94
  19. data/lib/asciidoctor/attribute_list.rb +30 -22
  20. data/lib/asciidoctor/block.rb +7 -7
  21. data/lib/asciidoctor/cli/invoker.rb +47 -34
  22. data/lib/asciidoctor/cli/options.rb +22 -11
  23. data/lib/asciidoctor/converter.rb +3 -3
  24. data/lib/asciidoctor/converter/base.rb +2 -2
  25. data/lib/asciidoctor/converter/composite.rb +1 -1
  26. data/lib/asciidoctor/converter/docbook45.rb +2 -2
  27. data/lib/asciidoctor/converter/docbook5.rb +132 -87
  28. data/lib/asciidoctor/converter/factory.rb +0 -1
  29. data/lib/asciidoctor/converter/html5.rb +116 -98
  30. data/lib/asciidoctor/converter/manpage.rb +51 -52
  31. data/lib/asciidoctor/converter/template.rb +47 -36
  32. data/lib/asciidoctor/core_ext.rb +8 -2
  33. data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +4 -0
  34. data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +6 -0
  35. data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +5 -0
  36. data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +1 -1
  37. data/lib/asciidoctor/core_ext/1.8.7/string/{limit.rb → limit_bytesize.rb} +7 -6
  38. data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +6 -0
  39. data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +1 -1
  40. data/lib/asciidoctor/core_ext/nil_or_empty.rb +5 -5
  41. data/lib/asciidoctor/core_ext/regexp/is_match.rb +3 -0
  42. data/lib/asciidoctor/core_ext/string/{limit.rb → limit_bytesize.rb} +2 -2
  43. data/lib/asciidoctor/document.rb +216 -213
  44. data/lib/asciidoctor/extensions.rb +318 -185
  45. data/lib/asciidoctor/helpers.rb +35 -35
  46. data/lib/asciidoctor/inline.rb +32 -1
  47. data/lib/asciidoctor/list.rb +22 -6
  48. data/lib/asciidoctor/parser.rb +1008 -1038
  49. data/lib/asciidoctor/path_resolver.rb +46 -50
  50. data/lib/asciidoctor/reader.rb +275 -251
  51. data/lib/asciidoctor/section.rb +86 -58
  52. data/lib/asciidoctor/stylesheets.rb +6 -6
  53. data/lib/asciidoctor/substitutors.rb +567 -649
  54. data/lib/asciidoctor/table.rb +163 -108
  55. data/lib/asciidoctor/version.rb +1 -1
  56. data/man/asciidoctor.1 +18 -16
  57. data/man/asciidoctor.adoc +15 -13
  58. data/test/attributes_test.rb +138 -22
  59. data/test/blocks_test.rb +377 -97
  60. data/test/converter_test.rb +13 -0
  61. data/test/document_test.rb +244 -34
  62. data/test/extensions_test.rb +409 -42
  63. data/test/fixtures/asciidoc_index.txt +521 -0
  64. data/test/fixtures/basic-docinfo-footer.html +6 -0
  65. data/test/fixtures/basic-docinfo-footer.xml +8 -0
  66. data/test/fixtures/basic-docinfo.html +1 -0
  67. data/test/fixtures/basic-docinfo.xml +4 -0
  68. data/test/fixtures/basic.asciidoc +5 -0
  69. data/test/fixtures/chapter-a.adoc +3 -0
  70. data/test/fixtures/child-include.adoc +5 -0
  71. data/test/fixtures/circle.svg +9 -0
  72. data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +6 -0
  73. data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +6 -0
  74. data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +1 -0
  75. data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +3 -0
  76. data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +5 -0
  77. data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +6 -0
  78. data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +3 -0
  79. data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +5 -0
  80. data/test/fixtures/custom-docinfodir/basic-docinfo.html +1 -0
  81. data/test/fixtures/custom-docinfodir/docinfo.html +1 -0
  82. data/test/fixtures/docinfo-footer.html +1 -0
  83. data/test/fixtures/docinfo-footer.xml +9 -0
  84. data/test/fixtures/docinfo.html +1 -0
  85. data/test/fixtures/docinfo.xml +3 -0
  86. data/test/fixtures/dot.gif +0 -0
  87. data/test/fixtures/encoding.asciidoc +13 -0
  88. data/test/fixtures/grandchild-include.adoc +3 -0
  89. data/test/fixtures/hello-asciidoctor.pdf +69 -0
  90. data/test/fixtures/include-file.asciidoc +24 -0
  91. data/test/fixtures/include-file.ml +3 -0
  92. data/test/fixtures/include-file.xml +5 -0
  93. data/test/fixtures/master.adoc +5 -0
  94. data/test/fixtures/mismatched-end-tag.adoc +7 -0
  95. data/test/fixtures/parent-include-restricted.adoc +5 -0
  96. data/test/fixtures/parent-include.adoc +5 -0
  97. data/test/fixtures/sample.asciidoc +26 -0
  98. data/test/fixtures/stylesheets/custom.css +3 -0
  99. data/test/fixtures/subs-docinfo.html +2 -0
  100. data/test/fixtures/subs.adoc +7 -0
  101. data/test/fixtures/tagged-class-enclosed.rb +26 -0
  102. data/test/fixtures/tagged-class.rb +23 -0
  103. data/test/fixtures/tip.gif +0 -0
  104. data/test/invoker_test.rb +82 -4
  105. data/test/links_test.rb +312 -37
  106. data/test/lists_test.rb +204 -25
  107. data/test/manpage_test.rb +191 -4
  108. data/test/options_test.rb +18 -1
  109. data/test/paragraphs_test.rb +32 -7
  110. data/test/parser_test.rb +150 -30
  111. data/test/paths_test.rb +47 -13
  112. data/test/preamble_test.rb +1 -1
  113. data/test/reader_test.rb +366 -126
  114. data/test/sections_test.rb +203 -56
  115. data/test/substitutions_test.rb +339 -131
  116. data/test/tables_test.rb +315 -15
  117. data/test/test_helper.rb +400 -0
  118. data/test/text_test.rb +5 -5
  119. metadata +110 -22
@@ -0,0 +1,6 @@
1
+ <script>
2
+ (function() {
3
+ var p1 = document.createElement('script'); p1.async = true; p1.src = 'https://apis.google.com/js/plusone.js';
4
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(p1, s);
5
+ })();
6
+ </script>
@@ -0,0 +1,8 @@
1
+ <revhistory>
2
+ <revision>
3
+ <revnumber>{revnumber}</revnumber>
4
+ <date>01 Jan 2013</date>
5
+ <authorinitials>abc</authorinitials>
6
+ <revremark>Unleashed into the wild</revremark>
7
+ </revision>
8
+ </revhistory>
@@ -0,0 +1 @@
1
+ <script src="modernizr.js"></script>
@@ -0,0 +1,4 @@
1
+ <copyright><!-- don't remove the indent! -->
2
+ <year>2013</year>
3
+ <holder>Acme™, Inc.</holder>
4
+ </copyright>
@@ -0,0 +1,5 @@
1
+ = Document Title
2
+ Doc Writer <doc.writer@asciidoc.org>
3
+ v1.0, 2013-01-01
4
+
5
+ Body content.
@@ -0,0 +1,3 @@
1
+ = Chapter A
2
+
3
+ content
@@ -0,0 +1,5 @@
1
+ first line of child
2
+
3
+ include::grandchild-include.adoc[]
4
+
5
+ last line of child
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <!-- An SVG of a black circle -->
4
+ <svg
5
+ viewBox="0 0 120 120" version="1.1"
6
+ xmlns="http://www.w3.org/2000/svg" style="width:500px;height:500px"
7
+ width="500px" height="500px">
8
+ <circle cx="60" cy="60" r="50"/>
9
+ </svg>
@@ -0,0 +1,6 @@
1
+ <%#encoding:UTF-8%><div<%= @id && %( id="#{@id}") %> class="<%= ['paragraph',role].compact * ' ' %>"><%
2
+ if title? %>
3
+ <div class="title"><%= title %></div><%
4
+ end %>
5
+ <p><%= content %></p>
6
+ </div>
@@ -0,0 +1,6 @@
1
+ - if title?
2
+ %formalpara{:id=>@id, :role=>(attr :role), :xreflabel=>(attr :reftext)}
3
+ %title=title
4
+ %para=content
5
+ - else
6
+ %para{:id=>@id, :role=>(attr :role), :xreflabel=>(attr :reftext)}=content
@@ -0,0 +1,3 @@
1
+ - if title?
2
+ .title=title
3
+ %p{:id=>@id, :class=>(attr 'role')}=content
@@ -0,0 +1,5 @@
1
+ %aside{:id=>@id, :class=>(attr 'role')}
2
+ - if title?
3
+ %header
4
+ %h1=title
5
+ =content.chomp
@@ -0,0 +1,6 @@
1
+ - if title?
2
+ formalpara id=@id role=(attr :role) xreflabel=(attr :reftext)
3
+ title=title
4
+ para=content
5
+ - else
6
+ para id=@id role=(attr :role) xreflabel=(attr :reftext) =content
@@ -0,0 +1,3 @@
1
+ - if title?
2
+ .title=title
3
+ p id=@id class=(attr 'role') =content
@@ -0,0 +1,5 @@
1
+ aside id=@id class=(attr 'role')
2
+ - if title?
3
+ header
4
+ h1=title
5
+ =content
@@ -0,0 +1 @@
1
+ <script src="bootstrap.js"></script>
@@ -0,0 +1 @@
1
+ <meta name="robots" content="index,follow">
@@ -0,0 +1 @@
1
+ <a id="top" href="#">Back to top</a>
@@ -0,0 +1,9 @@
1
+ <glossary id="_glossary">
2
+ <title>Glossary</title>
3
+ <glossentry>
4
+ <glossterm>term</glossterm>
5
+ <glossdef>
6
+ <simpara>definition</simpara>
7
+ </glossdef>
8
+ </glossentry>
9
+ </glossary>
@@ -0,0 +1 @@
1
+ <meta http-equiv="imagetoolbar" content="false">
@@ -0,0 +1,3 @@
1
+ <productname>Asciidoctor™</productname>
2
+ <productnumber>1.0.0</productnumber>
3
+ <edition>{revnumber}</edition>
Binary file
@@ -0,0 +1,13 @@
1
+ Gregory Romé has written an AsciiDoc plugin for the Redmine project management application.
2
+
3
+ https://github.com/foo-users/foo
4
+ へと `vicmd` キーマップを足してみている試み、
5
+ アニメーションgifです。
6
+
7
+ tag::romé[]
8
+ Gregory Romé has written an AsciiDoc plugin for the Redmine project management application.
9
+ end::romé[]
10
+
11
+ == Überschrift
12
+
13
+ * Codierungen sind verrückt auf älteren Versionen von Ruby
@@ -0,0 +1,3 @@
1
+ first line of grandchild
2
+
3
+ last line of grandchild
@@ -0,0 +1,69 @@
1
+ %PDF-1.3
2
+ %����
3
+ 1 0 obj
4
+ << /Creator <feff0050007200610077006e>
5
+ /Producer <feff0050007200610077006e>
6
+ >>
7
+ endobj
8
+ 2 0 obj
9
+ << /Type /Catalog
10
+ /Pages 3 0 R
11
+ >>
12
+ endobj
13
+ 3 0 obj
14
+ << /Type /Pages
15
+ /Count 1
16
+ /Kids [5 0 R]
17
+ >>
18
+ endobj
19
+ 4 0 obj
20
+ << /Length 92
21
+ >>
22
+ stream
23
+ q
24
+
25
+ BT
26
+ 36.0 747.384 Td
27
+ /F1.0 12 Tf
28
+ [<48656c6c6f> 40 <2c204173636969646f63746f7221>] TJ
29
+ ET
30
+
31
+ Q
32
+
33
+ endstream
34
+ endobj
35
+ 5 0 obj
36
+ << /Type /Page
37
+ /Parent 3 0 R
38
+ /MediaBox [0 0 612.0 792.0]
39
+ /Contents 4 0 R
40
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
41
+ /Font << /F1.0 6 0 R
42
+ >>
43
+ >>
44
+ >>
45
+ endobj
46
+ 6 0 obj
47
+ << /Type /Font
48
+ /Subtype /Type1
49
+ /BaseFont /Helvetica
50
+ /Encoding /WinAnsiEncoding
51
+ >>
52
+ endobj
53
+ xref
54
+ 0 7
55
+ 0000000000 65535 f
56
+ 0000000015 00000 n
57
+ 0000000109 00000 n
58
+ 0000000158 00000 n
59
+ 0000000215 00000 n
60
+ 0000000357 00000 n
61
+ 0000000535 00000 n
62
+ trailer
63
+ << /Size 7
64
+ /Root 2 0 R
65
+ /Info 1 0 R
66
+ >>
67
+ startxref
68
+ 632
69
+ %%EOF
@@ -0,0 +1,24 @@
1
+ first line of included content
2
+ second line of included content
3
+ third line of included content
4
+ fourth line of included content
5
+ fifth line of included content
6
+ sixth line of included content
7
+ seventh line of included content
8
+ eighth line of included content
9
+
10
+ // tag::snippet[]
11
+ // tag::snippetA[]
12
+ snippetA content
13
+ // end::snippetA[]
14
+
15
+ non-tagged content
16
+
17
+ // tag::snippetB[]
18
+ snippetB content
19
+ // end::snippetB[]
20
+ // end::snippet[]
21
+
22
+ more non-tagged content
23
+
24
+ last line of included content
@@ -0,0 +1,3 @@
1
+ (* tag::snippet[] *)
2
+ let s = SS.empty;;
3
+ (* end::snippet[] *)
@@ -0,0 +1,5 @@
1
+ <root>
2
+ <!-- tag::snippet[] -->
3
+ <snippet>content</snippet>
4
+ <!-- end::snippet[] -->
5
+ </root>
@@ -0,0 +1,5 @@
1
+ = Master Document
2
+
3
+ preamble
4
+
5
+ include::chapter-a.adoc[leveloffset=+1]
@@ -0,0 +1,7 @@
1
+ //tag::a[]
2
+ a
3
+ //tag::b[]
4
+ b
5
+ //end::a[]
6
+ //end::b[]
7
+ c
@@ -0,0 +1,5 @@
1
+ first line of parent
2
+
3
+ include::child-include.adoc[depth=1]
4
+
5
+ last line of parent
@@ -0,0 +1,5 @@
1
+ first line of parent
2
+
3
+ include::child-include.adoc[]
4
+
5
+ last line of parent
@@ -0,0 +1,26 @@
1
+ Document Title
2
+ ==============
3
+ Doc Writer <thedoc@asciidoctor.org>
4
+ :idprefix: id_
5
+
6
+ Preamble paragraph.
7
+
8
+ NOTE: This is test, only a test.
9
+
10
+ == Section A
11
+
12
+ *Section A* paragraph.
13
+
14
+ === Section A Subsection
15
+
16
+ *Section A* 'subsection' paragraph.
17
+
18
+ == Section B
19
+
20
+ *Section B* paragraph.
21
+
22
+ .Section B list
23
+ * Item 1
24
+ * Item 2
25
+ * Item 3
26
+
@@ -0,0 +1,3 @@
1
+ body {
2
+ color: red;
3
+ }
@@ -0,0 +1,2 @@
1
+ <meta name="copyright" content="(C) OpenDevise">
2
+ <script src="bootstrap.{bootstrap-version}.min.js"></script>
@@ -0,0 +1,7 @@
1
+ = Document Title
2
+ Doc Writer <doc.writer@asciidoc.org>
3
+ v1.0, 2013-01-01
4
+ :bootstrap-version: 3.2.0
5
+
6
+ Body content.
7
+
@@ -0,0 +1,26 @@
1
+ #tag::all[]
2
+ class Dog
3
+ #tag::init[]
4
+ def initialize breed
5
+ @breed = breed
6
+ end
7
+ #end::init[]
8
+ #tag::bark[]
9
+
10
+ def bark
11
+ #tag::bark-beagle[]
12
+ if @breed == 'beagle'
13
+ 'woof woof woof woof woof'
14
+ #end::bark-beagle[]
15
+ #tag::bark-other[]
16
+ else
17
+ 'woof woof'
18
+ #end::bark-other[]
19
+ #tag::bark-all[]
20
+ #tag::bark-all[]
21
+ end
22
+ #end::bark-all[]
23
+ end
24
+ #end::bark[]
25
+ end
26
+ #end::all[]
@@ -0,0 +1,23 @@
1
+ class Dog
2
+ #tag::init[]
3
+ def initialize breed
4
+ @breed = breed
5
+ end
6
+ #end::init[]
7
+ #tag::bark[]
8
+
9
+ def bark
10
+ #tag::bark-beagle[]
11
+ if @breed == 'beagle'
12
+ 'woof woof woof woof woof'
13
+ #end::bark-beagle[]
14
+ #tag::bark-other[]
15
+ else
16
+ 'woof woof'
17
+ #end::bark-other[]
18
+ #tag::bark-all[]
19
+ end
20
+ #end::bark-all[]
21
+ end
22
+ #end::bark[]
23
+ end
Binary file
@@ -41,6 +41,7 @@ context 'Invoker' do
41
41
  assert_equal sample_filepath, doc.attr('docfile')
42
42
  assert_equal sample_filedir, doc.attr('docdir')
43
43
  assert doc.attr?('docdate')
44
+ assert doc.attr?('docyear')
44
45
  assert doc.attr?('doctime')
45
46
  assert doc.attr?('docdatetime')
46
47
  assert invoker.read_output.empty?
@@ -51,6 +52,7 @@ context 'Invoker' do
51
52
  invoker = invoke_cli_to_buffer %w(-o /dev/null -a docdate=2015-01-01 -a doctime=10:00:00-07:00), sample_filepath
52
53
  doc = invoker.document
53
54
  assert doc.attr?('docdate', '2015-01-01')
55
+ assert doc.attr?('docyear', '2015')
54
56
  assert doc.attr?('doctime', '10:00:00-07:00')
55
57
  assert doc.attr?('docdatetime', '2015-01-01 10:00:00-07:00')
56
58
  end
@@ -62,6 +64,7 @@ context 'Invoker' do
62
64
  assert !doc.attr?('docfile')
63
65
  assert_equal Dir.pwd, doc.attr('docdir')
64
66
  assert_equal doc.attr('docdate'), doc.attr('localdate')
67
+ assert_equal doc.attr('docyear'), doc.attr('localyear')
65
68
  assert_equal doc.attr('doctime'), doc.attr('localtime')
66
69
  assert_equal doc.attr('docdatetime'), doc.attr('localdatetime')
67
70
  assert !doc.attr?('outfile')
@@ -91,6 +94,7 @@ context 'Invoker' do
91
94
  assert !doc.attr?('docfile')
92
95
  assert_equal Dir.pwd, doc.attr('docdir')
93
96
  assert_equal doc.attr('docdate'), doc.attr('localdate')
97
+ assert_equal doc.attr('docyear'), doc.attr('localyear')
94
98
  assert_equal doc.attr('doctime'), doc.attr('localtime')
95
99
  assert_equal doc.attr('docdatetime'), doc.attr('localdatetime')
96
100
  assert doc.attr?('outfile')
@@ -101,6 +105,33 @@ context 'Invoker' do
101
105
  end
102
106
  end
103
107
 
108
+ test 'should fail if input file matches resolved output file' do
109
+ invoker = invoke_cli_to_buffer %W(-a outfilesuffix=.asciidoc), 'sample.asciidoc'
110
+ assert_match(/input file and output file cannot be the same/, invoker.read_error)
111
+ end
112
+
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'))
115
+ invoker = invoke_cli_to_buffer %W(-o #{sample_outpath}), 'sample.asciidoc'
116
+ assert_match(/input file and output file cannot be the same/, invoker.read_error)
117
+ end
118
+
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'))
121
+ begin
122
+ %x(mkfifo #{sample_inpath})
123
+ write_thread = Thread.new do
124
+ IO.write sample_inpath, 'pipe content'
125
+ end
126
+ invoker = invoke_cli_to_buffer %w(-a stylesheet!), sample_inpath
127
+ result = invoker.read_output
128
+ assert_match(/pipe content/, result)
129
+ write_thread.join
130
+ ensure
131
+ FileUtils.rm_f sample_inpath
132
+ end
133
+ end if RUBY_MIN_VERSION_1_9 && !windows?
134
+
104
135
  test 'should allow docdir to be specified when input is a string' do
105
136
  expected_docdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))
106
137
  invoker = invoke_cli_to_buffer(%w(-s --base-dir test/fixtures -o /dev/null), '-') { 'content' }
@@ -178,7 +209,7 @@ context 'Invoker' do
178
209
  doc = invoker.document
179
210
  assert_equal sample_outpath, doc.attr('outfile')
180
211
  assert File.exist?(sample_outpath)
181
- output = File.read(sample_outpath)
212
+ output = IO.read(sample_outpath)
182
213
  assert !output.empty?
183
214
  assert_xpath '/html', output, 1
184
215
  assert_xpath '/html/head', output, 1
@@ -342,9 +373,9 @@ context 'Invoker' do
342
373
 
343
374
  test 'should render all files that matches an absolute path glob expression' do
344
375
  basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html'))
345
- glob = File.join(File.dirname(__FILE__), 'fixtures', 'ba*.asciidoc')
376
+ glob = File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures', 'ba*.asciidoc')
346
377
  # test Windows using backslash-style pathname
347
- if ::File::ALT_SEPARATOR == '\\'
378
+ if File::ALT_SEPARATOR == '\\'
348
379
  glob = glob.tr '/', '\\'
349
380
  end
350
381
 
@@ -409,6 +440,32 @@ context 'Invoker' do
409
440
  assert_xpath '/html/body[@class="book"]', output, 1
410
441
  end
411
442
 
443
+ test 'should warn if doctype is inline and the first block is not a candidate for inline conversion' do
444
+ ['== Section Title', 'image::tiger.png[]'].each do |input|
445
+ warnings = redirect_streams do |out, err|
446
+ invoke_cli_to_buffer(%w(-d inline), '-') { input }
447
+ err.string
448
+ end
449
+ assert_match(/WARNING: no inline candidate/, warnings)
450
+ end
451
+ end
452
+
453
+ test 'should not warn if doctype is inline and the document has no blocks' do
454
+ warnings = redirect_streams do |out, err|
455
+ invoke_cli_to_buffer(%w(-d inline), '-') { '// comment' }
456
+ err.string
457
+ end
458
+ refute_match(/WARNING/, warnings)
459
+ end
460
+
461
+ test 'should not warn if doctype is inline and the document contains multiple blocks' do
462
+ warnings = redirect_streams do |out, err|
463
+ invoke_cli_to_buffer(%w(-d inline), '-') { %(paragraph one\n\nparagraph two\n\nparagraph three) }
464
+ err.string
465
+ end
466
+ refute_match(/WARNING/, warnings)
467
+ end
468
+
412
469
  test 'should locate custom templates based on template dir, template engine and backend' do
413
470
  custom_backend_root = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends'))
414
471
  invoker = invoke_cli_to_buffer %W(-E haml -T #{custom_backend_root} -o -)
@@ -558,11 +615,32 @@ context 'Invoker' do
558
615
  invoker = invoke_cli_to_buffer %w(-o /dev/null), sample_filepath
559
616
  doc = invoker.document
560
617
  assert_equal '2009-02-08', (doc.attr 'docdate')
618
+ assert_equal '2009', (doc.attr 'docyear')
561
619
  assert_match(/2009-02-08 20:03:32 (GMT|UTC)/, (doc.attr 'docdatetime'))
562
620
  assert_equal '2009-02-08', (doc.attr 'localdate')
621
+ assert_equal '2009', (doc.attr 'localyear')
563
622
  assert_match(/2009-02-08 20:03:32 (GMT|UTC)/, (doc.attr 'localdatetime'))
564
623
  ensure
565
- ENV['SOURCE_DATE_EPOCH'] = old_source_date_epoch if old_source_date_epoch
624
+ if old_source_date_epoch
625
+ ENV['SOURCE_DATE_EPOCH'] = old_source_date_epoch
626
+ else
627
+ ENV.delete 'SOURCE_DATE_EPOCH'
628
+ end
629
+ end
630
+ end
631
+
632
+ test 'should fail if SOURCE_DATE_EPOCH is malformed' do
633
+ old_source_date_epoch = ENV.delete 'SOURCE_DATE_EPOCH'
634
+ begin
635
+ ENV['SOURCE_DATE_EPOCH'] = 'aaaaaaaa'
636
+ sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc'))
637
+ assert_equal 1, (invoke_cli_to_buffer %w(-o /dev/null), sample_filepath).code
638
+ ensure
639
+ if old_source_date_epoch
640
+ ENV['SOURCE_DATE_EPOCH'] = old_source_date_epoch
641
+ else
642
+ ENV.delete 'SOURCE_DATE_EPOCH'
643
+ end
566
644
  end
567
645
  end
568
646
  end