lib/review/latexbuilder.rb in review-4.0.0 vs lib/review/latexbuilder.rb in review-4.1.0

- old
+ new

@@ -1,8 +1,8 @@ # Copyright (c) 2002-2007 Minero Aoki # 2008-2009 Minero Aoki, Kenshi Muto -# 2010-2019 Minero Aoki, Kenshi Muto, TAKAHASHI Masayoshi +# 2010-2020 Minero Aoki, Kenshi Muto, TAKAHASHI Masayoshi # # 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. # For details of the GNU LGPL, see the file "COPYING". @@ -58,11 +58,11 @@ require 'mecab' end require 'nkf' @index_mecab = MeCab::Tagger.new(@book.config['pdfmaker']['makeindex_mecab_opts']) rescue LoadError - error 'not found MeCab' + warn 'not found MeCab' end end def load_idxdb(file) table = {} @@ -297,12 +297,11 @@ blank puts '\begin{description}' end def dt(str) - str.sub!(/\[/) { '\lbrack{}' } - str.sub!(/\]/) { '\rbrack{}' } + str = str.gsub('[', '\lbrack{}').gsub(']', '\rbrack{}') puts '\item[' + str + '] \mbox{} \\\\' end def dd(lines) if @book.config['join_lines_by_lang'] @@ -480,12 +479,20 @@ end def image_header(id, caption) end + def parse_metric(type, metric) + s = super(type, metric) + if @book.config['pdfmaker']['use_original_image_size'] && s.empty? && !metric.present? + return ' ' # pass empty to \reviewincludegraphics + end + s + end + def handle_metric(str) - if @book.config['image_scale2width'] && str =~ /\Ascale=([\d.]+)\Z/ + if @book.config['pdfmaker']['image_scale2width'] && str =~ /\Ascale=([\d.]+)\Z/ return "width=#{$1}\\maxwidth" end str end @@ -1017,10 +1024,10 @@ end def inline_fn(id) if @book.config['footnotetext'] macro("footnotemark[#{@chapter.footnote(id).number}]", '') - elsif @doc_status[:caption] || @doc_status[:table] || @doc_status[:column] + elsif @doc_status[:caption] || @doc_status[:table] || @doc_status[:column] || @doc_status[:dt] @foottext[id] = @chapter.footnote(id).number macro('protect\\footnotemark', '') else macro('footnote', compile_inline(@chapter.footnote(id).content.strip)) end