lib/review/rstbuilder.rb in review-4.2.0 vs lib/review/rstbuilder.rb in review-5.0.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (c) 2008-2019 Minero Aoki, Kenshi Muto +# Copyright (c) 2008-2020 Minero Aoki, Kenshi Muto # 2002-2006 Minero Aoki # # This program is free software. # You can distribute or modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. @@ -84,22 +84,22 @@ @blank_seen = true end private :blank def result - @output.string + solve_nest(@output.string) end def headline(level, label, caption) blank if label puts ".. _#{label}:" blank end p = '=' case level - when 1 then + when 1 unless label puts ".. _#{@chapter.name}:" blank end puts '=' * caption.size * 2 @@ -371,12 +371,13 @@ " :ruby:`#{base}`<#{ruby}>`_ " end def compile_kw(word, alt) if alt - then " **#{word}(#{alt.strip})** " - else " **#{word}** " + " **#{word}(#{alt.strip})** " + else + " **#{word}** " end end def compile_href(url, label) if label.blank? @@ -580,10 +581,28 @@ def centering(lines) base_parablock('centering', lines, nil) end + CAPTION_TITLES.each do |name| + class_eval %Q( + def #{name}_begin(caption = nil) + check_nested_minicolumn + @doc_status[:minicolumn] = '#{name}' + puts ".. #{name}::" + blank + puts " " + compile_inline(caption).to_s unless caption.nil? + print " " + end + + def #{name}_end + blank + @doc_status[:minicolumn] = nil + end + ), __FILE__, __LINE__ - 14 + end + def note(lines, caption = nil) base_parablock('note', lines, caption) end def memo(lines, caption = nil) @@ -703,10 +722,10 @@ def text(str) str end - def inline_chap(id) + def inline_chap(id) # rubocop:disable Lint/UselessMethodDefinition super end def inline_chapref(id) " :numref:`#{id}` "