review 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.rubocop.yml +293 -6
- data/.rubocop_todo.yml +3 -608
- data/.travis.yml +6 -13
- data/README.md +5 -3
- data/Rakefile +6 -6
- data/bin/review-catalog-converter +2 -2
- data/bin/review-check +1 -1
- data/bin/review-compile +1 -2
- data/bin/review-init +6 -3
- data/bin/review-validate +3 -3
- data/bin/review-vol +2 -1
- data/doc/NEWS.ja.md +138 -25
- data/doc/NEWS.md +137 -25
- data/doc/config.yml.sample +2 -2
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +86 -5
- data/doc/format.md +67 -2
- data/doc/makeindex.ja.md +95 -0
- data/doc/makeindex.md +97 -0
- data/doc/sample.css +214 -0
- data/lib/epubmaker.rb +6 -6
- data/lib/epubmaker/epubcommon.rb +19 -47
- data/lib/epubmaker/epubv2.rb +3 -1
- data/lib/epubmaker/epubv3.rb +4 -26
- data/lib/epubmaker/producer.rb +46 -46
- data/lib/epubmaker/zip_exporter.rb +86 -0
- data/lib/review/book/base.rb +13 -15
- data/lib/review/book/chapter.rb +2 -1
- data/lib/review/book/compilable.rb +9 -9
- data/lib/review/book/image_finder.rb +13 -13
- data/lib/review/book/index.rb +2 -2
- data/lib/review/book/volume.rb +2 -2
- data/lib/review/builder.rb +57 -1
- data/lib/review/catalog.rb +2 -2
- data/lib/review/compiler.rb +15 -7
- data/lib/review/configure.rb +11 -0
- data/lib/review/epubmaker.rb +403 -401
- data/lib/review/ewbbuilder.rb +16 -16
- data/lib/review/htmlbuilder.rb +42 -58
- data/lib/review/htmltoc.rb +1 -1
- data/lib/review/htmlutils.rb +50 -4
- data/lib/review/i18n.rb +2 -2
- data/lib/review/idgxmlbuilder.rb +30 -47
- data/lib/review/latexbuilder.rb +86 -41
- data/lib/review/latexutils.rb +19 -19
- data/lib/review/markdownbuilder.rb +16 -4
- data/lib/review/md2inaobuilder.rb +0 -9
- data/lib/review/pdfmaker.rb +91 -48
- data/lib/review/preprocessor.rb +1 -1
- data/lib/review/rstbuilder.rb +763 -0
- data/lib/review/sec_counter.rb +7 -9
- data/lib/review/tocparser.rb +3 -3
- data/lib/review/tocprinter.rb +5 -5
- data/lib/review/topbuilder.rb +48 -56
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +6 -7
- data/review.gemspec +1 -0
- data/templates/latex/layout.tex.erb +27 -2
- data/test/assets/test_template.tex +10 -1
- data/test/book_test_helper.rb +1 -2
- data/test/run_test.rb +10 -0
- data/test/sample-book/src/style.css +215 -0
- data/test/sample-book/src/vendor/jumoline/lppl.txt +416 -0
- data/test/test_book.rb +0 -1
- data/test/test_catalog.rb +1 -0
- data/test/test_converter.rb +1 -1
- data/test/test_epub3maker.rb +44 -51
- data/test/test_epubmaker.rb +82 -38
- data/test/test_epubmaker_cmd.rb +1 -1
- data/test/test_extentions_hash.rb +8 -1
- data/test/test_htmlbuilder.rb +411 -18
- data/test/test_i18n.rb +17 -0
- data/test/test_idgxmlbuilder.rb +88 -3
- data/test/test_image_finder.rb +18 -0
- data/test/test_index.rb +2 -0
- data/test/test_latexbuilder.rb +96 -8
- data/test/test_makerhelper.rb +2 -2
- data/test/test_markdownbuilder.rb +22 -1
- data/test/test_md2inaobuilder.rb +0 -5
- data/test/test_pdfmaker.rb +54 -36
- data/test/test_pdfmaker_cmd.rb +1 -1
- data/test/test_rstbuilder.rb +356 -0
- data/test/test_textutils.rb +14 -4
- data/test/test_topbuilder.rb +23 -4
- data/test/test_zip_exporter.rb +113 -0
- metadata +28 -2
data/lib/review/latexbuilder.rb
CHANGED
@@ -37,11 +37,39 @@ module ReVIEW
|
|
37
37
|
@tsize = nil
|
38
38
|
@table_caption = nil
|
39
39
|
@ol_num = nil
|
40
|
+
@first_line_num = nil
|
40
41
|
@sec_counter = SecCounter.new(5, @chapter)
|
42
|
+
setup_index
|
41
43
|
initialize_metachars(@book.config["texcommand"])
|
42
44
|
end
|
43
45
|
private :builder_init_file
|
44
46
|
|
47
|
+
def setup_index
|
48
|
+
@index_db = {}
|
49
|
+
@index_mecab = nil
|
50
|
+
if @book.config["pdfmaker"]["makeindex"]
|
51
|
+
@index_db = load_idxdb(@book.config["pdfmaker"]["makeindex_dic"]) if @book.config["pdfmaker"]["makeindex_dic"]
|
52
|
+
if @book.config["pdfmaker"]["makeindex_mecab"]
|
53
|
+
begin
|
54
|
+
require 'MeCab'
|
55
|
+
require 'nkf'
|
56
|
+
@index_mecab = MeCab::Tagger.new(@book.config["pdfmaker"]["makeindex_mecab_opts"])
|
57
|
+
rescue LoadError
|
58
|
+
error "not found MeCab"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_idxdb(file)
|
65
|
+
table = {}
|
66
|
+
File.foreach(file) do |line|
|
67
|
+
key, value = *line.strip.split(/\t+/, 2)
|
68
|
+
table[key] = value
|
69
|
+
end
|
70
|
+
table
|
71
|
+
end
|
72
|
+
|
45
73
|
def blank
|
46
74
|
@blank_needed = true
|
47
75
|
end
|
@@ -261,11 +289,12 @@ module ReVIEW
|
|
261
289
|
|
262
290
|
def emlistnum(lines, caption = nil, lang = nil)
|
263
291
|
blank
|
292
|
+
first_line_num = get_line_num
|
264
293
|
if highlight_listings?
|
265
|
-
common_code_block_lst(nil, lines, 'reviewemlistnumlst', 'title', caption, lang)
|
294
|
+
common_code_block_lst(nil, lines, 'reviewemlistnumlst', 'title', caption, lang, first_line_num: first_line_num)
|
266
295
|
else
|
267
296
|
common_code_block(nil, lines, 'reviewemlist', caption, lang) do |line, idx|
|
268
|
-
detab((idx+
|
297
|
+
detab((idx+first_line_num).to_s.rjust(2)+": " + line) + "\n"
|
269
298
|
end
|
270
299
|
end
|
271
300
|
end
|
@@ -283,11 +312,12 @@ module ReVIEW
|
|
283
312
|
|
284
313
|
## override Builder#listnum
|
285
314
|
def listnum(lines, id, caption, lang = nil)
|
315
|
+
first_line_num = get_line_num
|
286
316
|
if highlight_listings?
|
287
|
-
common_code_block_lst(id, lines, 'reviewlistnumlst', 'caption', caption, lang)
|
317
|
+
common_code_block_lst(id, lines, 'reviewlistnumlst', 'caption', caption, lang, first_line_num: first_line_num)
|
288
318
|
else
|
289
319
|
common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx|
|
290
|
-
detab((idx+
|
320
|
+
detab((idx+first_line_num).to_s.rjust(2)+": " + line) + "\n"
|
291
321
|
end
|
292
322
|
end
|
293
323
|
end
|
@@ -305,7 +335,7 @@ module ReVIEW
|
|
305
335
|
|
306
336
|
def common_code_block(id, lines, command, caption, lang)
|
307
337
|
if caption
|
308
|
-
if command =~ /emlist/ || command =~ /cmd/
|
338
|
+
if command =~ /emlist/ || command =~ /cmd/ || command =~ /source/
|
309
339
|
puts macro(command + 'caption', "#{compile_inline(caption)}")
|
310
340
|
else
|
311
341
|
begin
|
@@ -319,17 +349,28 @@ module ReVIEW
|
|
319
349
|
lines.each_with_index do |line, idx|
|
320
350
|
body.concat(yield(line, idx))
|
321
351
|
end
|
322
|
-
puts macro('begin'
|
352
|
+
puts macro('begin',command)
|
353
|
+
print body
|
354
|
+
puts macro('end',command)
|
355
|
+
blank
|
356
|
+
end
|
357
|
+
|
358
|
+
def common_code_block_lst(id, lines, command, title, caption, lang, first_line_num: 1)
|
359
|
+
if title == "title" && caption.blank?
|
360
|
+
print "\\vspace{-1.5em}"
|
361
|
+
end
|
362
|
+
body = lines.inject(''){|i, j| i + detab(unescape_latex(j)) + "\n"}
|
363
|
+
args = make_code_block_args(title, caption, lang, first_line_num: first_line_num)
|
364
|
+
puts "\\begin{"+command+"}[" + args + "]"
|
323
365
|
print body
|
324
|
-
puts
|
366
|
+
puts "\\end{"+ command + "}"
|
325
367
|
blank
|
326
368
|
end
|
327
369
|
|
328
|
-
def
|
370
|
+
def make_code_block_args(title, caption, lang, first_line_num: 1)
|
329
371
|
caption_str = compile_inline((caption || ""))
|
330
372
|
if title == "title" && caption_str == ""
|
331
373
|
caption_str = "\\relax" ## dummy charactor to remove lstname
|
332
|
-
print "\\vspace{-1.5em}"
|
333
374
|
end
|
334
375
|
if @book.config["highlight"] && @book.config["highlight"]["lang"]
|
335
376
|
lexer = @book.config["highlight"]["lang"] # default setting
|
@@ -337,24 +378,20 @@ module ReVIEW
|
|
337
378
|
lexer = ""
|
338
379
|
end
|
339
380
|
lexer = lang if lang.present?
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
381
|
+
args = title + "={" + caption_str + "},language={" + lexer + "}"
|
382
|
+
if first_line_num != 1
|
383
|
+
args += ",firstnumber=#{first_line_num}"
|
384
|
+
end
|
385
|
+
args
|
345
386
|
end
|
346
387
|
|
347
388
|
def source(lines, caption, lang = nil)
|
348
389
|
if highlight_listings?
|
349
|
-
common_code_block_lst(nil, lines, '
|
390
|
+
common_code_block_lst(nil, lines, 'reviewsourcelst', 'title', caption, lang)
|
350
391
|
else
|
351
|
-
|
352
|
-
|
353
|
-
lines.each do |line|
|
354
|
-
puts detab(line)
|
392
|
+
common_code_block(nil, lines, 'reviewsource', caption, lang) do |line, idx|
|
393
|
+
detab(line) + "\n"
|
355
394
|
end
|
356
|
-
puts '\end{reviewlist}'
|
357
|
-
puts ""
|
358
395
|
end
|
359
396
|
end
|
360
397
|
|
@@ -507,8 +544,12 @@ module ReVIEW
|
|
507
544
|
if @latex_tsize
|
508
545
|
puts macro('begin', 'reviewtable', @latex_tsize)
|
509
546
|
elsif @tsize
|
510
|
-
|
511
|
-
|
547
|
+
if @tsize =~ /\A[\d., ]+\Z/
|
548
|
+
cellwidth = @tsize.split(/\s*,\s*/)
|
549
|
+
puts macro('begin', 'reviewtable', '|'+cellwidth.collect{|i| "p{#{i}mm}"}.join('|')+'|')
|
550
|
+
else
|
551
|
+
puts macro('begin', 'reviewtable', @tsize)
|
552
|
+
end
|
512
553
|
else
|
513
554
|
puts macro('begin', 'reviewtable', (['|'] * (ncols + 1)).join('l'))
|
514
555
|
end
|
@@ -634,7 +675,7 @@ module ReVIEW
|
|
634
675
|
lines ||= []
|
635
676
|
lines.unshift comment unless comment.blank?
|
636
677
|
if @book.config["draft"]
|
637
|
-
str = lines.join(
|
678
|
+
str = lines.join('\par ')
|
638
679
|
puts macro('pdfcomment', escape(str))
|
639
680
|
end
|
640
681
|
end
|
@@ -821,7 +862,9 @@ module ReVIEW
|
|
821
862
|
end
|
822
863
|
|
823
864
|
def inline_column_chap(chapter, id)
|
824
|
-
macro('reviewcolumnref',
|
865
|
+
macro('reviewcolumnref',
|
866
|
+
I18n.t("chapter_quote", compile_inline(chapter.column(id).caption)),
|
867
|
+
column_label(id))
|
825
868
|
end
|
826
869
|
|
827
870
|
def inline_raw(str)
|
@@ -884,21 +927,27 @@ module ReVIEW
|
|
884
927
|
end
|
885
928
|
|
886
929
|
def index(str)
|
887
|
-
str.
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
end
|
893
|
-
unless /[^ -~]/ =~ str
|
894
|
-
if /\^/ =~ str
|
895
|
-
macro('index', escape_index(str.gsub(/\^/, '')) + '@' + escape_index(text(str)) + decl)
|
930
|
+
sa = str.split('<<>>')
|
931
|
+
|
932
|
+
sa.map! do |item|
|
933
|
+
if @index_db[item]
|
934
|
+
item = escape_index(escape_latex(@index_db[item])) + "@" + escape_index(escape_latex(item))
|
896
935
|
else
|
897
|
-
|
936
|
+
if item =~ /\A[[:ascii:]]+\Z/ || @index_mecab.nil?
|
937
|
+
esc_item = escape_index(escape_latex(item))
|
938
|
+
if esc_item != item
|
939
|
+
"#{escape_index(item)}@#{esc_item}"
|
940
|
+
else
|
941
|
+
esc_item
|
942
|
+
end
|
943
|
+
else
|
944
|
+
yomi = NKF.nkf("-w --hiragana", @index_mecab.parse(item).force_encoding("UTF-8").chomp)
|
945
|
+
escape_index(escape_latex(yomi)) + "@" + escape_index(escape_latex(item))
|
946
|
+
end
|
898
947
|
end
|
899
|
-
else
|
900
|
-
'\index{' + escape_index(@index_db[str]) + '@' + escape_index(text(str)) + '}'
|
901
948
|
end
|
949
|
+
|
950
|
+
"\\index{#{sa.join('!')}}"
|
902
951
|
end
|
903
952
|
|
904
953
|
def compile_kw(word, alt)
|
@@ -921,10 +970,6 @@ module ReVIEW
|
|
921
970
|
end
|
922
971
|
end
|
923
972
|
|
924
|
-
def tsize(str)
|
925
|
-
@tsize = str
|
926
|
-
end
|
927
|
-
|
928
973
|
def latextsize(str)
|
929
974
|
@latex_tsize = str
|
930
975
|
end
|
data/lib/review/latexutils.rb
CHANGED
@@ -35,30 +35,30 @@ module ReVIEW
|
|
35
35
|
|
36
36
|
if File.basename(texcommand, ".*") == "platex"
|
37
37
|
@metachars.merge!({
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
38
|
+
'⓪' => '\UTF{24EA}',
|
39
|
+
'①' => '\UTF{2460}',
|
40
|
+
'②' => '\UTF{2461}',
|
41
|
+
'③' => '\UTF{2462}',
|
42
|
+
'④' => '\UTF{2463}',
|
43
|
+
'⑤' => '\UTF{2464}',
|
44
|
+
'⑥' => '\UTF{2465}',
|
45
|
+
'⑦' => '\UTF{2466}',
|
46
|
+
'⑧' => '\UTF{2467}',
|
47
|
+
'⑨' => '\UTF{2468}',
|
48
|
+
'⑩' => '\UTF{2469}',
|
49
|
+
'⑪' => '\UTF{246A}',
|
50
|
+
'⑫' => '\UTF{246B}',
|
51
|
+
'⑬' => '\UTF{246C}',
|
52
|
+
'⑭' => '\UTF{246D}',
|
53
|
+
'⑮' => '\UTF{246E}',
|
54
|
+
'⑯' => '\UTF{246F}'
|
55
|
+
})
|
56
56
|
|
57
57
|
kanalist = %w{。 「 」 、 ・ ヲ ァ ィ ゥ ェ ォ ャ ュ ョ ッ ー ア イ ウ エ
|
58
58
|
オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ
|
59
59
|
ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ン ゙ ゚}
|
60
60
|
kanalist.each do |char|
|
61
|
-
char_jisx0208 = NKF
|
61
|
+
char_jisx0208 = NKF.nkf('-WwX',char)
|
62
62
|
@metachars[char] = "\\aj半角{#{char_jisx0208}}"
|
63
63
|
end
|
64
64
|
end
|
@@ -74,10 +74,6 @@ module ReVIEW
|
|
74
74
|
@ul_indent += 1
|
75
75
|
end
|
76
76
|
|
77
|
-
def ul_item(lines)
|
78
|
-
puts " " * (@ul_indent - 1) + "* " + "#{lines.join}"
|
79
|
-
end
|
80
|
-
|
81
77
|
def ul_item_begin(lines)
|
82
78
|
puts " " * (@ul_indent - 1) + "* " + "#{lines.join}"
|
83
79
|
end
|
@@ -301,6 +297,22 @@ module ReVIEW
|
|
301
297
|
end
|
302
298
|
end
|
303
299
|
|
300
|
+
def comment(lines, comment = nil)
|
301
|
+
if @book.config["draft"]
|
302
|
+
lines ||= []
|
303
|
+
lines.unshift comment unless comment.blank?
|
304
|
+
str = lines.join("<br />")
|
305
|
+
puts %Q(<div class="red">#{escape_html(str)}</div>)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
def inline_comment(str)
|
310
|
+
if @book.config["draft"]
|
311
|
+
%Q(<span class="red">#{escape_html(str)}</span>)
|
312
|
+
else
|
313
|
+
''
|
314
|
+
end
|
315
|
+
end
|
304
316
|
end
|
305
317
|
|
306
318
|
end # module ReVIEW
|
@@ -44,15 +44,6 @@ module ReVIEW
|
|
44
44
|
puts '</dl>'
|
45
45
|
end
|
46
46
|
|
47
|
-
def comment(lines, comment = nil)
|
48
|
-
lines ||= []
|
49
|
-
lines.unshift comment unless comment.blank?
|
50
|
-
str = lines.join("\n")
|
51
|
-
puts '<span class="red">'
|
52
|
-
puts str
|
53
|
-
puts '</span>'
|
54
|
-
end
|
55
|
-
|
56
47
|
def compile_ruby(base, ruby)
|
57
48
|
if base.length == 1
|
58
49
|
%Q[<span class='monoruby'>#{escape_html(base)}(#{escape_html(ruby)})</span>]
|
data/lib/review/pdfmaker.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
# Copyright (c) 2010-
|
3
|
+
# Copyright (c) 2010-2017 Kenshi Muto and Masayoshi Takahashi
|
4
4
|
#
|
5
5
|
# This program is free software.
|
6
6
|
# You can distribute or modify this program under the terms of
|
@@ -87,7 +87,7 @@ module ReVIEW
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def parse_opts(args)
|
90
|
-
cmd_config =
|
90
|
+
cmd_config = {}
|
91
91
|
opts = OptionParser.new
|
92
92
|
|
93
93
|
opts.banner = "Usage: review-pdfmaker configfile"
|
@@ -132,6 +132,87 @@ module ReVIEW
|
|
132
132
|
generate_pdf(yamlfile)
|
133
133
|
end
|
134
134
|
|
135
|
+
def make_input_files(book, yamlfile)
|
136
|
+
input_files = Hash.new{|h, key| h[key] = ""}
|
137
|
+
book.parts.each do |part|
|
138
|
+
if part.name.present?
|
139
|
+
if part.file?
|
140
|
+
output_chaps(part.name, yamlfile)
|
141
|
+
input_files["CHAPS"] << %Q|\\input{#{part.name}.tex}\n|
|
142
|
+
else
|
143
|
+
input_files["CHAPS"] << %Q|\\part{#{part.name}}\n|
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
part.chapters.each do |chap|
|
148
|
+
filename = File.basename(chap.path, ".*")
|
149
|
+
output_chaps(filename, yamlfile)
|
150
|
+
input_files["PREDEF"] << "\\input{#{filename}.tex}\n" if chap.on_PREDEF?
|
151
|
+
input_files["CHAPS"] << "\\input{#{filename}.tex}\n" if chap.on_CHAPS?
|
152
|
+
input_files["APPENDIX"] << "\\input{#{filename}.tex}\n" if chap.on_APPENDIX?
|
153
|
+
input_files["POSTDEF"] << "\\input{#{filename}.tex}\n" if chap.on_POSTDEF?
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
input_files
|
158
|
+
end
|
159
|
+
|
160
|
+
def build_pdf
|
161
|
+
template = get_template
|
162
|
+
Dir.chdir(@path) do
|
163
|
+
File.open("./book.tex", "wb"){|f| f.write(template)}
|
164
|
+
|
165
|
+
call_hook("hook_beforetexcompile")
|
166
|
+
|
167
|
+
## do compile
|
168
|
+
if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0
|
169
|
+
warn "command configuration is prohibited in safe mode. ignored."
|
170
|
+
texcommand = ReVIEW::Configure.values["texcommand"]
|
171
|
+
dvicommand = ReVIEW::Configure.values["dvicommand"]
|
172
|
+
dvioptions = ReVIEW::Configure.values["dvioptions"]
|
173
|
+
texoptions = ReVIEW::Configure.values["texoptions"]
|
174
|
+
makeindex_command = ReVIEW::Configure.values["pdfmaker"]["makeindex_command"]
|
175
|
+
makeindex_options = ReVIEW::Configure.values["pdfmaker"]["makeindex_options"]
|
176
|
+
makeindex_sty = ReVIEW::Configure.values["pdfmaker"]["makeindex_sty"]
|
177
|
+
makeindex_dic = ReVIEW::Configure.values["pdfmaker"]["makeindex_dic"]
|
178
|
+
else
|
179
|
+
texcommand = @config["texcommand"] if @config["texcommand"]
|
180
|
+
dvicommand = @config["dvicommand"] if @config["dvicommand"]
|
181
|
+
dvioptions = @config["dvioptions"] if @config["dvioptions"]
|
182
|
+
texoptions = @config["texoptions"] if @config["texoptions"]
|
183
|
+
makeindex_command = @config["pdfmaker"]["makeindex_command"]
|
184
|
+
makeindex_options = @config["pdfmaker"]["makeindex_options"]
|
185
|
+
makeindex_sty = @config["pdfmaker"]["makeindex_sty"]
|
186
|
+
makeindex_dic = @config["pdfmaker"]["makeindex_dic"]
|
187
|
+
end
|
188
|
+
|
189
|
+
if makeindex_sty.present?
|
190
|
+
makeindex_sty = File.absolute_path(makeindex_sty, @basedir)
|
191
|
+
makeindex_options += " -s #{makeindex_sty}" if File.exist?(makeindex_sty)
|
192
|
+
end
|
193
|
+
if makeindex_dic.present?
|
194
|
+
makeindex_dic = File.absolute_path(makeindex_dic, @basedir)
|
195
|
+
makeindex_options += " -d #{makeindex_dic}" if File.exist?(makeindex_dic)
|
196
|
+
end
|
197
|
+
|
198
|
+
2.times do
|
199
|
+
system_or_raise("#{texcommand} #{texoptions} book.tex")
|
200
|
+
end
|
201
|
+
|
202
|
+
call_hook("hook_beforemakeindex")
|
203
|
+
system_or_raise("#{makeindex_command} #{makeindex_options} book") if @config["pdfmaker"]["makeindex"] && File.exist?("book.idx")
|
204
|
+
call_hook("hook_aftermakeindex")
|
205
|
+
|
206
|
+
system_or_raise("#{texcommand} #{texoptions} book.tex")
|
207
|
+
call_hook("hook_aftertexcompile")
|
208
|
+
|
209
|
+
if File.exist?("book.dvi")
|
210
|
+
system_or_raise("#{dvicommand} #{dvioptions} book.dvi")
|
211
|
+
call_hook("hook_afterdvipdf")
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
135
216
|
def generate_pdf(yamlfile)
|
136
217
|
remove_old_file
|
137
218
|
@path = build_path()
|
@@ -141,25 +222,8 @@ module ReVIEW
|
|
141
222
|
book = ReVIEW::Book.load(@basedir)
|
142
223
|
book.config = @config
|
143
224
|
@converter = ReVIEW::Converter.new(book, ReVIEW::LATEXBuilder.new)
|
144
|
-
book.parts.each do |part|
|
145
|
-
if part.name.present?
|
146
|
-
if part.file?
|
147
|
-
output_chaps(part.name, yamlfile)
|
148
|
-
@input_files["CHAPS"] << %Q|\\input{#{part.name}.tex}\n|
|
149
|
-
else
|
150
|
-
@input_files["CHAPS"] << %Q|\\part{#{part.name}}\n|
|
151
|
-
end
|
152
|
-
end
|
153
225
|
|
154
|
-
|
155
|
-
filename = File.basename(chap.path, ".*")
|
156
|
-
output_chaps(filename, yamlfile)
|
157
|
-
@input_files["PREDEF"] << "\\input{#{filename}.tex}\n" if chap.on_PREDEF?
|
158
|
-
@input_files["CHAPS"] << "\\input{#{filename}.tex}\n" if chap.on_CHAPS?
|
159
|
-
@input_files["APPENDIX"] << "\\input{#{filename}.tex}\n" if chap.on_APPENDIX?
|
160
|
-
@input_files["POSTDEF"] << "\\input{#{filename}.tex}\n" if chap.on_POSTDEF?
|
161
|
-
end
|
162
|
-
end
|
226
|
+
@input_files = make_input_files(book, yamlfile)
|
163
227
|
|
164
228
|
check_compile_status(@config["ignore-errors"])
|
165
229
|
|
@@ -168,37 +232,13 @@ module ReVIEW
|
|
168
232
|
@config["usepackage"] = "\\usepackage{#{@config['texstyle']}}"
|
169
233
|
end
|
170
234
|
|
171
|
-
copy_images("
|
235
|
+
copy_images(@config["imagedir"], File.join(@path, @config["imagedir"]))
|
172
236
|
copyStyToDir(File.join(Dir.pwd, "sty"), @path)
|
173
237
|
copyStyToDir(File.join(Dir.pwd, "sty"), @path, "fd")
|
174
238
|
copyStyToDir(File.join(Dir.pwd, "sty"), @path, "cls")
|
175
239
|
copyStyToDir(Dir.pwd, @path, "tex")
|
176
240
|
|
177
|
-
|
178
|
-
Dir.chdir(@path) do
|
179
|
-
File.open("./book.tex", "wb"){|f| f.write(template)}
|
180
|
-
|
181
|
-
call_hook("hook_beforetexcompile")
|
182
|
-
|
183
|
-
## do compile
|
184
|
-
if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0
|
185
|
-
warn "command configuration is prohibited in safe mode. ignored."
|
186
|
-
else
|
187
|
-
texcommand = @config["texcommand"] if @config["texcommand"]
|
188
|
-
dvicommand = @config["dvicommand"] if @config["dvicommand"]
|
189
|
-
dvioptions = @config["dvioptions"] if @config["dvioptions"]
|
190
|
-
texoptions = @config["texoptions"] if @config["texoptions"]
|
191
|
-
end
|
192
|
-
3.times do
|
193
|
-
system_or_raise("#{texcommand} #{texoptions} book.tex")
|
194
|
-
end
|
195
|
-
call_hook("hook_aftertexcompile")
|
196
|
-
|
197
|
-
if File.exist?("book.dvi")
|
198
|
-
system_or_raise("#{dvicommand} #{dvioptions} book.dvi")
|
199
|
-
end
|
200
|
-
end
|
201
|
-
call_hook("hook_afterdvipdf")
|
241
|
+
build_pdf
|
202
242
|
|
203
243
|
FileUtils.cp(File.join(@path, "book.pdf"), pdf_filepath)
|
204
244
|
|
@@ -299,11 +339,14 @@ module ReVIEW
|
|
299
339
|
revstr = ReVIEW::I18n.t("nth_impression", "#{rev+1}")
|
300
340
|
if item =~ /\A\d+\-\d+\-\d+\Z/
|
301
341
|
buf << ReVIEW::I18n.t("published_by1", [date_to_s(item), editstr+revstr])
|
302
|
-
|
342
|
+
elsif item =~ /\A(\d+\-\d+\-\d+)[\s ](.+)/
|
303
343
|
# custom date with string
|
304
344
|
item.match(/\A(\d+\-\d+\-\d+)[\s ](.+)/) do |m|
|
305
345
|
buf << ReVIEW::I18n.t("published_by3", [date_to_s(m[1]), m[2]])
|
306
346
|
end
|
347
|
+
else
|
348
|
+
# free format
|
349
|
+
buf << item
|
307
350
|
end
|
308
351
|
end
|
309
352
|
end
|
@@ -350,7 +393,7 @@ module ReVIEW
|
|
350
393
|
@coverimageoption = "width=\\textwidth,height=\\textheight,keepaspectratio"
|
351
394
|
end
|
352
395
|
|
353
|
-
@locale_latex =
|
396
|
+
@locale_latex = {}
|
354
397
|
part_tuple = I18n.get("part").split(/\%[A-Za-z]{1,3}/, 2)
|
355
398
|
chapter_tuple = I18n.get("chapter").split(/\%[A-Za-z]{1,3}/, 2)
|
356
399
|
appendix_tuple = I18n.get("appendix").split(/\%[A-Za-z]{1,3}/, 2)
|