review 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +92 -73
- data/{doc/NEWS.ja.md → NEWS.ja.md} +60 -0
- data/{doc/NEWS.md → NEWS.md} +60 -0
- data/bin/review-compile +1 -1
- data/bin/review-epubmaker +2 -2
- data/bin/review-pdfmaker +2 -2
- data/debian/control +1 -1
- data/{ChangeLog → doc/ChangeLog-0.x_to_2.0} +0 -0
- data/doc/config.yml.sample +6 -6
- data/doc/format.ja.md +19 -1
- data/doc/format.md +28 -10
- data/doc/quickstart.ja.md +1 -1
- data/doc/quickstart.md +1 -1
- data/lib/epubmaker.rb +2 -1
- data/lib/epubmaker/content.rb +2 -1
- data/lib/epubmaker/epubcommon.rb +1 -0
- data/lib/epubmaker/epubv2.rb +2 -1
- data/lib/epubmaker/epubv3.rb +2 -1
- data/lib/epubmaker/producer.rb +2 -1
- data/lib/epubmaker/zip_exporter.rb +2 -2
- data/lib/review/book/base.rb +2 -2
- data/lib/review/book/index.rb +7 -3
- data/lib/review/builder.rb +15 -7
- data/lib/review/compiler.rb +4 -3
- data/lib/review/converter.rb +1 -1
- data/lib/review/epubmaker.rb +2 -2
- data/lib/review/ewbbuilder.rb +2 -1
- data/lib/review/htmlbuilder.rb +59 -9
- data/lib/review/idgxmlbuilder.rb +13 -5
- data/lib/review/latexbuilder.rb +44 -17
- data/lib/review/latexutils.rb +2 -2
- data/lib/review/makerhelper.rb +2 -2
- data/lib/review/markdownbuilder.rb +12 -8
- data/lib/review/pdfmaker.rb +1 -2
- data/lib/review/rstbuilder.rb +10 -4
- data/lib/review/sec_counter.rb +9 -3
- data/lib/review/topbuilder.rb +47 -5
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +1 -2
- data/review.gemspec +1 -1
- data/templates/latex/layout.tex.erb +5 -0
- data/test/assets/test_template.tex +5 -0
- data/test/test_book.rb +2 -1
- data/test/test_book_chapter.rb +1 -3
- data/test/test_epub3maker.rb +0 -2
- data/test/test_htmlbuilder.rb +72 -3
- data/test/test_idgxmlbuilder.rb +11 -2
- data/test/test_index.rb +0 -1
- data/test/test_latexbuilder.rb +96 -2
- data/test/test_pdfmaker.rb +0 -1
- data/test/test_rstbuilder.rb +5 -0
- data/test/test_topbuilder.rb +26 -1
- metadata +6 -7
data/lib/review/idgxmlbuilder.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
|
3
3
|
# Copyright (c) 2002-2007 Minero Aoki
|
4
|
-
# 2008-
|
4
|
+
# 2008-2017 Minero Aoki, Kenshi Muto
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
7
|
# You can distribute or modify this program under the terms of
|
@@ -563,10 +563,14 @@ module ReVIEW
|
|
563
563
|
end
|
564
564
|
|
565
565
|
def table_header(id, caption)
|
566
|
-
if
|
567
|
-
puts %Q[<caption>#{
|
566
|
+
if id.nil?
|
567
|
+
puts %Q[<caption>#{compile_inline(caption)}</caption>]
|
568
568
|
else
|
569
|
-
|
569
|
+
if get_chap.nil?
|
570
|
+
puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
|
571
|
+
else
|
572
|
+
puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
|
573
|
+
end
|
570
574
|
end
|
571
575
|
end
|
572
576
|
|
@@ -589,6 +593,10 @@ module ReVIEW
|
|
589
593
|
print "<?dtp tablerow last?>"
|
590
594
|
end
|
591
595
|
|
596
|
+
def emtable(lines, caption = nil)
|
597
|
+
table(lines, nil, caption)
|
598
|
+
end
|
599
|
+
|
592
600
|
def imgtable(lines, id, caption = nil, metric = nil)
|
593
601
|
if @chapter.image(id).bound?
|
594
602
|
metrics = parse_metric("idgxml", metric)
|
data/lib/review/latexbuilder.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
|
3
3
|
# Copyright (c) 2002-2007 Minero Aoki
|
4
4
|
# 2008-2009 Minero Aoki, Kenshi Muto
|
5
|
-
# 2010-
|
5
|
+
# 2010-2017 Minero Aoki, Kenshi Muto, TAKAHASHI Masayoshi
|
6
6
|
#
|
7
7
|
# This program is free software.
|
8
8
|
# You can distribute or modify this program under the terms of
|
@@ -32,6 +32,7 @@ module ReVIEW
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def builder_init_file
|
35
|
+
@chapter.book.image_types = %w(.ai .eps .pdf .tif .tiff .png .bmp .jpg .jpeg .gif)
|
35
36
|
@blank_needed = false
|
36
37
|
@latex_tsize = nil
|
37
38
|
@tsize = nil
|
@@ -339,7 +340,11 @@ module ReVIEW
|
|
339
340
|
puts macro(command + 'caption', "#{compile_inline(caption)}")
|
340
341
|
else
|
341
342
|
begin
|
342
|
-
|
343
|
+
if get_chap.nil?
|
344
|
+
puts macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}")
|
345
|
+
else
|
346
|
+
puts macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}")
|
347
|
+
end
|
343
348
|
rescue KeyError
|
344
349
|
error "no such list: #{id}"
|
345
350
|
end
|
@@ -395,7 +400,6 @@ module ReVIEW
|
|
395
400
|
end
|
396
401
|
end
|
397
402
|
|
398
|
-
|
399
403
|
def image_header(id, caption)
|
400
404
|
end
|
401
405
|
|
@@ -504,7 +508,7 @@ module ReVIEW
|
|
504
508
|
sepidx ||= idx
|
505
509
|
next
|
506
510
|
end
|
507
|
-
rows.push
|
511
|
+
rows.push(line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') })
|
508
512
|
end
|
509
513
|
rows = adjust_n_cols(rows)
|
510
514
|
|
@@ -517,27 +521,35 @@ module ReVIEW
|
|
517
521
|
table_begin rows.first.size
|
518
522
|
if sepidx
|
519
523
|
sepidx.times do
|
520
|
-
tr
|
524
|
+
tr(rows.shift.map {|s| th(s) })
|
521
525
|
end
|
522
526
|
rows.each do |cols|
|
523
|
-
tr
|
527
|
+
tr(cols.map {|s| td(s) })
|
524
528
|
end
|
525
529
|
else
|
526
530
|
rows.each do |cols|
|
527
531
|
h, *cs = *cols
|
528
|
-
tr
|
532
|
+
tr([th(h)] + cs.map {|s| td(s) })
|
529
533
|
end
|
530
534
|
end
|
531
535
|
table_end
|
532
536
|
end
|
533
537
|
|
534
538
|
def table_header(id, caption)
|
535
|
-
if
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
+
if id.nil?
|
540
|
+
if caption.present?
|
541
|
+
@table_caption = true
|
542
|
+
puts '\begin{table}[h]'
|
543
|
+
puts macro('reviewtablecaption*', compile_inline(caption))
|
544
|
+
end
|
545
|
+
else
|
546
|
+
if caption.present?
|
547
|
+
@table_caption = true
|
548
|
+
puts '\begin{table}[h]'
|
549
|
+
puts macro('reviewtablecaption', compile_inline(caption))
|
550
|
+
end
|
551
|
+
puts macro('label', table_label(id))
|
539
552
|
end
|
540
|
-
puts macro('label', table_label(id))
|
541
553
|
end
|
542
554
|
|
543
555
|
def table_begin(ncols)
|
@@ -594,6 +606,10 @@ module ReVIEW
|
|
594
606
|
blank
|
595
607
|
end
|
596
608
|
|
609
|
+
def emtable(lines, caption = nil)
|
610
|
+
table(lines, nil, caption)
|
611
|
+
end
|
612
|
+
|
597
613
|
def imgtable(lines, id, caption = nil, metric = nil)
|
598
614
|
if !@chapter.image(id).bound?
|
599
615
|
warn "image not bound: #{id}"
|
@@ -735,21 +751,32 @@ module ReVIEW
|
|
735
751
|
nofunc_text("[UnknownChapter:#{id}]")
|
736
752
|
end
|
737
753
|
|
738
|
-
|
739
754
|
# FIXME: use TeX native label/ref.
|
740
755
|
def inline_list(id)
|
741
756
|
chapter, id = extract_chapter_id(id)
|
742
|
-
|
757
|
+
if get_chap(chapter).nil?
|
758
|
+
macro('reviewlistref', I18n.t("format_number_without_header", [chapter.list(id).number]))
|
759
|
+
else
|
760
|
+
macro('reviewlistref', I18n.t("format_number", [get_chap(chapter), chapter.list(id).number]))
|
761
|
+
end
|
743
762
|
end
|
744
763
|
|
745
764
|
def inline_table(id)
|
746
765
|
chapter, id = extract_chapter_id(id)
|
747
|
-
|
766
|
+
if get_chap(chapter).nil?
|
767
|
+
macro('reviewtableref', I18n.t("format_number_without_header", [chapter.table(id).number]), table_label(id, chapter))
|
768
|
+
else
|
769
|
+
macro('reviewtableref', I18n.t("format_number", [get_chap(chapter), chapter.table(id).number]), table_label(id, chapter))
|
770
|
+
end
|
748
771
|
end
|
749
772
|
|
750
773
|
def inline_img(id)
|
751
774
|
chapter, id = extract_chapter_id(id)
|
752
|
-
|
775
|
+
if get_chap(chapter).nil?
|
776
|
+
macro('reviewimageref', I18n.t("format_number_without_header", [chapter.image(id).number]), image_label(id, chapter))
|
777
|
+
else
|
778
|
+
macro('reviewimageref', I18n.t("format_number", [get_chap(chapter), chapter.image(id).number]), image_label(id, chapter))
|
779
|
+
end
|
753
780
|
end
|
754
781
|
|
755
782
|
def footnote(id, content)
|
data/lib/review/latexutils.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
|
3
3
|
# Copyright (c) 2002-2006 Minero Aoki
|
4
|
-
# Copyright (c) 2006-
|
4
|
+
# Copyright (c) 2006-2017 Minero Aoki, Kenshi Muto and Masayoshi Takahashi
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
7
|
# You can distribute or modify this program under the terms of
|
data/lib/review/makerhelper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
|
2
3
|
# This program is free software.
|
3
4
|
# You can distribute or modify this program under the terms of
|
4
5
|
# the GNU LGPL, Lesser General Public License version 2.1.
|
@@ -162,7 +163,6 @@ module ReVIEW
|
|
162
163
|
"`#{str}`"
|
163
164
|
end
|
164
165
|
|
165
|
-
|
166
166
|
def image_image(id, caption, metric)
|
167
167
|
blank
|
168
168
|
puts "![#{compile_inline(caption)}](#{@chapter.image(id).path.sub(/\A\.\//, "")})"
|
@@ -212,7 +212,7 @@ module ReVIEW
|
|
212
212
|
sepidx ||= idx
|
213
213
|
next
|
214
214
|
end
|
215
|
-
rows.push
|
215
|
+
rows.push(line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') })
|
216
216
|
end
|
217
217
|
rows = adjust_n_cols(rows)
|
218
218
|
|
@@ -225,26 +225,30 @@ module ReVIEW
|
|
225
225
|
return if rows.empty?
|
226
226
|
if sepidx
|
227
227
|
sepidx.times do
|
228
|
-
tr
|
228
|
+
tr(rows.shift.map {|s| th(s) })
|
229
229
|
end
|
230
230
|
table_border rows.first.size
|
231
231
|
rows.each do |cols|
|
232
|
-
tr
|
232
|
+
tr(cols.map {|s| td(s) })
|
233
233
|
end
|
234
234
|
else
|
235
235
|
rows.each do |cols|
|
236
236
|
h, *cs = *cols
|
237
|
-
tr
|
237
|
+
tr([th(h)] + cs.map {|s| td(s) })
|
238
238
|
end
|
239
239
|
end
|
240
240
|
table_end
|
241
241
|
end
|
242
242
|
|
243
243
|
def table_header(id, caption)
|
244
|
-
if
|
245
|
-
puts
|
244
|
+
if id.nil?
|
245
|
+
puts compile_inline(caption)
|
246
246
|
else
|
247
|
-
|
247
|
+
if get_chap.nil?
|
248
|
+
puts %Q[#{I18n.t("table")}#{I18n.t("format_number_header_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
|
249
|
+
else
|
250
|
+
puts %Q[#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
|
251
|
+
end
|
248
252
|
end
|
249
253
|
blank
|
250
254
|
end
|
data/lib/review/pdfmaker.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
|
3
3
|
# Copyright (c) 2010-2017 Kenshi Muto and Masayoshi Takahashi
|
4
4
|
#
|
5
5
|
# This program is free software.
|
@@ -241,7 +241,6 @@ module ReVIEW
|
|
241
241
|
build_pdf
|
242
242
|
|
243
243
|
FileUtils.cp(File.join(@path, "book.pdf"), pdf_filepath)
|
244
|
-
|
245
244
|
ensure
|
246
245
|
unless @config["debug"]
|
247
246
|
remove_entry_secure @path
|
data/lib/review/rstbuilder.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
|
3
3
|
# Copyright (c) 2002-2006 Minero Aoki
|
4
|
-
# 2008-
|
4
|
+
# 2008-2017 Minero Aoki, Kenshi Muto
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
7
|
# You can distribute or modify this program under the terms of
|
@@ -317,8 +317,10 @@ module ReVIEW
|
|
317
317
|
end
|
318
318
|
|
319
319
|
def table_header(id, caption)
|
320
|
-
|
321
|
-
|
320
|
+
unless id.nil?
|
321
|
+
blank
|
322
|
+
puts ".. _#{id}:"
|
323
|
+
end
|
322
324
|
blank
|
323
325
|
puts ".. list-table:: #{compile_inline(caption)}"
|
324
326
|
puts " :header-rows: 1"
|
@@ -352,6 +354,10 @@ module ReVIEW
|
|
352
354
|
blank
|
353
355
|
end
|
354
356
|
|
357
|
+
def emtable(lines, caption = nil)
|
358
|
+
table(lines, nil, caption)
|
359
|
+
end
|
360
|
+
|
355
361
|
def comment(lines, comment = nil)
|
356
362
|
puts lines.map{|line| " .. #{line}"}.join("")
|
357
363
|
end
|
data/lib/review/sec_counter.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
# Copyright (c) 2008-
|
2
|
+
|
3
|
+
# Copyright (c) 2008-2017 Minero Aoki, Kenshi Muto, Masayoshi Takahashi,
|
4
4
|
# KADO Masanori
|
5
5
|
#
|
6
6
|
# This program is free software.
|
@@ -55,7 +55,13 @@ module ReVIEW
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
elsif secnolevel >= level
|
58
|
-
prefix =
|
58
|
+
prefix = ''
|
59
|
+
if @chapter.is_a? ReVIEW::Book::Part
|
60
|
+
prefix = I18n.t('part_short', @chapter.number)
|
61
|
+
else
|
62
|
+
prefix = @chapter.format_number(false)
|
63
|
+
end
|
64
|
+
|
59
65
|
0.upto(level - 2) do |i|
|
60
66
|
prefix << ".#{@counter[i]}"
|
61
67
|
end
|
data/lib/review/topbuilder.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
|
3
3
|
# Copyright (c) 2002-2006 Minero Aoki
|
4
4
|
# 2008-2017 Minero Aoki, Kenshi Muto
|
5
5
|
#
|
@@ -315,13 +315,55 @@ module ReVIEW
|
|
315
315
|
blank
|
316
316
|
end
|
317
317
|
|
318
|
-
def
|
318
|
+
def table(lines, id = nil, caption = nil)
|
319
319
|
blank
|
320
320
|
puts "◆→開始:#{@titles["table"]}←◆"
|
321
|
-
|
322
|
-
|
321
|
+
|
322
|
+
rows = []
|
323
|
+
sepidx = nil
|
324
|
+
lines.each_with_index do |line, idx|
|
325
|
+
if /\A[\=\-]{12}/ =~ line
|
326
|
+
# just ignore
|
327
|
+
#error "too many table separator" if sepidx
|
328
|
+
sepidx ||= idx
|
329
|
+
next
|
330
|
+
end
|
331
|
+
rows.push(line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') })
|
332
|
+
end
|
333
|
+
rows = adjust_n_cols(rows)
|
334
|
+
|
335
|
+
begin
|
336
|
+
table_header id, caption unless caption.nil?
|
337
|
+
rescue KeyError
|
338
|
+
error "no such table: #{id}"
|
339
|
+
end
|
340
|
+
return if rows.empty?
|
341
|
+
table_begin rows.first.size
|
342
|
+
if sepidx
|
343
|
+
sepidx.times do
|
344
|
+
tr(rows.shift.map {|s| th(s) })
|
345
|
+
end
|
346
|
+
rows.each do |cols|
|
347
|
+
tr(cols.map {|s| td(s) })
|
348
|
+
end
|
349
|
+
else
|
350
|
+
rows.each do |cols|
|
351
|
+
h, *cs = *cols
|
352
|
+
tr([th(h)] + cs.map {|s| td(s) })
|
353
|
+
end
|
354
|
+
end
|
355
|
+
table_end
|
356
|
+
end
|
357
|
+
|
358
|
+
def table_header(id, caption)
|
359
|
+
if id.nil?
|
360
|
+
puts compile_inline(caption)
|
323
361
|
else
|
324
|
-
|
362
|
+
if get_chap.nil?
|
363
|
+
puts "#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
|
364
|
+
else
|
365
|
+
puts "#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
|
366
|
+
end
|
325
367
|
end
|
326
368
|
blank
|
327
369
|
end
|
data/lib/review/version.rb
CHANGED
data/lib/review/webmaker.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
|
3
3
|
# This program is free software.
|
4
4
|
# You can distribute or modify this program under the terms of
|
5
5
|
# the GNU LGPL, Lesser General Public License version 2.1.
|
@@ -65,7 +65,6 @@ module ReVIEW
|
|
65
65
|
FileUtils.rm_rf(path)
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
68
|
def execute(*args)
|
70
69
|
@config = ReVIEW::Configure.values
|
71
70
|
@config.maker = "webmaker"
|
data/review.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
|
2
3
|
$:.push File.expand_path("../lib", __FILE__)
|
3
4
|
require "review/version"
|
4
5
|
|
@@ -19,7 +20,6 @@ Gem::Specification.new do |gem|
|
|
19
20
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
21
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
22
|
gem.extra_rdoc_files = [
|
22
|
-
"ChangeLog",
|
23
23
|
]
|
24
24
|
gem.require_paths = ["lib"]
|
25
25
|
|
@@ -8,6 +8,8 @@
|
|
8
8
|
<%- else -%>
|
9
9
|
\usepackage[deluxe]{otf}
|
10
10
|
<%- end -%>
|
11
|
+
\usepackage{caption}
|
12
|
+
\usepackage{suffix}
|
11
13
|
\usepackage[T1]{fontenc}\usepackage{textcomp}%T1/TS1
|
12
14
|
% \usepackage{lmodern}
|
13
15
|
\usepackage[dvipdfmx]{graphicx}
|
@@ -136,6 +138,9 @@
|
|
136
138
|
\newcommand{\reviewtablecaption}[1]{%
|
137
139
|
\caption{#1}}
|
138
140
|
|
141
|
+
\WithSuffix\newcommand\reviewtablecaption*[1]{%
|
142
|
+
\caption*{#1}}
|
143
|
+
|
139
144
|
\newcommand{\reviewimgtablecaption}[1]{%
|
140
145
|
\caption{#1}\vspace{-3mm}}
|
141
146
|
|