From 49c7579be873c16d91466bca121406bf752597a6 Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Sun, 29 Dec 2019 20:44:21 +0900 Subject: [PATCH 1/9] update README.md about commands --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8727beff1..006f30f64 100644 --- a/README.md +++ b/README.md @@ -22,15 +22,17 @@ Re:VIEW uses its original format('Re:VIEW format') as source files. See doc/for ## Commands -There are two commands generate files directly. +There are commands generate files directly. * review-epubmaker: generate EPUB file. * review-pdfmaker: generate PDF file using LaTeX (TeXLive). * review-textmaker: generate text files. * review-webmaker: generate Web pages. +* review-idgxmlmaker: generate InDesign XML files. And some useful commands. +* review-init: create a project. * review-compile: compile Re:VIEW format files. * review-vol: figure out size of Re:VIEW files. * review-index: generate index with various format. @@ -60,10 +62,11 @@ $ echo "export PATH=PATH_OF_REVIEW/bin:$PATH" >> ~/.profile $ review-init hello $ cd hello $ (... add and edit *.re file, config.yml and catalog.yml ...) -$ rake epub ## generating EPUB -$ rake pdf ## generating PDF (Requirement TeXLive) -$ rake text ## generating texts -$ rake web ## generating Web pages +$ rake epub ## generating EPUB +$ rake pdf ## generating PDF (Requirement TeXLive) +$ rake text ## generating texts +$ rake web ## generating Web pages +$ rake idgxml ## generating InDesign XML files ``` For further information, see [doc/quickstart.md](https://github.com/kmuto/review/blob/master/doc/quickstart.md) From c56c26b4045c3ae481ceea01472cf83ab2de88c3 Mon Sep 17 00:00:00 2001 From: Masayoshi Takahashi Date: Tue, 31 Dec 2019 23:22:06 +0900 Subject: [PATCH 2/9] items of ChapterIndex should be Index::Item (#1456) * items of ChapterIndex should be Index::Item * remove comment --- lib/review/book/base.rb | 14 +++++--------- lib/review/book/index.rb | 7 ++++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/review/book/base.rb b/lib/review/book/base.rb index 35a861daf..20f32d68d 100644 --- a/lib/review/book/base.rb +++ b/lib/review/book/base.rb @@ -136,19 +136,15 @@ def each_chapter_r(&block) def chapter_index return @chapter_index if @chapter_index - - contents = chapters - # TODO: contents += parts.find_all { |prt| prt.id.present? } - parts.each do |prt| - if prt.id.present? - contents << prt - end + chapter_items = chapters.map do |chap| + Index::Item.new(chap.id, chap.number, chap) end - @chapter_index = ChapterIndex.new(contents) + part_items = parts.select{ |prt| prt.id.present? }.map{ |prt| Index::Item.new(prt.id, prt.number, prt) } + @chapter_index = ChapterIndex.new(chapter_items + part_items) end def chapter(id) - chapter_index[id] + chapter_index[id].content end def next_chapter(chapter) diff --git a/lib/review/book/index.rb b/lib/review/book/index.rb index e9dcb3053..d9d3209f6 100644 --- a/lib/review/book/index.rb +++ b/lib/review/book/index.rb @@ -88,8 +88,9 @@ def item_type end def number(id) - chapter = @index.fetch(id) + chapter_item = @index.fetch(id) begin + chapter = chapter_item.content chapter.format_number rescue # part I18n.t('part', chapter.number) @@ -97,9 +98,9 @@ def number(id) end def title(id) - @index.fetch(id).title + @index.fetch(id).content.title rescue # non-file part - @index.fetch(id).name + @index.fetch(id).content.name end def display_string(id) From cfe720acdaf1f0980a167cd5df62bb952e415690 Mon Sep 17 00:00:00 2001 From: Masayoshi Takahashi Date: Wed, 1 Jan 2020 11:07:35 +0900 Subject: [PATCH 3/9] fix arguments of Index.new; remove items (#1457) * fix arguments of Index.new; remove items --- lib/review/book/base.rb | 13 +++-- lib/review/book/index.rb | 95 ++++++++++++++++------------------- lib/review/book/index/item.rb | 2 +- test/test_helper.rb | 2 + test/test_htmlbuilder.rb | 24 ++++++--- test/test_idgxmlbuilder.rb | 6 ++- test/test_latexbuilder.rb | 6 ++- test/test_latexbuilder_v2.rb | 6 ++- 8 files changed, 84 insertions(+), 70 deletions(-) diff --git a/lib/review/book/base.rb b/lib/review/book/base.rb index 20f32d68d..0aacf7ff3 100644 --- a/lib/review/book/base.rb +++ b/lib/review/book/base.rb @@ -136,11 +136,16 @@ def each_chapter_r(&block) def chapter_index return @chapter_index if @chapter_index - chapter_items = chapters.map do |chap| - Index::Item.new(chap.id, chap.number, chap) + @chapter_index = ChapterIndex.new + each_chapter do |chap| + @chapter_index.add_item(Index::Item.new(chap.id, chap.number, chap)) end - part_items = parts.select{ |prt| prt.id.present? }.map{ |prt| Index::Item.new(prt.id, prt.number, prt) } - @chapter_index = ChapterIndex.new(chapter_items + part_items) + parts.each do |prt| + if prt.id.present? + @chapter_index.add_item(Index::Item.new(prt.id, prt.number, prt)) + end + end + @chapter_index end def chapter(id) diff --git a/lib/review/book/index.rb b/lib/review/book/index.rb index d9d3209f6..7ba3c50f1 100644 --- a/lib/review/book/index.rb +++ b/lib/review/book/index.rb @@ -18,18 +18,18 @@ module ReVIEW module Book class Index def self.parse(src, *args) - items = [] + index = self.new(*args) seq = 1 src.grep(%r{\A//#{item_type}}) do |line| if id = line.slice(/\[(.*?)\]/, 1) - items.push(ReVIEW::Book::Index::Item.new(id, seq)) + index.add_item(ReVIEW::Book::Index::Item.new(id, seq)) seq += 1 if id.empty? ReVIEW.logger.warn "warning: no ID of #{item_type} in #{line}" end end end - new(items, *args) + index end include Enumerable @@ -38,19 +38,22 @@ def item_type self.class.item_type end - def initialize(items) - @items = items + def initialize @index = {} @logger = ReVIEW.logger - items.each do |item| - if @index[item.id] - @logger.warn "warning: duplicate ID: #{item.id} (#{item})" - end - @index[item.id] = item - end @image_finder = nil end + def add_item(item) + if @index[item.id] + @logger.warn "warning: duplicate ID: #{item.id} (#{item})" + end + @index[item.id] = item + if item.class != ReVIEW::Book::Chapter + item.index = self + end + end + def [](id) @index.fetch(id) rescue @@ -60,7 +63,7 @@ def [](id) raise KeyError, "key '#{id}' is ambiguous for #{self.class}" end - @items.each do |item| + @index.values.each do |item| if item.id.split('|').include?(id) return item end @@ -73,7 +76,7 @@ def number(id) end def each(&block) - @items.each(&block) + @index.values.each(&block) end def key?(id) @@ -132,32 +135,32 @@ def self.item_type class FootnoteIndex < Index def self.parse(src) - items = [] + index = self.new seq = 1 src.grep(%r{\A//footnote}) do |line| if m = /\[(.*?)\]\[(.*)\]/.match(line) m1 = m[1].gsub(/\\(\])/) { $1 } m2 = m[2].gsub(/\\(\])/) { $1 } - items.push(Item.new(m1, seq, m2)) + index.add_item(Item.new(m1, seq, m2)) end seq += 1 end - new(items) + index end end class ImageIndex < Index def self.parse(src, *args) - items = [] + index = self.new(*args) seq = 1 src.grep(%r{\A//#{item_type}}) do |line| # ex. ["//image", "id", "", "caption"] elements = line.split(/\[(.*?)\]/) if elements[1].present? if line.start_with?('//imgtable') - items.push(ReVIEW::Book::Index::Item.new(elements[1], 0, elements[3])) + index.add_item(ReVIEW::Book::Index::Item.new(elements[1], 0, elements[3])) else ## %r<\A//(image|graph)> - items.push(ReVIEW::Book::Index::Item.new(elements[1], seq, elements[3])) + index.add_item(ReVIEW::Book::Index::Item.new(elements[1], seq, elements[3])) seq += 1 end if elements[1] == '' @@ -165,7 +168,7 @@ def self.parse(src, *args) end end end - new(items, *args) + index end def self.item_type @@ -174,14 +177,12 @@ def self.item_type attr_reader :image_finder - def initialize(items, chapid, basedir, types, builder) - super(items) - items.each do |item| - item.index = self - end + def initialize(chapid, basedir, types, builder) + super() @chapid = chapid @basedir = basedir @types = types + @logger = ReVIEW.logger @image_finder = ReVIEW::Book::ImageFinder.new(basedir, chapid, builder, types) end @@ -192,44 +193,42 @@ def find_path(id) end class IconIndex < ImageIndex - def initialize(items, chapid, basedir, types, builder) - @items = items + def initialize(chapid, basedir, types, builder) @index = {} - items.each { |item| @index[item.id] = item } - items.each { |item| item.index = self } @chapid = chapid @basedir = basedir @types = types + @logger = ReVIEW.logger @image_finder = ImageFinder.new(basedir, chapid, builder, types) end def self.parse(src, *args) - items = [] + index = self.new(*args) seq = 1 src.grep(/@/) do |line| line.gsub(/@\{(.+?)\}/) do - items.push(ReVIEW::Book::Index::Item.new($1, seq)) + index.add_item(ReVIEW::Book::Index::Item.new($1, seq)) seq += 1 end end - new(items, *args) + index end end class BibpaperIndex < Index def self.parse(src) - items = [] + index = self.new seq = 1 src.grep(%r{\A//bibpaper}) do |line| if m = /\[(.*?)\]\[(.*)\]/.match(line) m1 = m[1].gsub(/\\(.)/) { $1 } m2 = m[2].gsub(/\\(.)/) { $1 } - items.push(Item.new(m1, seq, m2)) + index.add_item(Item.new(m1, seq, m2)) end seq += 1 end - new(items) + index end end @@ -255,10 +254,9 @@ def number(_id) class HeadlineIndex < Index HEADLINE_PATTERN = /\A(=+)(?:\[(.+?)\])?(?:\{(.+?)\})?(.*)/ - attr_reader :items def self.parse(src, chap) - items = [] + headline_index = self.new(chap) indexs = [] headlines = [] inside_column = false @@ -312,27 +310,22 @@ def self.parse(src, chap) if %w[nonum notoc nodisp].include?(m[2]) headlines[index] = m[3].present? ? m[3].strip : m[4].strip - items.push(Item.new(headlines.join('|'), nil, m[4].strip)) + item_id = headlines.join('|') + headline_index.add_item(Item.new(item_id, nil, m[4].strip)) else indexs[index] += 1 headlines[index] = m[3].present? ? m[3].strip : m[4].strip - items.push(Item.new(headlines.join('|'), indexs.dup, m[4].strip)) + item_id = headlines.join('|') + headline_index.add_item(Item.new(item_id, indexs.dup, m[4].strip)) end end - new(items, chap) + headline_index end - def initialize(items, chap) - @items = items + def initialize(chap) @chap = chap @index = {} @logger = ReVIEW.logger - items.each do |item| - if @index[item.id] - @logger.warn "warning: duplicate ID: #{item.id}" - end - @index[item.id] = item - end end def number(id) @@ -353,7 +346,7 @@ class ColumnIndex < Index COLUMN_PATTERN = /\A(=+)\[column\](?:\{(.+?)\})?(.*)/ def self.parse(src, *_args) - items = [] + index = self.new seq = 1 src.each do |line| m = COLUMN_PATTERN.match(line) @@ -363,10 +356,10 @@ def self.parse(src, *_args) caption = m[3].strip id = caption if id.nil? || id.empty? - items.push(ReVIEW::Book::Index::Item.new(id, seq, caption)) + index.add_item(ReVIEW::Book::Index::Item.new(id, seq, caption)) seq += 1 end - new(items) + index end end end diff --git a/lib/review/book/index/item.rb b/lib/review/book/index/item.rb index 848ede21e..f2edece56 100644 --- a/lib/review/book/index/item.rb +++ b/lib/review/book/index/item.rb @@ -27,7 +27,7 @@ def initialize(id, number, caption = nil) attr_reader :id attr_reader :number attr_reader :caption - attr_writer :index # internal use only + attr_accessor :index # internal use only alias_method :content, :caption diff --git a/test/test_helper.rb b/test/test_helper.rb index 89f4af910..70f06a712 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,8 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/') require 'test/unit' require 'fileutils' +require 'review/yamlloader' +require 'review/extentions' def touch_file(path) FileUtils.touch(path) diff --git a/test/test_htmlbuilder.rb b/test/test_htmlbuilder.rb index 37cd7d378..eff772803 100644 --- a/test/test_htmlbuilder.rb +++ b/test/test_htmlbuilder.rb @@ -244,8 +244,10 @@ def test_inline_ttb def test_inline_hd_chap def @chapter.headline_index - items = [Book::Index::Item.new('chap1|test', [1, 1], 'te_st')] - Book::HeadlineIndex.new(items, self) + item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st') + idx = Book::HeadlineIndex.new(self) + idx.add_item(item) + idx end @config['secnolevel'] = 2 @@ -270,8 +272,10 @@ def on_appendix? end def @chapter.headline_index - items = [Book::Index::Item.new('test', [1], 'te_st')] - Book::HeadlineIndex.new(items, self) + item = Book::Index::Item.new('test', [1], 'te_st') + idx = Book::HeadlineIndex.new(self) + idx.add_item(item) + idx end actual = compile_inline('test @{test} test2') @@ -293,8 +297,10 @@ def on_appendix? end def @chapter.headline_index - items = [Book::Index::Item.new('test', [1], 'te_st')] - Book::HeadlineIndex.new(items, self) + item = Book::Index::Item.new('test', [1], 'te_st') + idx = Book::HeadlineIndex.new(self) + idx.add_item(item) + idx end actual = compile_inline('test @{test} test2') @@ -1637,8 +1643,10 @@ def test_column_ref def test_column_in_aother_chapter_ref def @chapter.column_index - items = [Book::Index::Item.new('chap1|column', 1, 'column_cap')] - Book::ColumnIndex.new(items) + item = Book::Index::Item.new('chap1|column', 1, 'column_cap') + idx = Book::ColumnIndex.new + idx.add_item(item) + idx end actual = compile_inline('test @{chap1|column} test2') diff --git a/test/test_idgxmlbuilder.rb b/test/test_idgxmlbuilder.rb index 4b5df8742..ea71b6f4d 100644 --- a/test/test_idgxmlbuilder.rb +++ b/test/test_idgxmlbuilder.rb @@ -706,8 +706,10 @@ def test_column_ref def test_column_in_aother_chapter_ref def @chapter.column_index - items = [Book::Index::Item.new('chap1|column', 1, 'column_cap')] - Book::ColumnIndex.new(items) + item = Book::Index::Item.new('chap1|column', 1, 'column_cap') + idx = Book::ColumnIndex.new + idx.add_item(item) + idx end actual = compile_inline('test @{chap1|column} test2') diff --git a/test/test_latexbuilder.rb b/test/test_latexbuilder.rb index b9f4f4d3f..e91394874 100644 --- a/test/test_latexbuilder.rb +++ b/test/test_latexbuilder.rb @@ -247,8 +247,10 @@ def test_inline_ttb def test_inline_hd_chap def @chapter.headline_index - items = [Book::Index::Item.new('chap1|test', [1, 1], 'te_st')] - Book::HeadlineIndex.new(items, self) + item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st') + idx = Book::HeadlineIndex.new(self) + idx.add_item(item) + idx end @config['secnolevel'] = 3 diff --git a/test/test_latexbuilder_v2.rb b/test/test_latexbuilder_v2.rb index bff9c79fe..0c3975d52 100644 --- a/test/test_latexbuilder_v2.rb +++ b/test/test_latexbuilder_v2.rb @@ -221,8 +221,10 @@ def test_inline_ttb def test_inline_hd_chap def @chapter.headline_index - items = [Book::Index::Item.new('chap1|test', [1, 1], 'te_st')] - Book::HeadlineIndex.new(items, self) + item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st') + idx = Book::HeadlineIndex.new(self) + idx.add_item(item) + idx end @config['secnolevel'] = 3 From cbc7aa51ec5801809bae525789e5300635572239 Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Wed, 1 Jan 2020 11:34:10 +0900 Subject: [PATCH 4/9] happy new year --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 006f30f64..372c09e99 100644 --- a/README.md +++ b/README.md @@ -115,4 +115,4 @@ Exception: ## Copyright -Copyright (c) 2006-2019 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado. +Copyright (c) 2006-2020 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado. From cd6b58584e90bd4135abe9fb676415728c5e7f5a Mon Sep 17 00:00:00 2001 From: Masayoshi Takahashi Date: Wed, 1 Jan 2020 18:48:09 +0900 Subject: [PATCH 5/9] remove String#each (#1459) `src` in `FooIndex.parse(src)` should be `Enumerable` in compilable.rb. --- lib/review/extentions/string.rb | 4 ---- test/test_index.rb | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/review/extentions/string.rb b/lib/review/extentions/string.rb index 4449f80b8..ed981f17d 100644 --- a/lib/review/extentions/string.rb +++ b/lib/review/extentions/string.rb @@ -2,7 +2,3 @@ Encoding.default_external != Encoding::UTF_8 Encoding.default_external = 'UTF-8' end - -class String - alias_method :each, :each_line -end diff --git a/test/test_index.rb b/test/test_index.rb index ffd3352fd..c14416787 100644 --- a/test/test_index.rb +++ b/test/test_index.rb @@ -54,7 +54,7 @@ def test_headeline_index EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) # dummy - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal [2, 2], index['sec1-2|sec1-2-2'].number assert_equal '1.2.2', index.number('sec1-2|sec1-2-2') end @@ -71,7 +71,7 @@ def test_headeline_index2 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) # dummy - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines, chap) assert_equal [3, 1], index['sec1-3|sec1-3-1'].number assert_equal '1.3.1', index.number('sec1-3|sec1-3-1') end @@ -89,7 +89,7 @@ def test_headeline_index3 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) # dummy - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal [2, 2], index['sec1-2|sec1-2-2'].number assert_equal '1.2.2', index.number('sec1-2|sec1-2-2') @@ -108,7 +108,7 @@ def test_headeline_index4 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) # dummy - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal [2, 2], index['sec1-2|sec1-2-2'].number assert_equal '1.2.2', index.number('sec1-2|sec1-2-2') end @@ -124,7 +124,7 @@ def test_headeline_index5 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) # dummy - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal [2, 2], index['sec1-2-2'].number assert_equal '1.2.2', index.number('sec1-2-2') end @@ -139,7 +139,7 @@ def test_headeline_index6 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) # dummy - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal [1, 1], index['target'].number assert_equal '1.1.1', index.number('target') end @@ -157,7 +157,7 @@ def test_headeline_index7 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) # dummy - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_raise ReVIEW::KeyError do assert_equal [1, 1], index['target'].number @@ -174,7 +174,7 @@ def test_headeline_index8 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal '1.1.1', index.number('sec1-1') end @@ -190,7 +190,7 @@ def test_headeline_index9 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal [1, 1, 1], index['sec1-1-1'].number end @@ -205,7 +205,7 @@ def test_headeline_index10 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal [1, 1, 1], index['sec1-1-1'].number end @@ -222,7 +222,7 @@ def test_headeline_index11 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal nil, index['sec01'].number assert_equal nil, index['sec02'].number assert_equal [1], index['sec1'].number @@ -242,7 +242,7 @@ def test_headeline_index12 EOB book = Book::Base.load chap = Book::Chapter.new(book, 1, '-', nil) - index = Book::HeadlineIndex.parse(src, chap) + index = Book::HeadlineIndex.parse(src.lines.to_a, chap) assert_equal [1], index['A'].number assert_equal [1, 1], index['A2'].number assert_equal nil, index['B'].number From 50876fbd674d0ba7f98ac0290014cd77475ebf8f Mon Sep 17 00:00:00 2001 From: Masayoshi Takahashi Date: Wed, 1 Jan 2020 22:25:22 +0900 Subject: [PATCH 6/9] add new actions for windows (#1460) * add actions for windows * appveyor: use only 32bit --- .github/workflows/ruby-win.yml | 39 +++++++++++ appveyor.yml | 20 ------ test/test_book.rb | 8 +++ test/test_book_chapter.rb | 6 +- test/test_image_finder.rb | 122 ++++++++++++++------------------- test/test_latexbuilder.rb | 2 +- test/test_latexbuilder_v2.rb | 2 +- 7 files changed, 105 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/ruby-win.yml diff --git a/.github/workflows/ruby-win.yml b/.github/workflows/ruby-win.yml new file mode 100644 index 000000000..c0009f519 --- /dev/null +++ b/.github/workflows/ruby-win.yml @@ -0,0 +1,39 @@ +name: TestWin + +on: [push] + +jobs: + build: + + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + ruby: [ '2.6.x', '2.5.x', '2.4.x' ] + + steps: + - uses: actions/checkout@v1 + - name: Set up Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Build and test with Rake + shell: bash + run: | + gem install bundler --no-document + bundle install --retry 3 + bundle exec ruby test/run_test.rb --max-diff-target-string-size=10000 --verbose=v + - name: Test with epubcheck-ruby + shell: bash + run: | + gem install -N epubcheck-ruby + ruby bin/review-init hello + cd hello + ruby ../bin/review-epubmaker config.yml + epubcheck book.epub + cd .. + ruby bin/review-init hello2 --epub-version 2 + cd hello2 + ruby ../bin/review-epubmaker config.yml + epubcheck book.epub + cd .. diff --git a/appveyor.yml b/appveyor.yml index 9b5ee87bf..c2eadc4a5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,21 +6,6 @@ install: build_script: - bundle install - bundle exec rake test --trace --verbose - - bundle exec rubocop - -before_test: - - gem install -N epubcheck-ruby - -test_script: - - ruby bin/review-init hello - - cd hello - - ruby ../bin/review-epubmaker config.yml - - epubcheck book.epub - - cd .. - - ruby bin/review-init hello2 --epub-version 2 - - cd hello2 - - ruby ../bin/review-epubmaker config.yml - - epubcheck book.epub branches: only: @@ -28,9 +13,4 @@ branches: environment: matrix: - - ruby_version: "24" - - ruby_version: "24-x64" - - ruby_version: "25" - - ruby_version: "25-x64" - ruby_version: "26" - - ruby_version: "26-x64" diff --git a/test/test_book.rb b/test/test_book.rb index 294a2a9c7..ca72ce3a9 100644 --- a/test/test_book.rb +++ b/test/test_book.rb @@ -1,8 +1,16 @@ require 'book_test_helper' +require 'fileutils' class BookTest < Test::Unit::TestCase include BookTestHelper + def setup + if ENV['GITHUB_WORKSPACE'] + ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review') + FileUtils.mkdir_p(ENV['TMPDIR']) + end + end + def assert_same_path(expected, result, *options) require 'pathname' ex_path = Pathname(expected).realpath diff --git a/test/test_book_chapter.rb b/test/test_book_chapter.rb index 5180e9536..4e2845682 100644 --- a/test/test_book_chapter.rb +++ b/test/test_book_chapter.rb @@ -37,11 +37,13 @@ def test_name def test_size ch = Book::Chapter.new(nil, nil, nil, __FILE__, :io) - assert_equal File.size(__FILE__), ch.size + filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size + assert_equal filesize, ch.size File.open(__FILE__, 'r') do |i| ch = Book::Chapter.new(nil, nil, nil, nil, i) - assert_equal File.size(__FILE__), ch.size + filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size + assert_equal filesize, ch.size end end diff --git a/test/test_image_finder.rb b/test/test_image_finder.rb index cc428b6ba..d87ea6efc 100644 --- a/test/test_image_finder.rb +++ b/test/test_image_finder.rb @@ -7,93 +7,75 @@ class ImageFinderTest < Test::Unit::TestCase include ReVIEW def setup + if ENV['GITHUB_WORKSPACE'] + ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review') + FileUtils.mkdir_p(ENV['TMPDIR']) + end + @dir = Dir.mktmpdir end - def test_find_path_pattern1 - dir = Dir.mktmpdir - begin - path = File.join(dir, 'builder/ch01/foo.jpg') - FileUtils.mkdir_p(File.dirname(path)) - FileUtils.touch(path) - - finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg']) - assert_equal(path, finder.find_path('foo')) - ensure - FileUtils.remove_entry_secure(dir) + def teardown + if @dir + FileUtils.remove_entry_secure(@dir) end end + def test_find_path_pattern1 + path = File.join(@dir, 'builder/ch01/foo.jpg') + FileUtils.mkdir_p(File.dirname(path)) + FileUtils.touch(path) + + finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg']) + + assert_equal(path, finder.find_path('foo')) + end + def test_find_path_pattern2 - dir = Dir.mktmpdir - begin - path = File.join(dir, 'builder/ch01-foo.jpg') - FileUtils.mkdir_p(File.dirname(path)) - FileUtils.touch(path) - - finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg']) - assert_equal(path, finder.find_path('foo')) - ensure - FileUtils.remove_entry_secure(dir) - end + path = File.join(@dir, 'builder/ch01-foo.jpg') + FileUtils.mkdir_p(File.dirname(path)) + FileUtils.touch(path) + + finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg']) + assert_equal(path, finder.find_path('foo')) end def test_find_path_pattern3 - dir = Dir.mktmpdir - begin - path = File.join(dir, 'builder/foo.jpg') - FileUtils.mkdir_p(File.dirname(path)) - FileUtils.touch(path) - - finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg']) - assert_equal(path, finder.find_path('foo')) - ensure - FileUtils.remove_entry_secure(dir) - end + path = File.join(@dir, 'builder/foo.jpg') + FileUtils.mkdir_p(File.dirname(path)) + FileUtils.touch(path) + + finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg']) + assert_equal(path, finder.find_path('foo')) end def test_find_path_pattern4 - dir = Dir.mktmpdir - begin - path = File.join(dir, 'ch01/foo.jpg') - FileUtils.mkdir_p(File.dirname(path)) - FileUtils.touch(path) - - finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg']) - assert_equal(path, finder.find_path('foo')) - ensure - FileUtils.remove_entry_secure(dir) - end + path = File.join(@dir, 'ch01/foo.jpg') + FileUtils.mkdir_p(File.dirname(path)) + FileUtils.touch(path) + + finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg']) + assert_equal(path, finder.find_path('foo')) end def test_find_path_pattern5 - dir = Dir.mktmpdir - begin - path = File.join(dir, 'ch01-foo.jpg') - FileUtils.mkdir_p(File.dirname(path)) - FileUtils.touch(path) - - finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg']) - assert_equal(path, finder.find_path('foo')) - ensure - FileUtils.remove_entry_secure(dir) - end + path = File.join(@dir, 'ch01-foo.jpg') + FileUtils.mkdir_p(File.dirname(path)) + FileUtils.touch(path) + + finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg']) + assert_equal(path, finder.find_path('foo')) end def test_find_path_dir_symlink - dir = Dir.mktmpdir - begin - path_src = File.join(dir, 'src') - path_dst = File.join(dir, 'ch01') - FileUtils.mkdir_p(path_src) - FileUtils.symlink(path_src, path_dst) - path_srcimg = File.join(path_src, 'foo.jpg') - path_dstimg = File.join(path_dst, 'foo.jpg') - FileUtils.touch(path_srcimg) - - finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg']) - assert_equal(path_dstimg, finder.find_path('foo')) - ensure - FileUtils.remove_entry_secure(dir) - end + path_src = File.join(@dir, 'src') + path_dst = File.join(@dir, 'ch01') + FileUtils.mkdir_p(path_src) + FileUtils.symlink(path_src, path_dst) + path_srcimg = File.join(path_src, 'foo.jpg') + path_dstimg = File.join(path_dst, 'foo.jpg') + FileUtils.touch(path_srcimg) + + finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg']) + assert_equal(path_dstimg, finder.find_path('foo')) end end diff --git a/test/test_latexbuilder.rb b/test/test_latexbuilder.rb index e91394874..d494c22c1 100644 --- a/test/test_latexbuilder.rb +++ b/test/test_latexbuilder.rb @@ -284,9 +284,9 @@ def test_inline_idx end def test_inline_idx_yomi + require 'nkf' begin require 'MeCab' - require 'nkf' rescue LoadError $stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)' return true diff --git a/test/test_latexbuilder_v2.rb b/test/test_latexbuilder_v2.rb index 0c3975d52..bf9e2673c 100644 --- a/test/test_latexbuilder_v2.rb +++ b/test/test_latexbuilder_v2.rb @@ -253,9 +253,9 @@ def test_inline_idx end def test_inline_idx_yomi + require 'nkf' begin require 'MeCab' - require 'nkf' rescue LoadError $stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)' return true From ec10dd33cc93ebc084b40428b8be45698b79824d Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Thu, 2 Jan 2020 14:46:26 +0900 Subject: [PATCH 7/9] PDFMaker: introduce pdfmaker/use_original_image_size parameter to disable an automatic image scaling. Closes: #1461 --- doc/config.yml.sample | 3 ++ lib/review/compiler.rb | 4 +- lib/review/configure.rb | 5 +- lib/review/latexbuilder.rb | 10 +++- test/test_latexbuilder.rb | 93 +++++++++++++++++++++++++++++++++++++- 5 files changed, 109 insertions(+), 6 deletions(-) diff --git a/doc/config.yml.sample b/doc/config.yml.sample index 4c70077c6..24dfefd81 100644 --- a/doc/config.yml.sample +++ b/doc/config.yml.sample @@ -381,6 +381,9 @@ pdfmaker: # 画像のscale=X.Xという指定を画像拡大縮小率からページ最大幅の相対倍率に変換する # image_scale2width: true # + # 画像のデフォルトのサイズを、版面横幅合わせではなく、原寸をそのまま利用する + # use_original_image_size: null + # # PDFやIllustratorファイル(.ai)の画像のBoudingBoxの抽出に指定のボックスを採用する # cropbox(デフォルト), mediabox, artbox, trimbox, bleedboxから選択する。 # Illustrator CC以降のIllustratorファイルに対してはmediaboxを指定する必要がある diff --git a/lib/review/compiler.rb b/lib/review/compiler.rb index 501935bf3..1fede23dc 100644 --- a/lib/review/compiler.rb +++ b/lib/review/compiler.rb @@ -1,4 +1,4 @@ -# Copyright (c) 2009-2019 Minero Aoki, Kenshi Muto +# Copyright (c) 2009-2020 Minero Aoki, Kenshi Muto # Copyright (c) 2002-2007 Minero Aoki # # This program is free software. @@ -115,7 +115,7 @@ def inline_defined?(name) defblock :emlist, 0..2 defblock :cmd, 0..1 defblock :table, 0..2 - defblock :imgtable, 0..2 + defblock :imgtable, 0..3 defblock :emtable, 0..1 defblock :quote, 0 defblock :image, 2..3, true diff --git a/lib/review/configure.rb b/lib/review/configure.rb index f1c11b305..70efa4d42 100644 --- a/lib/review/configure.rb +++ b/lib/review/configure.rb @@ -1,5 +1,5 @@ # -# Copyright (c) 2012-2019 Masanori Kado, Masayoshi Takahashi, Kenshi Muto +# Copyright (c) 2012-2020 Masanori Kado, Masayoshi Takahashi, Kenshi Muto # # This program is free software. # You can distribute or modify this program under the terms of @@ -92,7 +92,8 @@ def self.values 'makeindex_dic' => nil, 'makeindex_mecab' => true, 'makeindex_mecab_opts' => '-Oyomi', - 'use_cover_nombre' => true + 'use_cover_nombre' => true, + 'use_original_image_size' => nil }, 'imgmath_options' => { 'format' => 'png', diff --git a/lib/review/latexbuilder.rb b/lib/review/latexbuilder.rb index 6eba40680..e82e29389 100644 --- a/lib/review/latexbuilder.rb +++ b/lib/review/latexbuilder.rb @@ -1,6 +1,6 @@ # 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 @@ -482,6 +482,14 @@ def source(lines, caption = nil, lang = nil) 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.nil? + return ' ' # pass empty to \reviewincludegraphics + end + s + end + def handle_metric(str) if @book.config['image_scale2width'] && str =~ /\Ascale=([\d.]+)\Z/ return "width=#{$1}\\maxwidth" diff --git a/test/test_latexbuilder.rb b/test/test_latexbuilder.rb index d494c22c1..0aa66e083 100644 --- a/test/test_latexbuilder.rb +++ b/test/test_latexbuilder.rb @@ -14,7 +14,7 @@ def setup 'secnolevel' => 2, # for IDGXMLBuilder, EPUBBuilder 'toclevel' => 2, 'stylesheet' => nil, # for EPUBBuilder - 'image_scale2width' => false, + 'image_scale2width' => nil, 'texcommand' => 'uplatex', 'review_version' => '3' ) @@ -857,6 +857,17 @@ def @chapter.image(_id) \\reviewimagecaption{sample photo} \\label{image:chap1:sampleimg} \\end{reviewimage} +EOS + assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//image[sampleimg][sample photo]{\n//}\n") + expected = <<-EOS +\\begin{reviewimage}%%sampleimg +\\reviewincludegraphics[ ]{./images/chap1-sampleimg.png} +\\reviewimagecaption{sample photo} +\\label{image:chap1:sampleimg} +\\end{reviewimage} EOS assert_equal expected, actual end @@ -877,6 +888,10 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n") + assert_equal expected, actual end def test_image_with_metric_width @@ -896,6 +911,10 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n") + assert_equal expected, actual end def test_image_with_metric2 @@ -914,6 +933,10 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n") + assert_equal expected, actual end def test_image_with_metric2_width @@ -933,6 +956,10 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n") + assert_equal expected, actual end def test_indepimage @@ -948,6 +975,16 @@ def @chapter.image(_id) \\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png} \\reviewindepimagecaption{図: sample photo} \\end{reviewimage} +EOS + assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//indepimage[sampleimg][sample photo]\n") + expected = <<-EOS +\\begin{reviewimage}%%sampleimg +\\reviewincludegraphics[ ]{./images/chap1-sampleimg.png} +\\reviewindepimagecaption{図: sample photo} +\\end{reviewimage} EOS assert_equal expected, actual end @@ -984,6 +1021,10 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n") + assert_equal expected, actual end def test_indepimage_with_metric_width @@ -1002,6 +1043,10 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n") + assert_equal expected, actual end def test_indepimage_with_metric2 @@ -1019,6 +1064,10 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n)) + assert_equal expected, actual end def test_indepimage_without_caption_but_with_metric @@ -1036,6 +1085,10 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n") + assert_equal expected, actual end def test_table @@ -1194,6 +1247,44 @@ def @chapter.image(_id) \\end{table} EOS assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n") + + expected = <<-EOS +\\begin{table}[h]%%sampleimg +\\reviewimgtablecaption{test for imgtable} +\\label{table:chap1:sampleimg} +\\begin{reviewimage}%%sampleimg +\\reviewincludegraphics[ ]{./images/chap1-sampleimg.png} +\\end{reviewimage} +\\end{table} +EOS + assert_equal expected, actual + end + + def test_imgtable_with_metrics + def @chapter.image(_id) + item = Book::Index::Item.new('sampleimg', 1, 'sample img') + item.instance_eval { @path = './images/chap1-sampleimg.png' } + item + end + + actual = compile_block("//imgtable[sampleimg][test for imgtable][scale=1.2]{\n//}\n") + expected = <<-EOS +\\begin{table}[h]%%sampleimg +\\reviewimgtablecaption{test for imgtable} +\\label{table:chap1:sampleimg} +\\begin{reviewimage}%%sampleimg +\\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png} +\\end{reviewimage} +\\end{table} +EOS + assert_equal expected, actual + + @book.config['pdfmaker']['use_original_image_size'] = true + actual = compile_block("//imgtable[sampleimg][test for imgtable][scale=1.2]{\n//}\n") + assert_equal expected, actual end def test_table_row_separator From 1600986656a95a2e73521481755e7a76c5d065e0 Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Thu, 2 Jan 2020 15:22:10 +0900 Subject: [PATCH 8/9] treat empty string as nil --- lib/review/latexbuilder.rb | 2 +- test/test_latexbuilder.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/review/latexbuilder.rb b/lib/review/latexbuilder.rb index e82e29389..b6e0cb276 100644 --- a/lib/review/latexbuilder.rb +++ b/lib/review/latexbuilder.rb @@ -484,7 +484,7 @@ def image_header(id, caption) def parse_metric(type, metric) s = super(type, metric) - if @book.config['pdfmaker']['use_original_image_size'] && s.empty? && metric.nil? + if @book.config['pdfmaker']['use_original_image_size'] && s.empty? && !metric.present? return ' ' # pass empty to \reviewincludegraphics end s diff --git a/test/test_latexbuilder.rb b/test/test_latexbuilder.rb index 0aa66e083..24197e38b 100644 --- a/test/test_latexbuilder.rb +++ b/test/test_latexbuilder.rb @@ -870,6 +870,9 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + actual = compile_block("//image[sampleimg][sample photo][]{\n//}\n") + assert_equal expected, actual end def test_image_with_metric @@ -987,6 +990,9 @@ def @chapter.image(_id) \\end{reviewimage} EOS assert_equal expected, actual + + actual = compile_block("//indepimage[sampleimg][sample photo][]\n") + assert_equal expected, actual end def test_indepimage_without_caption @@ -1261,6 +1267,9 @@ def @chapter.image(_id) \\end{table} EOS assert_equal expected, actual + + actual = compile_block("//imgtable[sampleimg][test for imgtable][]{\n//}\n") + assert_equal expected, actual end def test_imgtable_with_metrics From 72fb83c1b444208b0d45d62ff422f7fb9bfc84ae Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Thu, 2 Jan 2020 15:48:14 +0900 Subject: [PATCH 9/9] move image_csale2width parameter to under pdfmaker section. Closes: #1462 --- lib/review/configure.rb | 2 +- lib/review/latexbuilder.rb | 2 +- lib/review/pdfmaker.rb | 8 +++++++- test/test_latexbuilder.rb | 10 +++++----- test/test_latexbuilder_v2.rb | 8 ++++---- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/review/configure.rb b/lib/review/configure.rb index 70efa4d42..4428bfff7 100644 --- a/lib/review/configure.rb +++ b/lib/review/configure.rb @@ -75,7 +75,6 @@ def self.values 'structuredxml' => nil, 'pt_to_mm_unit' => 0.3528, # DTP: 1pt = 0.3528mm, JIS: 1pt = 0.3514mm # for LaTeX - 'image_scale2width' => true, 'footnotetext' => nil, 'texcommand' => 'uplatex', 'texoptions' => '-interaction=nonstopmode -file-line-error -halt-on-error', @@ -85,6 +84,7 @@ def self.values 'dvioptions' => '-d 5 -z 9', # for PDFMaker 'pdfmaker' => { + 'image_scale2width' => true, 'makeindex' => nil, # Make index page 'makeindex_command' => 'mendex', # works only when makeindex is true 'makeindex_options' => '-f -r -I utf8', diff --git a/lib/review/latexbuilder.rb b/lib/review/latexbuilder.rb index b6e0cb276..bedd64172 100644 --- a/lib/review/latexbuilder.rb +++ b/lib/review/latexbuilder.rb @@ -491,7 +491,7 @@ def parse_metric(type, metric) 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 diff --git a/lib/review/pdfmaker.rb b/lib/review/pdfmaker.rb index 3716cf5c9..21a1f3cf7 100644 --- a/lib/review/pdfmaker.rb +++ b/lib/review/pdfmaker.rb @@ -1,4 +1,4 @@ -# Copyright (c) 2010-2019 Kenshi Muto and Masayoshi Takahashi +# Copyright (c) 2010-2020 Kenshi Muto and Masayoshi Takahashi # # This program is free software. # You can distribute or modify this program under the terms of @@ -152,6 +152,12 @@ def execute(*args) end end + # version 4.0 compatibility + if @config['image_scale2width'] + warn 'image_scale2width parameter is moved to under pdfmaker section' + @config['pdfmaker']['image_scale2width'] = @config['image_scale2width'] + end + begin generate_pdf rescue ApplicationError => e diff --git a/test/test_latexbuilder.rb b/test/test_latexbuilder.rb index 24197e38b..8625e12e8 100644 --- a/test/test_latexbuilder.rb +++ b/test/test_latexbuilder.rb @@ -14,10 +14,10 @@ def setup 'secnolevel' => 2, # for IDGXMLBuilder, EPUBBuilder 'toclevel' => 2, 'stylesheet' => nil, # for EPUBBuilder - 'image_scale2width' => nil, 'texcommand' => 'uplatex', - 'review_version' => '3' + 'review_version' => '4' ) + @config['pdfmaker']['image_scale2width'] = nil @book = Book::Base.new @book.config = @config @compiler = ReVIEW::Compiler.new(@builder) @@ -904,7 +904,7 @@ def @chapter.image(_id) item end - @config['image_scale2width'] = true + @config['pdfmaker']['image_scale2width'] = true actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n") expected = <<-EOS \\begin{reviewimage}%%sampleimg @@ -949,7 +949,7 @@ def @chapter.image(_id) item end - @config['image_scale2width'] = true + @config['pdfmaker']['image_scale2width'] = true actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n") expected = <<-EOS \\begin{reviewimage}%%sampleimg @@ -1040,7 +1040,7 @@ def @chapter.image(_id) item end - @config['image_scale2width'] = true + @config['pdfmaker']['image_scale2width'] = true actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n") expected = <<-EOS \\begin{reviewimage}%%sampleimg diff --git a/test/test_latexbuilder_v2.rb b/test/test_latexbuilder_v2.rb index bf9e2673c..f0126fd8e 100644 --- a/test/test_latexbuilder_v2.rb +++ b/test/test_latexbuilder_v2.rb @@ -14,10 +14,10 @@ def setup 'secnolevel' => 2, # for IDGXMLBuilder, EPUBBuilder 'toclevel' => 2, 'stylesheet' => nil, # for EPUBBuilder - 'image_scale2width' => false, 'texcommand' => 'uplatex', 'review_version' => '2.0' ) + @config['pdfmaker']['image_scale2width'] = nil @book = Book::Base.new @book.config = @config @compiler = ReVIEW::Compiler.new(@builder) @@ -762,7 +762,7 @@ def @chapter.image(_id) item end - @config['image_scale2width'] = true + @config['pdfmaker']['image_scale2width'] = true actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n") expected = <<-EOS \\begin{reviewimage}%%sampleimg @@ -799,7 +799,7 @@ def @chapter.image(_id) item end - @config['image_scale2width'] = true + @config['pdfmaker']['image_scale2width'] = true actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n") expected = <<-EOS \\begin{reviewimage}%%sampleimg @@ -869,7 +869,7 @@ def @chapter.image(_id) item end - @config['image_scale2width'] = true + @config['pdfmaker']['image_scale2width'] = true actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n") expected = <<-EOS \\begin{reviewimage}%%sampleimg