asciidoctor 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -0
  3. data/Guardfile +18 -0
  4. data/LICENSE +1 -1
  5. data/README.adoc +65 -21
  6. data/Rakefile +10 -0
  7. data/asciidoctor.gemspec +17 -35
  8. data/compat/asciidoc.conf +130 -13
  9. data/lib/asciidoctor.rb +107 -87
  10. data/lib/asciidoctor/abstract_block.rb +6 -2
  11. data/lib/asciidoctor/abstract_node.rb +21 -13
  12. data/lib/asciidoctor/attribute_list.rb +2 -5
  13. data/{stylesheets/asciidoctor.css → lib/asciidoctor/backends/_stylesheets.rb} +96 -46
  14. data/lib/asciidoctor/backends/base_template.rb +9 -4
  15. data/lib/asciidoctor/backends/docbook45.rb +246 -138
  16. data/lib/asciidoctor/backends/html5.rb +580 -381
  17. data/lib/asciidoctor/block.rb +2 -50
  18. data/lib/asciidoctor/cli/options.rb +9 -8
  19. data/lib/asciidoctor/document.rb +35 -45
  20. data/lib/asciidoctor/helpers.rb +10 -0
  21. data/lib/asciidoctor/lexer.rb +456 -148
  22. data/lib/asciidoctor/list_item.rb +0 -21
  23. data/lib/asciidoctor/path_resolver.rb +18 -12
  24. data/lib/asciidoctor/reader.rb +71 -26
  25. data/lib/asciidoctor/renderer.rb +2 -19
  26. data/lib/asciidoctor/section.rb +0 -1
  27. data/lib/asciidoctor/substituters.rb +150 -36
  28. data/lib/asciidoctor/table.rb +30 -24
  29. data/lib/asciidoctor/version.rb +1 -1
  30. data/man/asciidoctor.1 +22 -16
  31. data/man/asciidoctor.ad +24 -16
  32. data/test/attributes_test.rb +50 -0
  33. data/test/blocks_test.rb +660 -9
  34. data/test/document_test.rb +191 -14
  35. data/test/fixtures/encoding.asciidoc +8 -0
  36. data/test/invoker_test.rb +47 -0
  37. data/test/lexer_test.rb +172 -0
  38. data/test/links_test.rb +28 -0
  39. data/test/lists_test.rb +172 -13
  40. data/test/options_test.rb +29 -2
  41. data/test/paragraphs_test.rb +105 -47
  42. data/test/paths_test.rb +3 -3
  43. data/test/reader_test.rb +46 -0
  44. data/test/sections_test.rb +365 -12
  45. data/test/substitutions_test.rb +127 -11
  46. data/test/tables_test.rb +81 -14
  47. data/test/test_helper.rb +18 -7
  48. data/test/text_test.rb +17 -5
  49. metadata +9 -36
data/test/links_test.rb CHANGED
@@ -74,6 +74,26 @@ context 'Links' do
74
74
  assert_xpath '//a[@href="http://github.com/asciidoctor"]', render_string('Asciidoctor GitHub organization: <**http://github.com/asciidoctor**>'), 1
75
75
  end
76
76
 
77
+ test 'link with quoted text should not be separated into attributes when linkattrs is set' do
78
+ assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing"]', render_embedded_string('http://search.example.com["Google, Yahoo, Bing"]', :attributes => {'linkattrs' => ''}), 1
79
+ end
80
+
81
+ test 'role and window attributes on link are processed when linkattrs is set' do
82
+ assert_xpath '//a[@href="http://google.com"][@class="external"][@target="_blank"]', render_embedded_string('http://google.com[Google, role="external", window="_blank"]', :attributes => {'linkattrs' => ''}), 1
83
+ end
84
+
85
+ test 'link text that ends in ^ should set link window to _blank' do
86
+ assert_xpath '//a[@href="http://google.com"][@target="_blank"]', render_embedded_string('http://google.com[Google^]'), 1
87
+ end
88
+
89
+ test 'inline irc link' do
90
+ assert_xpath '//a[@href="irc://irc.freenode.net"][text()="irc://irc.freenode.net"]', render_embedded_string('irc://irc.freenode.net'), 1
91
+ end
92
+
93
+ test 'inline irc link with text' do
94
+ assert_xpath '//a[@href="irc://irc.freenode.net"][text()="Freenode IRC"]', render_embedded_string('irc://irc.freenode.net[Freenode IRC]'), 1
95
+ end
96
+
77
97
  test 'inline ref' do
78
98
  doc = document_from_string 'Here you can read about tigers.[[tigers]]'
79
99
  output = doc.render
@@ -119,6 +139,14 @@ context 'Links' do
119
139
  assert_xpath %{//a[@href="#tigers"][text() = "about\ntigers"]}, render_string("Want to learn <<tigers,about\ntigers>>?"), 1
120
140
  end
121
141
 
142
+ test 'xref with escaped text' do
143
+ # when \x0 was used as boundary character for passthrough, it was getting stripped
144
+ # now using \e as boundary character, which resolves issue
145
+ input = 'See the <<tigers , `[tigers]`>> section for data about tigers'
146
+ output = render_embedded_string input
147
+ assert_xpath %(//a[@href="#tigers"]/code[text()="[tigers]"]), output, 1
148
+ end
149
+
122
150
  test 'xref using macro syntax' do
123
151
  doc = document_from_string 'xref:tigers[]'
124
152
  doc.references[:ids]['tigers'] = '[tigers]'
data/test/lists_test.rb CHANGED
@@ -322,6 +322,23 @@ para
322
322
  assert_xpath '(//ul/li)[1]/*[@class="literalblock"]/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
323
323
  end
324
324
 
325
+ test 'an admonition paragraph attached by a line continuation to a list item with wrapped text should produce admonition' do
326
+ input = <<-EOS
327
+ - first-line text
328
+ wrapped text
329
+ +
330
+ NOTE: This is a note.
331
+ EOS
332
+
333
+ output = render_embedded_string input
334
+ assert_css 'ul', output, 1
335
+ assert_css 'ul > li', output, 1
336
+ assert_css 'ul > li > p', output, 1
337
+ assert_xpath %(//ul/li/p[text()="first-line text\nwrapped text"]), output, 1
338
+ assert_css 'ul > li > p + .admonitionblock.note', output, 1
339
+ assert_xpath '//ul/li/*[@class="admonitionblock note"]//td[@class="content"][normalize-space(text())="This is a note."]', output, 1
340
+ end
341
+
325
342
  test 'appends line as paragraph if attached by continuation following line comment' do
326
343
  input = <<-EOS
327
344
  - list item 1
@@ -1020,7 +1037,7 @@ Lists
1020
1037
  assert_xpath '//ul/li[1]/p', output, 1
1021
1038
  assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@id="beck"][@class = "listingblock"]', output, 1
1022
1039
  assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@id="beck"]/div[@class="title"][starts-with(text(),"Read")]', output, 1
1023
- assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@id="beck"]//code[@class="ruby"][starts-with(text(),"5.times")]', output, 1
1040
+ assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@id="beck"]//code[@class="ruby language-ruby"][starts-with(text(),"5.times")]', output, 1
1024
1041
  end
1025
1042
 
1026
1043
  test 'trailing block attribute line attached by continuation should not create block' do
@@ -1681,6 +1698,22 @@ def2
1681
1698
  assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
1682
1699
  end
1683
1700
 
1701
+ test 'consecutive terms share same varlistentry in docbook' do
1702
+ input = <<-EOS
1703
+ term::
1704
+ alt term::
1705
+ definition
1706
+
1707
+ last::
1708
+ EOS
1709
+ output = render_embedded_string input, :backend => 'docbook'
1710
+ assert_xpath '//varlistentry', output, 2
1711
+ assert_xpath '(//varlistentry)[1]/term', output, 2
1712
+ assert_xpath '(//varlistentry)[2]/term', output, 1
1713
+ assert_xpath '(//varlistentry)[2]/listitem', output, 1
1714
+ assert_xpath '(//varlistentry)[2]/listitem[normalize-space(text())=""]', output, 1
1715
+ end
1716
+
1684
1717
  test "multi-line elements with blank line before paragraph content" do
1685
1718
  input = <<-EOS
1686
1719
  term1::
@@ -2192,6 +2225,23 @@ term 2:: def 2
2192
2225
  assert_css '.dlist dt:not([class])', output, 2
2193
2226
  end
2194
2227
 
2228
+ test 'consecutive glossary terms should share same glossentry element in docbook' do
2229
+ input = <<-EOS
2230
+ [glossary]
2231
+ term::
2232
+ alt term::
2233
+ definition
2234
+
2235
+ last::
2236
+ EOS
2237
+ output = render_embedded_string input, :backend => 'docbook'
2238
+ assert_xpath '/glossentry', output, 2
2239
+ assert_xpath '(/glossentry)[1]/glossterm', output, 2
2240
+ assert_xpath '(/glossentry)[2]/glossterm', output, 1
2241
+ assert_xpath '(/glossentry)[2]/glossdef', output, 1
2242
+ assert_xpath '(/glossentry)[2]/glossdef[normalize-space(text())=""]', output, 1
2243
+ end
2244
+
2195
2245
  test 'should render horizontal list with proper markup' do
2196
2246
  input = <<-EOS
2197
2247
  [horizontal]
@@ -2204,7 +2254,7 @@ second term:: definition
2204
2254
  output = render_embedded_string input
2205
2255
  assert_css '.hdlist', output, 1
2206
2256
  assert_css '.hdlist table', output, 1
2207
- assert_css '.hdlist table colgroup col', output, 2
2257
+ assert_css '.hdlist table colgroup', output, 0
2208
2258
  assert_css '.hdlist table tr', output, 2
2209
2259
  assert_xpath '/*[@class="hdlist"]/table/tr[1]/td', output, 2
2210
2260
  assert_xpath '/*[@class="hdlist"]/table/tr[1]/td[@class="hdlist1"]', output, 1
@@ -2219,6 +2269,74 @@ second term:: definition
2219
2269
  assert_xpath '((//tr)[2]/td)[2]/p[normalize-space(text())="definition"]', output, 1
2220
2270
  end
2221
2271
 
2272
+ test 'should set col widths of item and label if specified' do
2273
+ input = <<-EOS
2274
+ [horizontal]
2275
+ [labelwidth="25", itemwidth="75"]
2276
+ term:: def
2277
+ EOS
2278
+
2279
+ output = render_embedded_string input
2280
+ assert_css 'table', output, 1
2281
+ assert_css 'table > colgroup', output, 1
2282
+ assert_css 'table > colgroup > col', output, 2
2283
+ assert_xpath '(//table/colgroup/col)[1][@style="width:25%;"]', output, 1
2284
+ assert_xpath '(//table/colgroup/col)[2][@style="width:75%;"]', output, 1
2285
+ end
2286
+
2287
+ test 'consecutive terms in horizontal list should share same cell' do
2288
+ input = <<-EOS
2289
+ [horizontal]
2290
+ term::
2291
+ alt term::
2292
+ definition
2293
+
2294
+ last::
2295
+ EOS
2296
+ output = render_embedded_string input
2297
+ assert_xpath '//tr', output, 2
2298
+ assert_xpath '(//tr)[1]/td[@class="hdlist1"]', output, 1
2299
+ assert_xpath '(//tr)[1]/td[@class="hdlist1"]/br', output, 2
2300
+ assert_xpath '(//tr)[2]/td[@class="hdlist2"]', output, 1
2301
+ end
2302
+
2303
+ test 'consecutive terms in horizontal list should share same entry in docbook' do
2304
+ input = <<-EOS
2305
+ [horizontal]
2306
+ term::
2307
+ alt term::
2308
+ definition
2309
+
2310
+ last::
2311
+ EOS
2312
+ output = render_embedded_string input, :backend => 'docbook'
2313
+ assert_xpath '//row', output, 2
2314
+ assert_xpath '(//row)[1]/entry', output, 2
2315
+ assert_xpath '((//row)[1]/entry)[1]/simpara', output, 2
2316
+ assert_xpath '(//row)[2]/entry', output, 2
2317
+ assert_xpath '((//row)[2]/entry)[2][normalize-space(text())=""]', output, 1
2318
+ end
2319
+
2320
+ test 'should render horizontal list in docbook with proper markup' do
2321
+ input = <<-EOS
2322
+ .Terms
2323
+ [horizontal]
2324
+ first term:: definition
2325
+ +
2326
+ more detail
2327
+
2328
+ second term:: definition
2329
+ EOS
2330
+ output = render_embedded_string input, :backend => 'docbook'
2331
+ assert_xpath '/table', output, 1
2332
+ assert_xpath '/table[@tabstyle="horizontal"]', output, 1
2333
+ assert_xpath '/table[@tabstyle="horizontal"]/title[text()="Terms"]', output, 1
2334
+ assert_xpath '/table//row', output, 2
2335
+ assert_xpath '(/table//row)[1]/entry', output, 2
2336
+ assert_xpath '(/table//row)[2]/entry', output, 2
2337
+ assert_xpath '((/table//row)[1]/entry)[2]/simpara', output, 2
2338
+ end
2339
+
2222
2340
  test 'should render qanda list in HTML with proper semantics' do
2223
2341
  input = <<-EOS
2224
2342
  [qanda]
@@ -2261,6 +2379,24 @@ Question 2::
2261
2379
  end
2262
2380
  end
2263
2381
 
2382
+ test 'consecutive questions should share same question element in docbook' do
2383
+ input = <<-EOS
2384
+ [qanda]
2385
+ question::
2386
+ follow-up question::
2387
+ response
2388
+
2389
+ last question::
2390
+ EOS
2391
+ output = render_embedded_string input, :backend => 'docbook'
2392
+ assert_xpath '//qandaentry', output, 2
2393
+ assert_xpath '(//qandaentry)[1]/question', output, 1
2394
+ assert_xpath '(//qandaentry)[1]/question/simpara', output, 2
2395
+ assert_xpath '(//qandaentry)[2]/question', output, 1
2396
+ assert_xpath '(//qandaentry)[2]/answer', output, 1
2397
+ assert_xpath '(//qandaentry)[2]/answer[normalize-space(text())=""]', output, 1
2398
+ end
2399
+
2264
2400
  test 'should render bibliography list with proper semantics' do
2265
2401
  input = <<-EOS
2266
2402
  [bibliography]
@@ -3297,7 +3433,7 @@ end
3297
3433
  context 'Callout lists' do
3298
3434
  test 'listing block with sequential callouts followed by adjacent callout list' do
3299
3435
  input = <<-EOS
3300
- [source]
3436
+ [source, ruby]
3301
3437
  ----
3302
3438
  require 'asciidoctor' # <1>
3303
3439
  doc = Asciidoctor::Document.new('Hello, World!') # <2>
@@ -3321,7 +3457,7 @@ puts doc.render # <3>
3321
3457
 
3322
3458
  test 'listing block with sequential callouts followed by non-adjacent callout list' do
3323
3459
  input = <<-EOS
3324
- [source]
3460
+ [source, ruby]
3325
3461
  ----
3326
3462
  require 'asciidoctor' # <1>
3327
3463
  doc = Asciidoctor::Document.new('Hello, World!') # <2>
@@ -3349,7 +3485,7 @@ Paragraph.
3349
3485
 
3350
3486
  test 'listing block with a callout that refers to two different lines' do
3351
3487
  input = <<-EOS
3352
- [source]
3488
+ [source, ruby]
3353
3489
  ----
3354
3490
  require 'asciidoctor' # <1>
3355
3491
  doc = Asciidoctor::Document.new('Hello, World!') # <2>
@@ -3371,7 +3507,7 @@ puts doc.render # <2>
3371
3507
 
3372
3508
  test 'listing block with non-sequential callouts followed by adjacent callout list' do
3373
3509
  input = <<-EOS
3374
- [source]
3510
+ [source, ruby]
3375
3511
  ----
3376
3512
  require 'asciidoctor' # <2>
3377
3513
  doc = Asciidoctor::Document.new('Hello, World!') # <3>
@@ -3396,13 +3532,13 @@ puts doc.render # <1>
3396
3532
  test 'two listing blocks can share the same callout list' do
3397
3533
  input = <<-EOS
3398
3534
  .Import library
3399
- [source]
3535
+ [source, ruby]
3400
3536
  ----
3401
3537
  require 'asciidoctor' # <1>
3402
3538
  ----
3403
3539
 
3404
3540
  .Use library
3405
- [source]
3541
+ [source, ruby]
3406
3542
  ----
3407
3543
  doc = Asciidoctor::Document.new('Hello, World!') # <2>
3408
3544
  puts doc.render # <3>
@@ -3427,14 +3563,14 @@ puts doc.render # <3>
3427
3563
  test 'two listing blocks each followed by an adjacent callout list' do
3428
3564
  input = <<-EOS
3429
3565
  .Import library
3430
- [source]
3566
+ [source, ruby]
3431
3567
  ----
3432
3568
  require 'asciidoctor' # <1>
3433
3569
  ----
3434
3570
  <1> Describe the first line
3435
3571
 
3436
3572
  .Use library
3437
- [source]
3573
+ [source, ruby]
3438
3574
  ----
3439
3575
  doc = Asciidoctor::Document.new('Hello, World!') # <1>
3440
3576
  puts doc.render # <2>
@@ -3459,7 +3595,7 @@ puts doc.render # <2>
3459
3595
 
3460
3596
  test 'callout list with block content' do
3461
3597
  input = <<-EOS
3462
- [source]
3598
+ [source, ruby]
3463
3599
  ----
3464
3600
  require 'asciidoctor' # <1>
3465
3601
  doc = Asciidoctor::Document.new('Hello, World!') # <2>
@@ -3486,7 +3622,7 @@ You can write this to file rather than printing to stdout.
3486
3622
 
3487
3623
  test 'escaped callout should not be interpreted as a callout' do
3488
3624
  input = <<-EOS
3489
- [source]
3625
+ [source, ruby]
3490
3626
  ----
3491
3627
  require 'asciidoctor' # \\<1>
3492
3628
  ----
@@ -3518,7 +3654,7 @@ Violets are blue <2>
3518
3654
 
3519
3655
  test 'callout list with icons enabled' do
3520
3656
  input = <<-EOS
3521
- [source]
3657
+ [source, ruby]
3522
3658
  ----
3523
3659
  require 'asciidoctor' # <1>
3524
3660
  doc = Asciidoctor::Document.new('Hello, World!') # <2>
@@ -3538,4 +3674,27 @@ puts doc.render # <3>
3538
3674
  assert_xpath %((/div[@class="colist arabic"]//td/img)[#{i}][@src="./images/icons/callouts/#{i}.png"][@alt="#{i}"]), output, 1
3539
3675
  end
3540
3676
  end
3677
+
3678
+ test 'callout list with font-based icons enabled' do
3679
+ input = <<-EOS
3680
+ [source]
3681
+ ----
3682
+ require 'asciidoctor' # <1>
3683
+ doc = Asciidoctor::Document.new('Hello, World!') # <2>
3684
+ puts doc.render # <3>
3685
+ ----
3686
+ <1> Describe the first line
3687
+ <2> Describe the second line
3688
+ <3> Describe the third line
3689
+ EOS
3690
+ output = render_embedded_string input, :attributes => {'icons' => 'font'}
3691
+ assert_css '.listingblock code > i', output, 3
3692
+ (1..3).each do |i|
3693
+ assert_xpath %((/div[@class="listingblock"]//code/i)[#{i}][@class="conum"][text() = "#{i}"]), output, 1
3694
+ end
3695
+ assert_css '.colist table td i', output, 3
3696
+ (1..3).each do |i|
3697
+ assert_xpath %((/div[@class="colist arabic"]//td/i)[#{i}][@class="conum"][text() = "#{i}"]), output, 1
3698
+ end
3699
+ end
3541
3700
  end
data/test/options_test.rb CHANGED
@@ -20,9 +20,9 @@ context 'Options' do
20
20
 
21
21
  test 'should return error code 1 when option has invalid argument' do
22
22
  redirect_streams do |stdout, stderr|
23
- exitval = Asciidoctor::Cli::Options.parse!(%w(-b foo input.ad))
23
+ exitval = Asciidoctor::Cli::Options.parse!(%w(-d chapter input.ad)) # had to change for #320
24
24
  assert_equal 1, exitval
25
- assert_equal 'asciidoctor: invalid argument: -b foo', stderr.string.chomp
25
+ assert_equal 'asciidoctor: invalid argument: -d chapter', stderr.string.chomp
26
26
  end
27
27
  end
28
28
 
@@ -65,4 +65,31 @@ context 'Options' do
65
65
  assert_equal '', options[:attributes]['icons']
66
66
  end
67
67
 
68
+ test 'should only split attribute key/value pairs on first equal sign' do
69
+ options = Asciidoctor::Cli::Options.parse!(%w(-a name=value=value test/fixtures/sample.asciidoc))
70
+
71
+ assert_equal 'value=value', options[:attributes]['name']
72
+ end
73
+
74
+ test 'should allow any backend to be specified' do
75
+ options = Asciidoctor::Cli::Options.parse!(%w(-b my_custom_backend test/fixtures/sample.asciidoc))
76
+
77
+ assert_equal 'my_custom_backend', options[:attributes]['backend']
78
+ end
79
+
80
+ test 'article doctype assignment' do
81
+ options = Asciidoctor::Cli::Options.parse!(%w(-d article test/fixtures/sample.asciidoc))
82
+ assert_equal 'article', options[:attributes]['doctype']
83
+ end
84
+
85
+ test 'book doctype assignment' do
86
+ options = Asciidoctor::Cli::Options.parse!(%w(-d book test/fixtures/sample.asciidoc))
87
+ assert_equal 'book', options[:attributes]['doctype']
88
+ end
89
+
90
+ test 'inline doctype assignment' do
91
+ options = Asciidoctor::Cli::Options.parse!(%w(-d inline test/fixtures/sample.asciidoc))
92
+ assert_equal 'inline', options[:attributes]['doctype']
93
+ end
94
+
68
95
  end
@@ -252,7 +252,7 @@ use the source, luke!
252
252
  die 'zomg perl sucks';
253
253
  EOS
254
254
  output = render_embedded_string input
255
- assert_xpath %(/*[@class="listingblock"]//pre[@class="highlight"]/code[@class="perl"][text()="die 'zomg perl sucks';"]), output, 1
255
+ assert_xpath %(/*[@class="listingblock"]//pre[@class="highlight"]/code[@class="perl language-perl"][text()="die 'zomg perl sucks';"]), output, 1
256
256
  end
257
257
 
258
258
  test 'literal paragraph terminates at block attribute list' do
@@ -292,28 +292,12 @@ normal text
292
292
  end
293
293
 
294
294
  context 'Quote' do
295
- test "quote block" do
296
- output = render_string("____\nFamous quote.\n____")
297
- assert_xpath '//*[@class = "quoteblock"]', output, 1
298
- assert_xpath '//*[@class = "quoteblock"]//p[text() = "Famous quote."]', output, 1
299
- end
300
-
301
- test "quote block with attribution" do
302
- output = render_string("[quote, A famous person, A famous book (1999)]\n____\nFamous quote.\n____")
303
- assert_xpath '//*[@class = "quoteblock"]', output, 1
304
- assert_xpath '//*[@class = "quoteblock"]/*[@class = "attribution"]', output, 1
305
- assert_xpath '//*[@class = "quoteblock"]/*[@class = "attribution"]/cite[text() = "A famous book (1999)"]', output, 1
306
- # TODO I can't seem to match the attribution (author) w/ xpath
307
- end
308
-
309
- test "quote block with section body" do
310
- output = render_string("____\nFamous quote.\n\nNOTE: That was inspiring.\n____")
311
- assert_xpath '//*[@class = "quoteblock"]', output, 1
312
- assert_xpath '//*[@class = "quoteblock"]//*[@class = "admonitionblock note"]', output, 1
313
- end
314
-
315
295
  test "single-line quote paragraph" do
316
- output = render_string("[quote]\nFamous quote.")
296
+ input = <<-EOS
297
+ [quote]
298
+ Famous quote.
299
+ EOS
300
+ output = render_string input
317
301
  assert_xpath '//*[@class = "quoteblock"]', output, 1
318
302
  assert_xpath '//*[@class = "quoteblock"]//p', output, 0
319
303
  assert_xpath '//*[@class = "quoteblock"]//*[contains(text(), "Famous quote.")]', output, 1
@@ -339,31 +323,6 @@ A famouse quote.
339
323
  assert_xpath '//*[@class = "verseblock"]/pre[normalize-space(text()) = "Famous verse."]', output, 1
340
324
  end
341
325
 
342
- test "single-line verse block" do
343
- output = render_string("[verse]\n____\nFamous verse.\n____")
344
- assert_xpath '//*[@class = "verseblock"]', output, 1
345
- assert_xpath '//*[@class = "verseblock"]/pre', output, 1
346
- assert_xpath '//*[@class = "verseblock"]//p', output, 0
347
- assert_xpath '//*[@class = "verseblock"]/pre[normalize-space(text()) = "Famous verse."]', output, 1
348
- end
349
-
350
- test "multi-line verse block" do
351
- output = render_string("[verse]\n____\nFamous verse.\n\nStanza two.\n____")
352
- assert_xpath '//*[@class = "verseblock"]', output, 1
353
- assert_xpath '//*[@class = "verseblock"]/pre', output, 1
354
- assert_xpath '//*[@class = "verseblock"]//p', output, 0
355
- assert_xpath '//*[@class = "verseblock"]/pre[contains(text(), "Famous verse.")]', output, 1
356
- assert_xpath '//*[@class = "verseblock"]/pre[contains(text(), "Stanza two.")]', output, 1
357
- end
358
-
359
- test "verse block does not contain block elements" do
360
- output = render_string("[verse]\n____\nFamous verse.\n\n....\nnot a literal\n....\n____")
361
- assert_xpath '//*[@class = "verseblock"]', output, 1
362
- assert_xpath '//*[@class = "verseblock"]/pre', output, 1
363
- assert_xpath '//*[@class = "verseblock"]//p', output, 0
364
- assert_xpath '//*[@class = "verseblock"]//*[@class = "literalblock"]', output, 0
365
- end
366
-
367
326
  test 'quote paragraph should honor explicit subs list' do
368
327
  input = <<-EOS
369
328
  [subs="specialcharacters"]
@@ -407,5 +366,104 @@ Content goes here
407
366
  result = render_string(input)
408
367
  assert_xpath "//*[@class='sidebarblock']//p", result, 1
409
368
  end
369
+
370
+ context 'Styled Paragraphs' do
371
+ test 'should wrap text in simpara for styled paragraphs when rendered to DocBook' do
372
+ input = <<-EOS
373
+ = Book
374
+ :doctype: book
375
+
376
+ [preface]
377
+ = About this book
378
+
379
+ [abstract]
380
+ An abstract for the book.
381
+
382
+ = Part 1
383
+
384
+ [partintro]
385
+ An intro to this part.
386
+
387
+ [sidebar]
388
+ Just a side note.
389
+
390
+ [example]
391
+ As you can see here.
392
+
393
+ [quote]
394
+ Wise words from a wise person.
395
+ EOS
396
+
397
+ output = render_string input, :backend => 'docbook'
398
+ assert_css 'abstract > simpara', output, 1
399
+ assert_css 'partintro > simpara', output, 1
400
+ assert_css 'sidebar > simpara', output, 1
401
+ assert_css 'informalexample > simpara', output, 1
402
+ assert_css 'blockquote > simpara', output, 1
403
+ end
404
+
405
+ test 'should wrap text in simpara for styled paragraphs with title when rendered to DocBook' do
406
+ input = <<-EOS
407
+ = Book
408
+ :doctype: book
409
+
410
+ [preface]
411
+ = About this book
412
+
413
+ [abstract]
414
+ .Abstract title
415
+ An abstract for the book.
416
+
417
+ = Part 1
418
+
419
+ [partintro]
420
+ .Part intro title
421
+ An intro to this part.
422
+
423
+ [sidebar]
424
+ .Sidebar title
425
+ Just a side note.
426
+
427
+ [example]
428
+ .Example title
429
+ As you can see here.
430
+
431
+ [quote]
432
+ .Quote title
433
+ Wise words from a wise person.
434
+ EOS
435
+
436
+ output = render_string input, :backend => 'docbook'
437
+ assert_css 'abstract > title', output, 1
438
+ assert_xpath '//abstract/title[text() = "Abstract title"]', output, 1
439
+ assert_css 'abstract > title + simpara', output, 1
440
+ assert_css 'partintro > title', output, 1
441
+ assert_xpath '//partintro/title[text() = "Part intro title"]', output, 1
442
+ assert_css 'partintro > title + simpara', output, 1
443
+ assert_css 'sidebar > title', output, 1
444
+ assert_xpath '//sidebar/title[text() = "Sidebar title"]', output, 1
445
+ assert_css 'sidebar > title + simpara', output, 1
446
+ assert_css 'example > title', output, 1
447
+ assert_xpath '//example/title[text() = "Example title"]', output, 1
448
+ assert_css 'example > title + simpara', output, 1
449
+ assert_css 'blockquote > title', output, 1
450
+ assert_xpath '//blockquote/title[text() = "Quote title"]', output, 1
451
+ assert_css 'blockquote > title + simpara', output, 1
452
+ end
453
+ end
454
+
455
+ context 'Inline doctype' do
456
+ test 'should only format and output text in first paragraph when doctype is inline' do
457
+ input = "http://asciidoc.org[AsciiDoc] is a _lightweight_ markup language...\n\nignored"
458
+ output = render_string input, :doctype => 'inline'
459
+ assert_equal '<a href="http://asciidoc.org">AsciiDoc</a> is a <em>lightweight</em> markup language&#8230;', output
460
+ end
461
+
462
+ test 'should output empty string if first block is not a paragraph' do
463
+ input = '* bullet'
464
+ output = render_string input, :doctype => 'inline'
465
+ assert output.empty?
466
+ end
467
+ end
410
468
  end
411
469
  end