lib/review/rstbuilder.rb in review-2.4.0 vs lib/review/rstbuilder.rb in review-2.5.0
- old
+ new
@@ -18,11 +18,13 @@
# package (https://pypi.python.org/pypi/sphinxcontrib-textstyle).
#
class RSTBuilder < Builder
include TextUtils
- %i[ttbold hint maru keytop labelref ref balloon strong].each { |e| Compiler.definline(e) }
+ %i[ttbold hint maru keytop labelref ref balloon strong].each do |e|
+ Compiler.definline(e)
+ end
Compiler.defsingle(:dtp, 1)
Compiler.defblock(:insn, 1)
Compiler.defblock(:planning, 0..1)
Compiler.defblock(:best, 0..1)
@@ -150,19 +152,23 @@
def dt(line)
puts line
end
def dd(lines)
- split_paragraph(lines).each { |paragraph| puts " #{paragraph.gsub(/\n/, '')}" }
+ split_paragraph(lines).each do |paragraph|
+ puts " #{paragraph.gsub(/\n/, '')}"
+ end
end
def dl_end
end
def paragraph(lines)
pre = ''
- pre = ' ' if @in_role == true
+ if @in_role
+ pre = ' '
+ end
puts pre + lines.join
puts "\n"
end
def read(lines)
@@ -184,11 +190,13 @@
puts ".. _#{id}:"
blank
end
def list_body(_id, lines, _lang)
- lines.each { |line| puts '-' + detab(line) }
+ lines.each do |line|
+ puts '-' + detab(line)
+ end
end
def base_block(_type, lines, caption = nil)
blank
puts compile_inline(caption) unless caption.nil?
@@ -211,11 +219,13 @@
print "\n"
end
lang ||= 'none'
puts ".. code-block:: #{lang}"
blank
- lines.each { |line| puts ' ' + detab(line) }
+ lines.each do |line|
+ puts ' ' + detab(line)
+ end
blank
end
def emlistnum(lines, caption = nil, lang = nil)
blank
@@ -225,22 +235,28 @@
end
lang ||= 'none'
puts ".. code-block:: #{lang}"
puts ' :linenos:'
blank
- lines.each { |line| puts ' ' + detab(line) }
+ lines.each do |line|
+ puts ' ' + detab(line)
+ end
blank
end
def listnum_body(lines, _lang)
- lines.each_with_index { |line, i| puts(i + 1).to_s.rjust(2) + ": #{line}" }
+ lines.each_with_index do |line, i|
+ puts(i + 1).to_s.rjust(2) + ": #{line}"
+ end
blank
end
def cmd(lines, _caption = nil)
puts '.. code-block:: bash'
- lines.each { |line| puts ' ' + detab(line) }
+ lines.each do |line|
+ puts ' ' + detab(line)
+ end
end
def quote(lines)
blank
puts lines.map { |line| " #{line}" }.join
@@ -255,11 +271,13 @@
" :numref:`#{id}` "
end
def image_image(id, caption, metric)
chapter, id = extract_chapter_id(id)
- scale = metric.split('=')[1].to_f * 100 if metric
+ if metric
+ scale = metric.split('=')[1].to_f * 100
+ end
puts ".. _#{id}:"
blank
puts ".. figure:: images/#{chapter.name}/#{id}.#{image_ext}"
puts " :scale:#{scale}%" if scale
@@ -351,10 +369,12 @@
else " **#{word}** "
end
end
def compile_href(url, label)
- label = url if label.blank?
+ if label.blank?
+ label = url
+ end
" `#{label} <#{url}>`_ "
end
def inline_sup(str)
" :superscript:`#{str}` "