lib/review/latexbuilder.rb in review-5.3.0 vs lib/review/latexbuilder.rb in review-5.4.0

- old
+ new

@@ -155,11 +155,11 @@ puts macro('label', chapter_label) else puts macro('label', sec_label(anchor)) puts macro('label', label) if label end - rescue + rescue StandardError app_error "unknown level: #{level}" end def nonum_begin(level, _label, caption) blank unless @output.pos == 0 @@ -197,16 +197,15 @@ def column_begin(level, label, caption) blank @doc_status[:column] = true - target = nil - if label - target = "\\hypertarget{#{column_label(label)}}{}" - else - target = "\\hypertarget{#{column_label(caption)}}{}" - end + target = if label + "\\hypertarget{#{column_label(label)}}{}" + else + "\\hypertarget{#{column_label(caption)}}{}" + end @doc_status[:caption] = true if @book.config.check_version('2', exception: false) puts '\\begin{reviewcolumn}' puts target @@ -474,15 +473,15 @@ if caption.present? if command =~ /emlist/ || command =~ /cmd/ || command =~ /source/ captionstr = macro(command + 'caption', compile_inline(caption)) else begin - if get_chap.nil? - captionstr = macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") - else - captionstr = macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") - end + captionstr = if get_chap.nil? + macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") + else + macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") + end rescue KeyError app_error "no such list: #{id}" end end end @@ -576,17 +575,16 @@ def result_metric(array) array.join(',') end def image_image(id, caption = '', metric = nil) - captionstr = nil @doc_status[:caption] = true - if @book.config.check_version('2', exception: false) - captionstr = macro('caption', compile_inline(caption)) + "\n" - else - captionstr = macro('reviewimagecaption', compile_inline(caption)) + "\n" - end + captionstr = if @book.config.check_version('2', exception: false) + macro('caption', compile_inline(caption)) + "\n" + else + macro('reviewimagecaption', compile_inline(caption)) + "\n" + end captionstr << macro('label', image_label(id)) @doc_status[:caption] = nil metrics = parse_metric('latex', metric) # image is always bound here @@ -803,11 +801,11 @@ if @latex_tsize @tsize = @latex_tsize end if @tsize - if @tsize =~ /\A[\d., ]+\Z/ + if /\A[\d., ]+\Z/.match?(@tsize) @cellwidth = @tsize.split(/\s*,\s*/) @cellwidth.collect! { |i| "p{#{i}mm}" } puts macro('begin', 'reviewtable', '|' + @cellwidth.join('|') + '|') else @cellwidth = separate_tsize(@tsize) @@ -856,11 +854,11 @@ def table_separator # puts '\hline' end def th(s, cellwidth = 'l') - if /\\\\/ =~ s + if /\\\\/.match?(s) if !@book.config.check_version('2', exception: false) && cellwidth =~ /\{/ macro('reviewth', s.gsub("\\\\\n", '\\newline{}')) else ## use shortstack for @<br> macro('reviewth', macro('shortstack[l]', s)) @@ -869,11 +867,11 @@ macro('reviewth', s) end end def td(s, cellwidth = 'l') - if /\\\\/ =~ s + if /\\\\/.match?(s) if !@book.config.check_version('2', exception: false) && cellwidth =~ /\{/ s.gsub("\\\\\n", '\\newline{}') else ## use shortstack for @<br> macro('shortstack[l]', s) @@ -968,15 +966,15 @@ blank captionstr = nil if id puts macro('begin', 'reviewequationblock') - if get_chap.nil? - captionstr = macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") - else - captionstr = macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") - end + captionstr = if get_chap.nil? + macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") + else + macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") + end end if caption_top?('equation') && captionstr puts captionstr end @@ -1277,15 +1275,15 @@ macro('reviewbibref', "[#{@chapter.bibpaper(id).number}]", bib_label(id)) end def inline_hd_chap(chap, id) n = chap.headline_index.number(id) - if n.present? && chap.number && over_secnolevel?(n) - str = I18n.t('hd_quote', [chap.headline_index.number(id), compile_inline(chap.headline(id).caption)]) - else - str = I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption)) - end + str = if n.present? && chap.number && over_secnolevel?(n) + I18n.t('hd_quote', [chap.headline_index.number(id), compile_inline(chap.headline(id).caption)]) + else + I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption)) + end if @book.config['chapterlink'] anchor = n.tr('.', '-') macro('reviewsecref', str, sec_label(anchor)) else str @@ -1412,10 +1410,10 @@ macro('reviewkw', escape(word)) end end def compile_href(url, label) - if /\A[a-z]+:/ =~ url + if /\A[a-z]+:/.match?(url) if label macro('href', escape_url(url), escape(label)) else macro('url', escape_url(url)) end