asciidoctor 1.5.3 → 1.5.4

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +67 -5
  3. data/CONTRIBUTING.adoc +171 -0
  4. data/LICENSE.adoc +1 -1
  5. data/README.adoc +62 -30
  6. data/bin/asciidoctor +3 -3
  7. data/bin/asciidoctor-safe +8 -5
  8. data/lib/asciidoctor.rb +10 -21
  9. data/lib/asciidoctor/abstract_block.rb +29 -11
  10. data/lib/asciidoctor/abstract_node.rb +11 -6
  11. data/lib/asciidoctor/callouts.rb +6 -10
  12. data/lib/asciidoctor/cli/options.rb +2 -2
  13. data/lib/asciidoctor/converter.rb +1 -1
  14. data/lib/asciidoctor/converter/docbook5.rb +46 -23
  15. data/lib/asciidoctor/converter/factory.rb +3 -3
  16. data/lib/asciidoctor/converter/html5.rb +27 -24
  17. data/lib/asciidoctor/converter/manpage.rb +72 -61
  18. data/lib/asciidoctor/converter/template.rb +5 -9
  19. data/lib/asciidoctor/document.rb +18 -18
  20. data/lib/asciidoctor/extensions.rb +5 -5
  21. data/lib/asciidoctor/helpers.rb +2 -2
  22. data/lib/asciidoctor/inline.rb +2 -2
  23. data/lib/asciidoctor/parser.rb +59 -59
  24. data/lib/asciidoctor/path_resolver.rb +23 -15
  25. data/lib/asciidoctor/reader.rb +34 -29
  26. data/lib/asciidoctor/section.rb +6 -8
  27. data/lib/asciidoctor/substitutors.rb +2 -2
  28. data/lib/asciidoctor/table.rb +46 -23
  29. data/lib/asciidoctor/version.rb +1 -1
  30. data/man/asciidoctor.1 +11 -11
  31. data/man/asciidoctor.adoc +2 -2
  32. data/test/attributes_test.rb +21 -37
  33. data/test/blocks_test.rb +41 -14
  34. data/test/converter_test.rb +4 -4
  35. data/test/document_test.rb +61 -8
  36. data/test/extensions_test.rb +2 -2
  37. data/test/invoker_test.rb +3 -3
  38. data/test/links_test.rb +13 -3
  39. data/test/lists_test.rb +114 -114
  40. data/test/manpage_test.rb +203 -0
  41. data/test/paragraphs_test.rb +3 -3
  42. data/test/parser_test.rb +4 -4
  43. data/test/preamble_test.rb +1 -1
  44. data/test/reader_test.rb +149 -109
  45. data/test/sections_test.rb +137 -27
  46. data/test/substitutions_test.rb +24 -16
  47. data/test/tables_test.rb +183 -31
  48. data/test/test_helper.rb +10 -22
  49. metadata +9 -6
  50. data/compat/asciidoc.conf +0 -395
  51. data/compat/font-awesome-3-compat.css +0 -397
@@ -1,3 +1,3 @@
1
1
  module Asciidoctor
2
- VERSION = '1.5.3'
2
+ VERSION = '1.5.4'
3
3
  end
@@ -1,13 +1,13 @@
1
1
  '\" t
2
2
  .\" Title: asciidoctor
3
3
  .\" Author: Dan Allen, Sarah White, Ryan Waldron
4
- .\" Generator: Asciidoctor 1.5.3
5
- .\" Date: 2015-10-30
4
+ .\" Generator: Asciidoctor 1.5.4
5
+ .\" Date: 2016-01-05
6
6
  .\" Manual: Asciidoctor Manual
7
- .\" Source: Asciidoctor 1.5.3
7
+ .\" Source: Asciidoctor 1.5.4
8
8
  .\" Language: English
9
9
  .\"
10
- .TH "ASCIIDOCTOR" "1" "2015-10-30" "Asciidoctor 1.5.3" "Asciidoctor Manual"
10
+ .TH "ASCIIDOCTOR" "1" "2016-01-05" "Asciidoctor 1.5.4" "Asciidoctor Manual"
11
11
  .ie \n(.g .ds Aq \(aq
12
12
  .el .ds Aq '
13
13
  .ss \n[.ss] 0
@@ -204,7 +204,7 @@ Failure (syntax or usage error; configuration error; document processing failure
204
204
  .RE
205
205
  .SH "BUGS"
206
206
  .sp
207
- Refer to the \fBAsciidoctor\fP issue tracker at
207
+ Refer to the \fBAsciidoctor\fP issue tracker at \c
208
208
  .URL "https://github.com/asciidoctor/asciidoctor/issues?q=is%3Aopen" "" "."
209
209
  .SH "AUTHORS"
210
210
  .sp
@@ -213,24 +213,24 @@ Refer to the \fBAsciidoctor\fP issue tracker at
213
213
  \fBAsciiDoc\fP was written by Stuart Rackham and has received contributions from many other individuals.
214
214
  .SH "RESOURCES"
215
215
  .sp
216
- \fBProject web site:\fP
216
+ \fBProject web site:\fP \c
217
217
  .URL "http://asciidoctor.org" "" ""
218
218
  .sp
219
- \fBGit source repository on GitHub:\fP
219
+ \fBGit source repository on GitHub:\fP \c
220
220
  .URL "https://github.com/asciidoctor/asciidoctor" "" ""
221
221
  .sp
222
- \fBGitHub organization:\fP
222
+ \fBGitHub organization:\fP \c
223
223
  .URL "https://github.com/asciidoctor" "" ""
224
224
  .sp
225
- \fBDiscussion list / forum:\fP
225
+ \fBDiscussion list / forum:\fP \c
226
226
  .URL "http://discuss.asciidoctor.org" "" ""
227
227
  .SH "COPYING"
228
228
  .sp
229
- Copyright (C) 2012\-2015 Dan Allen, Ryan Waldron and the Asciidoctor Project.
229
+ Copyright (C) 2012\-2016 Dan Allen, Ryan Waldron and the Asciidoctor Project.
230
230
  Free use of this software is granted under the terms of the MIT License.
231
231
  .SH "AUTHOR(S)"
232
232
  .sp
233
233
  \fBDan Allen, Sarah White, Ryan Waldron\fP
234
234
  .RS 4
235
235
  Author(s).
236
- .RE
236
+ .RE
@@ -2,7 +2,7 @@
2
2
  Dan Allen; Sarah White; Ryan Waldron
3
3
  :doctype: manpage
4
4
  :man manual: Asciidoctor Manual
5
- :man source: Asciidoctor 1.5.3
5
+ :man source: Asciidoctor 1.5.4
6
6
  :page-layout: base
7
7
 
8
8
  == NAME
@@ -174,5 +174,5 @@ Refer to the *Asciidoctor* issue tracker at https://github.com/asciidoctor/ascii
174
174
 
175
175
  == COPYING
176
176
 
177
- Copyright \(C) 2012-2015 Dan Allen, Ryan Waldron and the Asciidoctor Project.
177
+ Copyright \(C) 2012-2016 Dan Allen, Ryan Waldron and the Asciidoctor Project.
178
178
  Free use of this software is granted under the terms of the MIT License.
@@ -349,10 +349,10 @@ toc toc-placement! | |content |macro |nil
349
349
  raw_attrs, toc, toc_position, toc_placement, toc_class = expect
350
350
  attrs = Hash[*(raw_attrs.split ' ').map {|e| e.include?('=') ? e.split('=') : [e, ''] }.flatten]
351
351
  doc = document_from_string '', :attributes => attrs
352
- toc ? (assert doc.attr?('toc', toc)) : (assert !doc.attr?('toc'))
353
- toc_position ? (assert doc.attr?('toc-position', toc_position)) : (assert !doc.attr?('toc-position'))
354
- toc_placement ? (assert doc.attr?('toc-placement', toc_placement)) : (assert !doc.attr?('toc-placement'))
355
- toc_class ? (assert doc.attr?('toc-class', toc_class)) : (assert !doc.attr?('toc-class'))
352
+ toc ? (assert doc.attr?('toc', toc)) : (assert !doc.attr?('toc'))
353
+ toc_position ? (assert doc.attr?('toc-position', toc_position)) : (assert !doc.attr?('toc-position'))
354
+ toc_placement ? (assert doc.attr?('toc-placement', toc_placement)) : (assert !doc.attr?('toc-placement'))
355
+ toc_class ? (assert doc.attr?('toc-class', toc_class)) : (assert !doc.attr?('toc-class'))
356
356
  end
357
357
  end
358
358
  end
@@ -618,7 +618,7 @@ Belly up to the {foo}.
618
618
 
619
619
  test 'does not substitute attributes inside listing blocks' do
620
620
  input = <<-EOS
621
- :forecast: snow
621
+ :forecast: snow
622
622
 
623
623
  ----
624
624
  puts 'The forecast for today is {forecast}'
@@ -668,22 +668,22 @@ of the attribute named foo in your document.
668
668
  end
669
669
 
670
670
  test 'assigns attribute defined in attribute reference with set prefix and value' do
671
- input = '{set:foo:bar}{foo}'
672
- output = render_embedded_string input
671
+ input = '{set:foo:bar}{foo}'
672
+ output = render_embedded_string input
673
673
  assert_xpath '//p', output, 1
674
674
  assert_xpath '//p[text()="bar"]', output, 1
675
675
  end
676
676
 
677
677
  test 'assigns attribute defined in attribute reference with set prefix and no value' do
678
678
  input = "{set:foo}\n{foo}yes"
679
- output = render_embedded_string input
679
+ output = render_embedded_string input
680
680
  assert_xpath '//p', output, 1
681
681
  assert_xpath '//p[normalize-space(text())="yes"]', output, 1
682
682
  end
683
683
 
684
684
  test 'assigns attribute defined in attribute reference with set prefix and empty value' do
685
685
  input = "{set:foo:}\n{foo}yes"
686
- output = render_embedded_string input
686
+ output = render_embedded_string input
687
687
  assert_xpath '//p', output, 1
688
688
  assert_xpath '//p[normalize-space(text())="yes"]', output, 1
689
689
  end
@@ -793,7 +793,7 @@ of the attribute named foo in your document.
793
793
  assert_equal 'A', doc.attributes['mycounter']
794
794
  assert_xpath '//p[text()="A"]', output, 2
795
795
  end
796
-
796
+
797
797
  test 'counter uses 0 as seed value if seed attribute is nil' do
798
798
  input = <<-EOS
799
799
  :mycounter:
@@ -836,11 +836,11 @@ content
836
836
  EOS
837
837
 
838
838
  block = block_from_string input
839
- assert_equal 'bar', block.attr('foo')
840
- assert_equal '_bar', block.attr('_foo')
841
- assert_equal 'bar1', block.attr('foo1')
842
- assert_equal 'bar-bar', block.attr('foo-foo')
843
- assert_equal 'bar.bar', block.attr('foo.foo')
839
+ assert_equal 'bar', block.attr('foo')
840
+ assert_equal '_bar', block.attr('_foo')
841
+ assert_equal 'bar1', block.attr('foo1')
842
+ assert_equal 'bar-bar', block.attr('foo-foo')
843
+ assert_equal 'bar.bar', block.attr('foo.foo')
844
844
  end
845
845
 
846
846
  test 'positional attributes assigned to block' do
@@ -1069,7 +1069,7 @@ Text
1069
1069
 
1070
1070
  test 'a role can be added using add_role when the node has no roles' do
1071
1071
  input = <<-EOS
1072
- A normal paragraph
1072
+ A normal paragraph
1073
1073
  EOS
1074
1074
  doc = document_from_string(input)
1075
1075
  para = doc.blocks.first
@@ -1081,7 +1081,7 @@ A normal paragraph
1081
1081
  test 'a role can be added using add_role when the node already has a role' do
1082
1082
  input = <<-EOS
1083
1083
  [.role1]
1084
- A normal paragraph
1084
+ A normal paragraph
1085
1085
  EOS
1086
1086
  doc = document_from_string(input)
1087
1087
  para = doc.blocks.first
@@ -1094,7 +1094,7 @@ A normal paragraph
1094
1094
  test 'a role is not added using add_role if the node already has that role' do
1095
1095
  input = <<-EOS
1096
1096
  [.role1]
1097
- A normal paragraph
1097
+ A normal paragraph
1098
1098
  EOS
1099
1099
  doc = document_from_string(input)
1100
1100
  para = doc.blocks.first
@@ -1106,7 +1106,7 @@ A normal paragraph
1106
1106
  test 'an existing role can be removed using remove_role' do
1107
1107
  input = <<-EOS
1108
1108
  [.role1.role2]
1109
- A normal paragraph
1109
+ A normal paragraph
1110
1110
  EOS
1111
1111
  doc = document_from_string(input)
1112
1112
  para = doc.blocks.first
@@ -1119,7 +1119,7 @@ A normal paragraph
1119
1119
  test 'roles are not changed when a non-existent role is removed using remove_role' do
1120
1120
  input = <<-EOS
1121
1121
  [.role1]
1122
- A normal paragraph
1122
+ A normal paragraph
1123
1123
  EOS
1124
1124
  doc = document_from_string(input)
1125
1125
  para = doc.blocks.first
@@ -1131,7 +1131,7 @@ A normal paragraph
1131
1131
 
1132
1132
  test 'roles are not changed when using remove_role if the node has no roles' do
1133
1133
  input = <<-EOS
1134
- A normal paragraph
1134
+ A normal paragraph
1135
1135
  EOS
1136
1136
  doc = document_from_string(input)
1137
1137
  para = doc.blocks.first
@@ -1213,22 +1213,6 @@ paragraph
1213
1213
  assert_equal 'coolio', subsec.id
1214
1214
  end
1215
1215
 
1216
- test 'block id above document title sets id on document' do
1217
- input = <<-EOS
1218
- [[reference]]
1219
- Reference Manual
1220
- ================
1221
- :css-signature: refguide
1222
-
1223
- preamble
1224
- EOS
1225
- doc = document_from_string input
1226
- assert_equal 'reference', doc.id
1227
- assert_equal 'refguide', doc.attr('css-signature')
1228
- output = doc.render
1229
- assert_xpath '//body[@id="reference"]', output, 1
1230
- end
1231
-
1232
1216
  test "trailing block attributes tranfer to the following section" do
1233
1217
  input = <<-EOS
1234
1218
  [[one]]
@@ -486,7 +486,7 @@ La la la <1>
486
486
  ____
487
487
  <1> Not pointing to a callout
488
488
  EOS
489
-
489
+
490
490
  output = render_embedded_string input
491
491
  assert_xpath '//pre[text()="La la la <1>"]', output, 1
492
492
  end
@@ -675,7 +675,7 @@ listing content
675
675
  ----
676
676
  paragraph 2
677
677
  EOS
678
-
678
+
679
679
  output = render_embedded_string input
680
680
  assert_xpath '/*[@class="paragraph"]/p', output, 2
681
681
  assert_xpath '/*[@class="listingblock"]', output, 1
@@ -1241,7 +1241,7 @@ line below
1241
1241
  expect = <<-'EOS'
1242
1242
  <informalequation>
1243
1243
  <alt><![CDATA[\sqrt{3x-1}+(1+x)^2 < y]]></alt>
1244
- <mediaobject><textobject><phrase></phrase></textobject></mediaobject>
1244
+ <mathphrase><![CDATA[\sqrt{3x-1}+(1+x)^2 < y]]></mathphrase>
1245
1245
  </informalequation>
1246
1246
  EOS
1247
1247
 
@@ -1402,7 +1402,7 @@ section paragraph
1402
1402
  .Block title
1403
1403
  = Document Title
1404
1404
 
1405
- == First Section
1405
+ == First Section
1406
1406
 
1407
1407
  paragraph
1408
1408
  EOS
@@ -1740,7 +1740,7 @@ image::{bogus}[]
1740
1740
 
1741
1741
  output = render_embedded_string input
1742
1742
  assert_css 'img', output, 0
1743
- assert_css 'h2', output, 1
1743
+ assert_css 'h2', output, 1
1744
1744
  assert !output.include?('== Section Title')
1745
1745
  end
1746
1746
 
@@ -1790,7 +1790,7 @@ image::http://#{resolve_localhost}:9876/fixtures/dot.gif[Dot]
1790
1790
  output = using_test_webserver do
1791
1791
  render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
1792
1792
  end
1793
-
1793
+
1794
1794
  assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
1795
1795
  end
1796
1796
 
@@ -1805,7 +1805,7 @@ image::dot.gif[Dot]
1805
1805
  output = using_test_webserver do
1806
1806
  render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
1807
1807
  end
1808
-
1808
+
1809
1809
  assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
1810
1810
  end
1811
1811
 
@@ -1820,7 +1820,7 @@ image::#{image_uri}[Missing image]
1820
1820
  output = using_test_webserver do
1821
1821
  render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
1822
1822
  end
1823
-
1823
+
1824
1824
  assert_xpath %(/*[@class="imageblock"]//img[@src="#{image_uri}"][@alt="Missing image"]), output, 1
1825
1825
  end
1826
1826
 
@@ -1835,7 +1835,7 @@ image::#{image_uri}[Dot]
1835
1835
  output = using_test_webserver do
1836
1836
  render_embedded_string input, :safe => :safe
1837
1837
  end
1838
-
1838
+
1839
1839
  assert_xpath %(/*[@class="imageblock"]//img[@src="#{image_uri}"][@alt="Dot"]), output, 1
1840
1840
  end
1841
1841
 
@@ -1985,7 +1985,7 @@ video::http://example.org/videos/cats-vs-dogs.avi[]
1985
1985
  assert_css 'video', output, 1
1986
1986
  assert_css 'video[src="http://example.org/videos/cats-vs-dogs.avi"]', output, 1
1987
1987
  end
1988
-
1988
+
1989
1989
  test 'video macro should output custom HTML with iframe for vimeo service' do
1990
1990
  input = <<-EOS
1991
1991
  video::67480300[vimeo, 400, 300, start=60, options=autoplay]
@@ -2095,6 +2095,19 @@ You can use icons for admonitions by setting the 'icons' attribute.
2095
2095
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="icons/tip.png"][@alt="Tip"]', output, 1
2096
2096
  end
2097
2097
 
2098
+ test 'should add file extension to custom icon if not specified' do
2099
+ input = <<-EOS
2100
+ :icons: font
2101
+ :iconsdir: images/icons
2102
+
2103
+ [TIP,icon=a]
2104
+ Override the icon of an admonition block using an attribute
2105
+ EOS
2106
+
2107
+ output = render_string input, :safe => Asciidoctor::SafeMode::SERVER
2108
+ assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="images/icons/a.png"]', output, 1
2109
+ end
2110
+
2098
2111
  test 'embeds base64-encoded data uri of icon when data-uri attribute is set and safe mode level is less than SECURE' do
2099
2112
  input = <<-EOS
2100
2113
  :icons:
@@ -2149,10 +2162,24 @@ You can use icons for admonitions by setting the 'icons' attribute.
2149
2162
  EOS
2150
2163
 
2151
2164
  output = render_string input, :safe => Asciidoctor::SafeMode::SERVER
2152
- assert_css 'html > head > link[rel="stylesheet"][href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css"]', output, 1
2165
+ assert_css 'html > head > link[rel="stylesheet"][href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css"]', output, 1
2153
2166
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/i[@class="fa icon-tip"]', output, 1
2154
2167
  end
2155
2168
 
2169
+ test 'font-based icon should not override icon specified on admonition' do
2170
+ input = <<-EOS
2171
+ :icons: font
2172
+ :iconsdir: images/icons
2173
+
2174
+ [TIP,icon=a.png]
2175
+ Override the icon of an admonition block using an attribute
2176
+ EOS
2177
+
2178
+ output = render_string input, :safe => Asciidoctor::SafeMode::SERVER
2179
+ assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/i[@class="fa icon-tip"]', output, 0
2180
+ assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="images/icons/a.png"]', output, 1
2181
+ end
2182
+
2156
2183
  test 'should use http uri scheme for assets when asset-uri-scheme is http' do
2157
2184
  input = <<-EOS
2158
2185
  :asset-uri-scheme: http
@@ -2166,7 +2193,7 @@ puts "AsciiDoc, FTW!"
2166
2193
  EOS
2167
2194
 
2168
2195
  output = render_string input, :safe => Asciidoctor::SafeMode::SAFE
2169
- assert_css 'html > head > link[rel="stylesheet"][href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css"]', output, 1
2196
+ assert_css 'html > head > link[rel="stylesheet"][href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css"]', output, 1
2170
2197
  assert_css 'html > body > script[src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js"]', output, 1
2171
2198
  end
2172
2199
 
@@ -2183,7 +2210,7 @@ puts "AsciiDoc, FTW!"
2183
2210
  EOS
2184
2211
 
2185
2212
  output = render_string input, :safe => Asciidoctor::SafeMode::SAFE
2186
- assert_css 'html > head > link[rel="stylesheet"][href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css"]', output, 1
2213
+ assert_css 'html > head > link[rel="stylesheet"][href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css"]', output, 1
2187
2214
  assert_css 'html > body > script[src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js"]', output, 1
2188
2215
  end
2189
2216
  end
@@ -2234,7 +2261,7 @@ puts "Hello, World!"
2234
2261
  assert_css '.listingblock pre code', output, 1
2235
2262
  assert_css '.listingblock pre code:not([class])', output, 1
2236
2263
  end
2237
-
2264
+
2238
2265
  test 'should not recognize fenced code blocks with more than three delimiters' do
2239
2266
  input = <<-EOS
2240
2267
  ````ruby
@@ -317,7 +317,7 @@ content
317
317
  EOS
318
318
 
319
319
  begin
320
- Asciidoctor::Converter::Factory.unregister_all
320
+ Asciidoctor::Converter::Factory.unregister_all
321
321
 
322
322
  class CustomConverterB
323
323
  include Asciidoctor::Converter
@@ -333,7 +333,7 @@ content
333
333
  output = render_string input, :backend => 'foobar'
334
334
  assert 'foobar content', output
335
335
  ensure
336
- Asciidoctor::Converter::Factory.unregister_all
336
+ Asciidoctor::Converter::Factory.unregister_all
337
337
  end
338
338
  end
339
339
 
@@ -343,7 +343,7 @@ content
343
343
  EOS
344
344
 
345
345
  begin
346
- Asciidoctor::Converter::Factory.unregister_all
346
+ Asciidoctor::Converter::Factory.unregister_all
347
347
 
348
348
  class CustomConverterC
349
349
  include Asciidoctor::Converter
@@ -358,7 +358,7 @@ content
358
358
  output = render_string input, :backend => 'foobaz'
359
359
  assert 'foobaz content', output
360
360
  ensure
361
- Asciidoctor::Converter::Factory.unregister_all
361
+ Asciidoctor::Converter::Factory.unregister_all
362
362
  end
363
363
  end
364
364
  end
@@ -72,7 +72,7 @@ context 'Document' do
72
72
  doc = empty_document
73
73
  begin
74
74
  doc.safe = Asciidoctor::SafeMode::UNSAFE
75
- flunk 'safe mode property of Asciidoctor::Document should not be writable!'
75
+ flunk 'safe mode property of Asciidoctor::Document should not be writable!'
76
76
  rescue
77
77
  end
78
78
  end
@@ -261,6 +261,30 @@ preamble
261
261
  assert doc.attributes.has_key?('toc')
262
262
  end
263
263
 
264
+ test 'should output timestamps by default' do
265
+ doc = document_from_string 'text', :backend => :html5, :attributes => nil
266
+ result = doc.convert
267
+ assert doc.attr?('docdate')
268
+ refute doc.attr? 'reproducible'
269
+ assert_xpath '//div[@id="footer-text" and contains(string(.//text()), "Last updated")]', result, 1
270
+ end
271
+
272
+ test 'should not output timestamps if reproducible attribute is set in HTML 5' do
273
+ doc = document_from_string 'text', :backend => :html5, :attributes => { 'reproducible' => '' }
274
+ result = doc.convert
275
+ assert doc.attr?('docdate')
276
+ assert doc.attr?('reproducible')
277
+ assert_xpath '//div[@id="footer-text" and contains(string(.//text()), "Last updated")]', result, 0
278
+ end
279
+
280
+ test 'should not output timestamps if reproducible attribute is set in DocBook' do
281
+ doc = document_from_string 'text', :backend => :docbook, :attributes => { 'reproducible' => '' }
282
+ result = doc.convert
283
+ assert doc.attr?('docdate')
284
+ assert doc.attr?('reproducible')
285
+ assert_xpath '/article/info/date', result, 0
286
+ end
287
+
264
288
  test 'should not modify options argument' do
265
289
  options = {
266
290
  :safe => Asciidoctor::SafeMode::SAFE
@@ -304,7 +328,7 @@ preamble
304
328
  assert_equal 'sample.asciidoc', section_2.file
305
329
  assert_equal 18, section_2.lineno
306
330
 
307
- last_block = section_2.blocks[-1]
331
+ last_block = section_2.blocks[-1]
308
332
  assert_equal :ulist, last_block.context
309
333
  refute_nil last_block.source_location
310
334
  assert_equal 'sample.asciidoc', last_block.file
@@ -468,6 +492,19 @@ content
468
492
  refute_nil result
469
493
  assert_equal 0, result.size
470
494
  end
495
+
496
+ test 'find_by should not crash if dlist entry does not have description' do
497
+ input = <<-EOS
498
+ term without description::
499
+ EOS
500
+ doc = Asciidoctor.load input
501
+ result = doc.find_by
502
+ refute_nil result
503
+ assert_equal 3, result.size
504
+ assert Asciidoctor::Document === result[0]
505
+ assert Asciidoctor::List === result[1]
506
+ assert Asciidoctor::ListItem === result[2]
507
+ end
471
508
  end
472
509
 
473
510
  context 'Convert APIs' do
@@ -1085,6 +1122,22 @@ preamble
1085
1122
  assert_equal 'Document Title', doc.first_section.title
1086
1123
  end
1087
1124
 
1125
+ test 'document with doctitle defined as attribute entry followed by block with title' do
1126
+ input = <<-EOS
1127
+ :doctitle: Document Title
1128
+
1129
+ .Block title
1130
+ Block content
1131
+ EOS
1132
+
1133
+ doc = document_from_string input
1134
+ assert_equal 'Document Title', doc.doctitle
1135
+ assert doc.has_header?
1136
+ assert_equal 1, doc.blocks.size
1137
+ assert_equal :paragraph, doc.blocks[0].context
1138
+ assert_equal 'Block title', doc.blocks[0].title
1139
+ end
1140
+
1088
1141
  test 'document with title attribute entry overrides doctitle' do
1089
1142
  input = <<-EOS
1090
1143
  = Document Title
@@ -1190,7 +1243,7 @@ content
1190
1243
  assert_equal 1, nodes.size
1191
1244
  assert_match('<h1><strong>Document</strong> <span class="image"><img src="logo.png" alt="logo"></span> <em>Title</em> <span class="image"><img src="another-logo.png" alt="another logo"></span></h1>', output)
1192
1245
  end
1193
-
1246
+
1194
1247
  test 'should not choke on empty source' do
1195
1248
  doc = Asciidoctor::Document.new ''
1196
1249
  assert doc.blocks.empty?
@@ -1531,7 +1584,7 @@ Text that has supporting information{empty}footnote:[An example footnote.].
1531
1584
  end
1532
1585
  end
1533
1586
 
1534
- context 'Backends and Doctypes' do
1587
+ context 'Backends and Doctypes' do
1535
1588
  test 'html5 backend doctype article' do
1536
1589
  result = render_string("= Title\n\nparagraph", :attributes => {'backend' => 'html5'})
1537
1590
  assert_xpath '/html', result, 1
@@ -1787,7 +1840,7 @@ section body
1787
1840
  assert_xpath '/xmlns:article', result, 1
1788
1841
  doc = xmlnodes_at_xpath('/xmlns:article', result, 1).first
1789
1842
  assert_equal 'http://docbook.org/ns/docbook', doc.namespaces['xmlns']
1790
- assert_equal 'http://www.w3.org/1999/xlink', doc.namespaces['xmlns:xlink']
1843
+ assert_equal 'http://www.w3.org/1999/xlink', doc.namespaces['xmlns:xl']
1791
1844
  assert_xpath '/xmlns:article[@version="5.0"]', result, 1
1792
1845
  assert_xpath '/xmlns:article/xmlns:info/xmlns:title[text() = "Title"]', result, 1
1793
1846
  assert_xpath '/xmlns:article/xmlns:simpara[text() = "preamble"]', result, 1
@@ -1821,7 +1874,7 @@ section body
1821
1874
  assert_xpath '/xmlns:refentry', result, 1
1822
1875
  doc = xmlnodes_at_xpath('/xmlns:refentry', result, 1).first
1823
1876
  assert_equal 'http://docbook.org/ns/docbook', doc.namespaces['xmlns']
1824
- assert_equal 'http://www.w3.org/1999/xlink', doc.namespaces['xmlns:xlink']
1877
+ assert_equal 'http://www.w3.org/1999/xlink', doc.namespaces['xmlns:xl']
1825
1878
  assert_xpath '/xmlns:refentry[@version="5.0"]', result, 1
1826
1879
  assert_xpath '/xmlns:refentry/xmlns:info/xmlns:title[text() = "asciidoctor(1)"]', result, 1
1827
1880
  assert_xpath '/xmlns:refentry/xmlns:refmeta/xmlns:refentrytitle[text() = "asciidoctor"]', result, 1
@@ -1855,7 +1908,7 @@ chapter body
1855
1908
  assert_xpath '/xmlns:book', result, 1
1856
1909
  doc = xmlnodes_at_xpath('/xmlns:book', result, 1).first
1857
1910
  assert_equal 'http://docbook.org/ns/docbook', doc.namespaces['xmlns']
1858
- assert_equal 'http://www.w3.org/1999/xlink', doc.namespaces['xmlns:xlink']
1911
+ assert_equal 'http://www.w3.org/1999/xlink', doc.namespaces['xmlns:xl']
1859
1912
  assert_xpath '/xmlns:book[@version="5.0"]', result, 1
1860
1913
  assert_xpath '/xmlns:book/xmlns:info/xmlns:title[text() = "Title"]', result, 1
1861
1914
  assert_xpath '/xmlns:book/xmlns:preface/xmlns:simpara[text() = "preamble"]', result, 1
@@ -2005,7 +2058,7 @@ asciidoctor - converts AsciiDoc source files to HTML, DocBook and other formats
2005
2058
  EOS
2006
2059
 
2007
2060
  doc = document_from_string input
2008
- synopsis_section = doc.blocks.first
2061
+ synopsis_section = doc.blocks.first
2009
2062
  refute_nil synopsis_section
2010
2063
  assert_equal :section, synopsis_section.context
2011
2064
  assert synopsis_section.special