asciidoctor 2.0.0.rc.2 → 2.0.0.rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ class Converter::ManPageConverter < Converter::Base
28
28
  init_backend_traits basebackend: 'manpage', filetype: 'man', outfilesuffix: '.man', supports_templates: true
29
29
  end
30
30
 
31
- def document node
31
+ def convert_document node
32
32
  unless node.attr? 'mantitle'
33
33
  raise 'asciidoctor: ERROR: doctype must be set to manpage when using manpage backend'
34
34
  end
@@ -49,7 +49,7 @@ class Converter::ManPageConverter < Converter::Base
49
49
  .\\" Language: English
50
50
  .\\")
51
51
  # TODO add document-level setting to disable capitalization of manname
52
- result << %(.TH "#{_manify manname.upcase}" "#{manvolnum}" "#{docdate}" "#{mansource ? (_manify mansource) : '\ \&'}" "#{manmanual ? (_manify manmanual) : '\ \&'}")
52
+ result << %(.TH "#{manify manname.upcase}" "#{manvolnum}" "#{docdate}" "#{mansource ? (manify mansource) : '\ \&'}" "#{manmanual ? (manify manmanual) : '\ \&'}")
53
53
  # define portability settings
54
54
  # see http://bugs.debian.org/507673
55
55
  # see http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
@@ -91,7 +91,7 @@ class Converter::ManPageConverter < Converter::Base
91
91
  if node.attr? 'manpurpose'
92
92
  mannames = node.attr 'mannames', [manname]
93
93
  result << %(.SH "#{(node.attr 'manname-title', 'NAME').upcase}"
94
- #{mannames.map {|n| _manify n }.join ', '} \\- #{_manify node.attr('manpurpose'), whitespace: :normalize})
94
+ #{mannames.map {|n| manify n }.join ', '} \\- #{manify node.attr('manpurpose'), whitespace: :normalize})
95
95
  end
96
96
  end
97
97
 
@@ -121,7 +121,7 @@ class Converter::ManPageConverter < Converter::Base
121
121
  end
122
122
 
123
123
  # NOTE embedded doesn't really make sense in the manpage backend
124
- def embedded node
124
+ def convert_embedded node
125
125
  result = [node.content]
126
126
 
127
127
  if node.footnotes? && !(node.attr? 'nofootnotes')
@@ -134,7 +134,7 @@ class Converter::ManPageConverter < Converter::Base
134
134
  result.join LF
135
135
  end
136
136
 
137
- def section node
137
+ def convert_section node
138
138
  result = []
139
139
  if node.level > 1
140
140
  macro = 'SS'
@@ -144,12 +144,12 @@ class Converter::ManPageConverter < Converter::Base
144
144
  macro = 'SH'
145
145
  stitle = node.title.upcase
146
146
  end
147
- result << %(.#{macro} "#{_manify stitle}"
147
+ result << %(.#{macro} "#{manify stitle}"
148
148
  #{node.content})
149
149
  result.join LF
150
150
  end
151
151
 
152
- def admonition node
152
+ def convert_admonition node
153
153
  result = []
154
154
  result << %(.if n .sp
155
155
  .RS 4
@@ -158,19 +158,19 @@ class Converter::ManPageConverter < Converter::Base
158
158
  .nr an-break-flag 1
159
159
  .br
160
160
  .ps +1
161
- .B #{node.attr 'textlabel'}#{node.title? ? "\\fP: #{_manify node.title}" : ''}
161
+ .B #{node.attr 'textlabel'}#{node.title? ? "\\fP: #{manify node.title}" : ''}
162
162
  .ps -1
163
163
  .br
164
- #{_enclose_content node}
164
+ #{enclose_content node}
165
165
  .sp .5v
166
166
  .RE)
167
167
  result.join LF
168
168
  end
169
169
 
170
- def colist node
170
+ def convert_colist node
171
171
  result = []
172
172
  result << %(.sp
173
- .B #{_manify node.title}
173
+ .B #{manify node.title}
174
174
  .br) if node.title?
175
175
  result << '.TS
176
176
  tab(:);
@@ -179,7 +179,7 @@ r lw(\n(.lu*75u/100u).'
179
179
  num = 0
180
180
  node.items.each do |item|
181
181
  result << %(\\fB(#{num += 1})\\fP\\h'-2n':T{)
182
- result << (_manify item.text, whitespace: :normalize)
182
+ result << (manify item.text, whitespace: :normalize)
183
183
  result << item.content if item.blocks?
184
184
  result << 'T}'
185
185
  end
@@ -188,10 +188,10 @@ r lw(\n(.lu*75u/100u).'
188
188
  end
189
189
 
190
190
  # TODO implement horizontal (if it makes sense)
191
- def dlist node
191
+ def convert_dlist node
192
192
  result = []
193
193
  result << %(.sp
194
- .B #{_manify node.title}
194
+ .B #{manify node.title}
195
195
  .br) if node.title?
196
196
  counter = 0
197
197
  node.items.each do |terms, dd|
@@ -199,15 +199,15 @@ r lw(\n(.lu*75u/100u).'
199
199
  case node.style
200
200
  when 'qanda'
201
201
  result << %(.sp
202
- #{counter}. #{_manify terms.map {|dt| dt.text }.join ' '}
202
+ #{counter}. #{manify terms.map {|dt| dt.text }.join ' '}
203
203
  .RS 4)
204
204
  else
205
205
  result << %(.sp
206
- #{_manify terms.map {|dt| dt.text }.join(', '), whitespace: :normalize}
206
+ #{manify terms.map {|dt| dt.text }.join(', '), whitespace: :normalize}
207
207
  .RS 4)
208
208
  end
209
209
  if dd
210
- result << (_manify dd.text, whitespace: :normalize) if dd.text?
210
+ result << (manify dd.text, whitespace: :normalize) if dd.text?
211
211
  result << dd.content if dd.blocks?
212
212
  end
213
213
  result << '.RE'
@@ -215,73 +215,73 @@ r lw(\n(.lu*75u/100u).'
215
215
  result.join LF
216
216
  end
217
217
 
218
- def example node
218
+ def convert_example node
219
219
  result = []
220
220
  result << (node.title? ? %(.sp
221
- .B #{_manify node.captioned_title}
221
+ .B #{manify node.captioned_title}
222
222
  .br) : '.sp')
223
223
  result << %(.RS 4
224
- #{_enclose_content node}
224
+ #{enclose_content node}
225
225
  .RE)
226
226
  result.join LF
227
227
  end
228
228
 
229
- def floating_title node
230
- %(.SS "#{_manify node.title}")
229
+ def convert_floating_title node
230
+ %(.SS "#{manify node.title}")
231
231
  end
232
232
 
233
- def image node
233
+ def convert_image node
234
234
  result = []
235
235
  result << (node.title? ? %(.sp
236
- .B #{_manify node.captioned_title}
236
+ .B #{manify node.captioned_title}
237
237
  .br) : '.sp')
238
238
  result << %([#{node.alt}])
239
239
  result.join LF
240
240
  end
241
241
 
242
- def listing node
242
+ def convert_listing node
243
243
  result = []
244
244
  result << %(.sp
245
- .B #{_manify node.captioned_title}
245
+ .B #{manify node.captioned_title}
246
246
  .br) if node.title?
247
247
  result << %(.sp
248
248
  .if n .RS 4
249
249
  .nf
250
- #{_manify node.content, whitespace: :preserve}
250
+ #{manify node.content, whitespace: :preserve}
251
251
  .fi
252
252
  .if n .RE)
253
253
  result.join LF
254
254
  end
255
255
 
256
- def literal node
256
+ def convert_literal node
257
257
  result = []
258
258
  result << %(.sp
259
- .B #{_manify node.title}
259
+ .B #{manify node.title}
260
260
  .br) if node.title?
261
261
  result << %(.sp
262
262
  .if n .RS 4
263
263
  .nf
264
- #{_manify node.content, whitespace: :preserve}
264
+ #{manify node.content, whitespace: :preserve}
265
265
  .fi
266
266
  .if n .RE)
267
267
  result.join LF
268
268
  end
269
269
 
270
- def sidebar node
270
+ def convert_sidebar node
271
271
  result = []
272
272
  result << (node.title? ? %(.sp
273
- .B #{_manify node.title}
273
+ .B #{manify node.title}
274
274
  .br) : '.sp')
275
275
  result << %(.RS 4
276
- #{_enclose_content node}
276
+ #{enclose_content node}
277
277
  .RE)
278
278
  result.join LF
279
279
  end
280
280
 
281
- def olist node
281
+ def convert_olist node
282
282
  result = []
283
283
  result << %(.sp
284
- .B #{_manify node.title}
284
+ .B #{manify node.title}
285
285
  .br) if node.title?
286
286
 
287
287
  node.items.each_with_index do |item, idx|
@@ -294,46 +294,46 @@ r lw(\n(.lu*75u/100u).'
294
294
  . sp -1
295
295
  . IP " #{idx + 1}." 4.2
296
296
  .\\}
297
- #{_manify item.text, whitespace: :normalize})
297
+ #{manify item.text, whitespace: :normalize})
298
298
  result << item.content if item.blocks?
299
299
  result << '.RE'
300
300
  end
301
301
  result.join LF
302
302
  end
303
303
 
304
- def open node
304
+ def convert_open node
305
305
  case node.style
306
306
  when 'abstract', 'partintro'
307
- _enclose_content node
307
+ enclose_content node
308
308
  else
309
309
  node.content
310
310
  end
311
311
  end
312
312
 
313
313
  # TODO use Page Control https://www.gnu.org/software/groff/manual/html_node/Page-Control.html#Page-Control
314
- alias page_break _skip
314
+ alias convert_page_break skip
315
315
 
316
- def paragraph node
316
+ def convert_paragraph node
317
317
  if node.title?
318
318
  %(.sp
319
- .B #{_manify node.title}
319
+ .B #{manify node.title}
320
320
  .br
321
- #{_manify node.content, whitespace: :normalize})
321
+ #{manify node.content, whitespace: :normalize})
322
322
  else
323
323
  %(.sp
324
- #{_manify node.content, whitespace: :normalize})
324
+ #{manify node.content, whitespace: :normalize})
325
325
  end
326
326
  end
327
327
 
328
- alias pass _content_only
329
- alias preamble _content_only
328
+ alias convert_pass content_only
329
+ alias convert_preamble content_only
330
330
 
331
- def quote node
331
+ def convert_quote node
332
332
  result = []
333
333
  if node.title?
334
334
  result << %(.sp
335
335
  .RS 3
336
- .B #{_manify node.title}
336
+ .B #{manify node.title}
337
337
  .br
338
338
  .RE)
339
339
  end
@@ -341,7 +341,7 @@ r lw(\n(.lu*75u/100u).'
341
341
  attribution_line = (node.attr? 'attribution') ? %[#{attribution_line}\\(em #{node.attr 'attribution'}] : nil
342
342
  result << %(.RS 3
343
343
  .ll -.6i
344
- #{_enclose_content node}
344
+ #{enclose_content node}
345
345
  .br
346
346
  .RE
347
347
  .ll)
@@ -355,16 +355,16 @@ r lw(\n(.lu*75u/100u).'
355
355
  result.join LF
356
356
  end
357
357
 
358
- def stem node
358
+ def convert_stem node
359
359
  result = []
360
360
  result << (node.title? ? %(.sp
361
- .B #{_manify node.title}
361
+ .B #{manify node.title}
362
362
  .br) : '.sp')
363
363
  open, close = BLOCK_MATH_DELIMITERS[node.style.to_sym]
364
364
  if ((equation = node.content).start_with? open) && (equation.end_with? close)
365
365
  equation = equation.slice open.length, equation.length - open.length - close.length
366
366
  end
367
- result << %(#{_manify equation, whitespace: :preserve} (#{node.style}))
367
+ result << %(#{manify equation, whitespace: :preserve} (#{node.style}))
368
368
  result.join LF
369
369
  end
370
370
 
@@ -374,7 +374,7 @@ r lw(\n(.lu*75u/100u).'
374
374
  # create empty cells as placeholders of the span.
375
375
  # To fix this, asciidoctor needs to provide an API to tell the user if a
376
376
  # given cell is being used as a colspan or rowspan.
377
- def table node
377
+ def convert_table node
378
378
  result = []
379
379
  if node.title?
380
380
  result << %(.sp
@@ -382,7 +382,7 @@ r lw(\n(.lu*75u/100u).'
382
382
  .nr an-no-space-flag 1
383
383
  .nr an-break-flag 1
384
384
  .br
385
- .B #{_manify node.captioned_title}
385
+ .B #{manify node.captioned_title}
386
386
  )
387
387
  end
388
388
  result << '.TS
@@ -419,7 +419,7 @@ allbox tab(:);'
419
419
  row_header[row_index][cell_index + 1] ||= []
420
420
  row_header[row_index][cell_index + 1] << %(#{cell_halign}tB)
421
421
  end
422
- row_text[row_index] << %(#{_manify cell.text, whitespace: :normalize}#{LF})
422
+ row_text[row_index] << %(#{manify cell.text, whitespace: :normalize}#{LF})
423
423
  elsif tsec == :body
424
424
  if row_header[row_index].empty? || row_header[row_index][cell_index].empty?
425
425
  row_header[row_index][cell_index] << %(#{cell_halign}t)
@@ -431,9 +431,9 @@ allbox tab(:);'
431
431
  when :asciidoc
432
432
  cell_content = cell.content
433
433
  when :literal
434
- cell_content = %(.nf#{LF}#{_manify cell.text, whitespace: :preserve}#{LF}.fi)
434
+ cell_content = %(.nf#{LF}#{manify cell.text, whitespace: :preserve}#{LF}.fi)
435
435
  else
436
- cell_content = _manify cell.content.join, whitespace: :normalize
436
+ cell_content = manify cell.content.join, whitespace: :normalize
437
437
  end
438
438
  row_text[row_index] << %(#{cell_content}#{LF})
439
439
  elsif tsec == :foot
@@ -443,7 +443,7 @@ allbox tab(:);'
443
443
  row_header[row_index][cell_index + 1] ||= []
444
444
  row_header[row_index][cell_index + 1] << %(#{cell_halign}tB)
445
445
  end
446
- row_text[row_index] << %(#{_manify cell.text, whitespace: :normalize}#{LF})
446
+ row_text[row_index] << %(#{manify cell.text, whitespace: :normalize}#{LF})
447
447
  end
448
448
  if cell.colspan && cell.colspan > 1
449
449
  (cell.colspan - 1).times do |i|
@@ -496,18 +496,18 @@ allbox tab(:);'
496
496
  result.join
497
497
  end
498
498
 
499
- def thematic_break node
499
+ def convert_thematic_break node
500
500
  '.sp
501
501
  .ce
502
502
  \l\'\n(.lu*25u/100u\(ap\''
503
503
  end
504
504
 
505
- alias toc _skip
505
+ alias convert_toc skip
506
506
 
507
- def ulist node
507
+ def convert_ulist node
508
508
  result = []
509
509
  result << %(.sp
510
- .B #{_manify node.title}
510
+ .B #{manify node.title}
511
511
  .br) if node.title?
512
512
  node.items.map do |item|
513
513
  result << %[.sp
@@ -519,7 +519,7 @@ allbox tab(:);'
519
519
  . sp -1
520
520
  . IP \\(bu 2.3
521
521
  .\\}
522
- #{_manify item.text, whitespace: :normalize}]
522
+ #{manify item.text, whitespace: :normalize}]
523
523
  result << item.content if item.blocks?
524
524
  result << '.RE'
525
525
  end
@@ -527,16 +527,16 @@ allbox tab(:);'
527
527
  end
528
528
 
529
529
  # FIXME git uses [verse] for the synopsis; detect this special case
530
- def verse node
530
+ def convert_verse node
531
531
  result = []
532
532
  result << (node.title? ? %(.sp
533
- .B #{_manify node.title}
533
+ .B #{manify node.title}
534
534
  .br) : '.sp')
535
535
  attribution_line = (node.attr? 'citetitle') ? %(#{node.attr 'citetitle'} ) : nil
536
536
  attribution_line = (node.attr? 'attribution') ? %[#{attribution_line}\\(em #{node.attr 'attribution'}] : nil
537
537
  result << %(.sp
538
538
  .nf
539
- #{_manify node.content, whitespace: :preserve}
539
+ #{manify node.content, whitespace: :preserve}
540
540
  .fi
541
541
  .br)
542
542
  if attribution_line
@@ -549,18 +549,18 @@ allbox tab(:);'
549
549
  result.join LF
550
550
  end
551
551
 
552
- def video node
552
+ def convert_video node
553
553
  start_param = (node.attr? 'start') ? %(&start=#{node.attr 'start'}) : ''
554
554
  end_param = (node.attr? 'end') ? %(&end=#{node.attr 'end'}) : ''
555
555
  result = []
556
556
  result << (node.title? ? %(.sp
557
- .B #{_manify node.title}
557
+ .B #{manify node.title}
558
558
  .br) : '.sp')
559
559
  result << %(<#{node.media_uri(node.attr 'target')}#{start_param}#{end_param}> (video))
560
560
  result.join LF
561
561
  end
562
562
 
563
- def inline_anchor node
563
+ def convert_inline_anchor node
564
564
  target = node.target
565
565
  case node.type
566
566
  when :link
@@ -596,20 +596,20 @@ allbox tab(:);'
596
596
  end
597
597
  end
598
598
 
599
- def inline_break node
599
+ def convert_inline_break node
600
600
  %(#{node.text}#{LF}#{ESC_FS}br)
601
601
  end
602
602
 
603
- def inline_button node
603
+ def convert_inline_button node
604
604
  %(#{ESC_BS}fB[#{ESC_BS}0#{node.text}#{ESC_BS}0]#{ESC_BS}fP)
605
605
  end
606
606
 
607
- def inline_callout node
607
+ def convert_inline_callout node
608
608
  %(#{ESC_BS}fB(#{node.text})#{ESC_BS}fP)
609
609
  end
610
610
 
611
611
  # TODO supposedly groff has footnotes, but we're in search of an example
612
- def inline_footnote node
612
+ def convert_inline_footnote node
613
613
  if (index = node.attr 'index')
614
614
  %([#{index}])
615
615
  elsif node.type == :xref
@@ -617,15 +617,15 @@ allbox tab(:);'
617
617
  end
618
618
  end
619
619
 
620
- def inline_image node
620
+ def convert_inline_image node
621
621
  (node.attr? 'link') ? %([#{node.alt}] <#{node.attr 'link'}>) : %([#{node.alt}])
622
622
  end
623
623
 
624
- def inline_indexterm node
624
+ def convert_inline_indexterm node
625
625
  node.type == :visible ? node.text : ''
626
626
  end
627
627
 
628
- def inline_kbd node
628
+ def convert_inline_kbd node
629
629
  if (keys = node.attr 'keys').size == 1
630
630
  keys[0]
631
631
  else
@@ -633,7 +633,7 @@ allbox tab(:);'
633
633
  end
634
634
  end
635
635
 
636
- def inline_menu node
636
+ def convert_inline_menu node
637
637
  caret = %[#{ESC_BS}0#{ESC_BS}(fc#{ESC_BS}0]
638
638
  menu = node.attr 'menu'
639
639
  if !(submenus = node.attr 'submenus').empty?
@@ -647,7 +647,7 @@ allbox tab(:);'
647
647
  end
648
648
 
649
649
  # NOTE use fake <BOUNDARY> element to prevent creating artificial word boundaries
650
- def inline_quoted node
650
+ def convert_inline_quoted node
651
651
  case node.type
652
652
  when :emphasis
653
653
  %(#{ESC_BS}fI<BOUNDARY>#{node.text}</BOUNDARY>#{ESC_BS}fP)
@@ -680,7 +680,7 @@ allbox tab(:);'
680
680
  # Converts HTML entity references back to their original form, escapes
681
681
  # special man characters and strips trailing whitespace.
682
682
  #
683
- # It's crucial that text only ever pass through _manify once.
683
+ # It's crucial that text only ever pass through manify once.
684
684
  #
685
685
  # str - the String to convert
686
686
  # opts - an Hash of options to control processing (default: {})
@@ -689,7 +689,7 @@ allbox tab(:);'
689
689
  # (remove spaces around newlines); :collapse - collapse adjacent whitespace to a single
690
690
  # space (default: :collapse)
691
691
  # * :append_newline a Boolean that indicates whether to append a newline to the result (default: false)
692
- def _manify str, opts = {}
692
+ def manify str, opts = {}
693
693
  case opts.fetch :whitespace, :collapse
694
694
  when :preserve
695
695
  str = str.gsub TAB, ET
@@ -732,8 +732,8 @@ allbox tab(:);'
732
732
  opts[:append_newline] ? %(#{str}#{LF}) : str
733
733
  end
734
734
 
735
- def _enclose_content node
736
- node.content_model == :compound ? node.content : %(.sp#{LF}#{_manify node.content, whitespace: :normalize})
735
+ def enclose_content node
736
+ node.content_model == :compound ? node.content : %(.sp#{LF}#{manify node.content, whitespace: :normalize})
737
737
  end
738
738
  end
739
739
  end