lib/review/textmaker.rb in review-5.7.0 vs lib/review/textmaker.rb in review-5.8.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (c) 2018-2022 Kenshi Muto +# Copyright (c) 2018-2023 Kenshi Muto # # 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". @@ -15,10 +15,11 @@ require 'review/yamlloader' require 'review/topbuilder' require 'review/version' require 'review/makerhelper' require 'review/img_math' +require 'review/img_graph' require 'review/loggable' module ReVIEW class TEXTMaker include MakerHelper @@ -29,10 +30,11 @@ def initialize @basedir = nil @logger = ReVIEW.logger @plaintext = nil @img_math = nil + @img_graph = nil @compile_errors = nil end def self.execute(*args) self.new.execute(*args) @@ -65,10 +67,11 @@ "#{@config['bookname']}-text" end def remove_old_files(path) @img_math.cleanup_mathimg + @img_graph.cleanup_graphimg FileUtils.rm_rf(path) end def execute(*args) cmd_config, yamlfile = parse_opts(args) @@ -81,10 +84,11 @@ rescue ReVIEW::ConfigError => e error! e.message end @img_math = ReVIEW::ImgMath.new(@config, path_name: '_review_math_text') + @img_graph = ReVIEW::ImgGraph.new(@config, 'top', path_name: '_review_graph') I18n.setup(@config['language']) begin generate_text_files(yamlfile) @logger.success("built #{build_path}") @@ -95,10 +99,17 @@ end if @config['math_format'] == 'imgmath' @img_math.make_math_images end + + begin + @img_graph.make_mermaid_images + rescue ApplicationError => e + error! e.message + end + @img_graph.cleanup_graphimg end def generate_text_files(yamlfile) @basedir = File.dirname(yamlfile) @path = build_path @@ -115,12 +126,12 @@ end def build_body(basetmpdir, _yamlfile) base_path = Pathname.new(@basedir) builder = if @plaintext - ReVIEW::PLAINTEXTBuilder.new(img_math: @img_math) + ReVIEW::PLAINTEXTBuilder.new(img_math: @img_math, img_graph: @img_graph) else - ReVIEW::TOPBuilder.new(img_math: @img_math) + ReVIEW::TOPBuilder.new(img_math: @img_math, img_graph: @img_graph) end @converter = ReVIEW::Converter.new(@book, builder) @book.parts.each do |part| if part.name.present? if part.file?