review 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +1 -0
- data/ChangeLog +87 -0
- data/bin/review-check +2 -2
- data/bin/review-compile +15 -30
- data/bin/review-index +1 -1
- data/bin/review-init +12 -7
- data/bin/review-vol +9 -1
- data/doc/catalog.ja.md +53 -0
- data/doc/catalog.md +52 -0
- data/doc/format.ja.md +734 -0
- data/doc/format.md +746 -0
- data/doc/format_idg.ja.md +203 -0
- data/doc/{quickstart.rdoc → quickstart.ja.md} +138 -104
- data/doc/quickstart.md +252 -0
- data/doc/sample.yml +216 -48
- data/lib/epubmaker.rb +0 -1
- data/lib/epubmaker/content.rb +2 -2
- data/lib/epubmaker/epubcommon.rb +440 -0
- data/lib/epubmaker/epubv2.rb +8 -418
- data/lib/epubmaker/epubv3.rb +67 -61
- data/lib/epubmaker/producer.rb +60 -19
- data/lib/review/book.rb +1 -3
- data/lib/review/book/base.rb +18 -11
- data/lib/review/book/chapter.rb +5 -24
- data/lib/review/book/compilable.rb +5 -1
- data/lib/review/book/index.rb +48 -17
- data/lib/review/book/page_metric.rb +17 -8
- data/lib/review/book/part.rb +12 -2
- data/lib/review/book/volume.rb +3 -2
- data/lib/review/builder.rb +30 -10
- data/lib/review/compiler.rb +6 -4
- data/lib/review/configure.rb +3 -3
- data/lib/review/epubmaker.rb +56 -26
- data/lib/review/htmlbuilder.rb +33 -42
- data/lib/review/htmlutils.rb +12 -7
- data/lib/review/i18n.rb +77 -17
- data/lib/review/i18n.yml +80 -4
- data/lib/review/idgxmlbuilder.rb +27 -57
- data/lib/review/inaobuilder.rb +3 -3
- data/lib/review/latexbuilder.rb +90 -67
- data/lib/review/layout.tex.erb +54 -7
- data/lib/review/markdownbuilder.rb +21 -3
- data/lib/review/pdfmaker.rb +67 -38
- data/lib/review/sec_counter.rb +1 -1
- data/lib/review/tocparser.rb +9 -5
- data/lib/review/topbuilder.rb +6 -6
- data/lib/review/version.rb +1 -1
- data/review.gemspec +3 -1
- data/test/book_test_helper.rb +1 -1
- data/test/sample-book/README.md +2 -0
- data/test/sample-book/src/Rakefile +31 -0
- data/test/sample-book/src/_cover.html +0 -0
- data/test/sample-book/src/catalog.yml +10 -0
- data/test/sample-book/src/ch01.re +0 -0
- data/test/sample-book/src/ch02.re +0 -0
- data/test/sample-book/src/config.yml +160 -32
- data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
- data/test/sample-book/src/images/cover.jpg +0 -0
- data/test/sample-book/src/preface.re +0 -0
- data/test/sample-book/src/sty/jumoline.sty +0 -0
- data/test/sample-book/src/sty/reviewmacro.sty +18 -0
- data/test/sample-book/src/style.css +0 -0
- data/test/test_book.rb +25 -27
- data/test/test_book_chapter.rb +4 -73
- data/test/test_book_part.rb +5 -4
- data/test/test_builder.rb +3 -3
- data/test/test_epub3maker.rb +527 -0
- data/test/test_epubmaker.rb +6 -6
- data/test/test_htmlbuilder.rb +143 -6
- data/test/test_i18n.rb +95 -10
- data/test/test_idgxmlbuilder.rb +28 -2
- data/test/test_index.rb +109 -1
- data/test/test_latexbuilder.rb +51 -0
- data/test/test_markdownbuilder.rb +54 -1
- data/test/test_pdfmaker.rb +7 -6
- data/test/test_review_ext.rb +31 -0
- data/test/test_topbuilder.rb +3 -1
- metadata +46 -13
- data/doc/catalog.rdoc +0 -49
- data/doc/format.rdoc +0 -618
- data/doc/format_idg.rdoc +0 -180
- data/doc/libepubmaker/config.yml +0 -207
- data/lib/epubmaker/resource.rb +0 -82
- data/test/sample-book/src/CHAPS +0 -2
- data/test/sample-book/src/PREDEF +0 -1
data/lib/review/layout.tex.erb
CHANGED
@@ -6,6 +6,10 @@
|
|
6
6
|
\usepackage{wrapfig}
|
7
7
|
\definecolor{shadecolor}{gray}{0.9}
|
8
8
|
\definecolor{shadecolorb}{gray}{0.1}
|
9
|
+
\definecolor{reviewgreen}{rgb}{0,0.4,0}
|
10
|
+
\definecolor{reviewblue}{rgb}{0.2,0.2,0.4}
|
11
|
+
\definecolor{reviewred}{rgb}{0.7,0,0}
|
12
|
+
\definecolor{reviewdarkred}{rgb}{0.3,0,0}
|
9
13
|
\usepackage[utf8]{inputenc}
|
10
14
|
\usepackage{ascmac}
|
11
15
|
\usepackage{float}
|
@@ -42,6 +46,43 @@
|
|
42
46
|
pdftitle={<%= values["booktitle"] %>},%
|
43
47
|
pdfauthor={<%= values["aut"] %>}]{hyperref}
|
44
48
|
|
49
|
+
<% if config["highlight"] && config["highlight"]["latex"] == "listings" %>
|
50
|
+
<% if config["language"] == "ja" %>
|
51
|
+
\usepackage{listings,jlisting}
|
52
|
+
<% else %>
|
53
|
+
\usepackage{listings}
|
54
|
+
<% end %>
|
55
|
+
\renewcommand{\lstlistingname}{<%I18n.t("list")%>}
|
56
|
+
\lstset{%
|
57
|
+
breaklines=true,%
|
58
|
+
breakautoindent=false,%
|
59
|
+
breakindent=0pt,%
|
60
|
+
fontadjust=true,%
|
61
|
+
backgroundcolor=\color{shadecolor},%
|
62
|
+
frame=single,%
|
63
|
+
framerule=0pt,%
|
64
|
+
basicstyle=\ttfamily\scriptsize,%
|
65
|
+
commentstyle=\color{reviewgreen},%
|
66
|
+
identifierstyle=\color{reviewblue},%
|
67
|
+
stringstyle=\color{reviewred},%
|
68
|
+
keywordstyle=\bfseries\color{reviewdarkred},%
|
69
|
+
}
|
70
|
+
\lstnewenvironment{reviewemlistlst}[1][]{%
|
71
|
+
\lstset{#1}}{}
|
72
|
+
|
73
|
+
\lstnewenvironment{reviewemlistnumlst}[1][]{%
|
74
|
+
\lstset{numbers=left, #1}}{}
|
75
|
+
|
76
|
+
\lstnewenvironment{reviewlistlst}[1][]{%
|
77
|
+
\lstset{#1}}{}
|
78
|
+
|
79
|
+
\lstnewenvironment{reviewlistnumlst}[1][]{%
|
80
|
+
\lstset{numbers=left, #1}}{}
|
81
|
+
|
82
|
+
\lstnewenvironment{reviewcmdlst}[1][]{%
|
83
|
+
\lstset{backgroundcolor=\color{white}, frameround=tttt, frame=trbl, #1}}{}
|
84
|
+
<% end %>
|
85
|
+
|
45
86
|
\newenvironment{reviewimage}{%
|
46
87
|
\begin{figure}[H]
|
47
88
|
\begin{center}}{%
|
@@ -83,7 +124,7 @@
|
|
83
124
|
\vspace{2zw}}
|
84
125
|
|
85
126
|
\newcommand{\reviewcolumnhead}[2]{%
|
86
|
-
{\noindent\large
|
127
|
+
{\noindent\large <%= I18n.t("column_head")%>: #2}}
|
87
128
|
|
88
129
|
\newcommand{\reviewtablecaption}[1]{%
|
89
130
|
\caption{#1}}
|
@@ -107,20 +148,24 @@
|
|
107
148
|
\medskip{\small\noindent #1}\vspace*{-1.3zw}}
|
108
149
|
|
109
150
|
\newcommand{\reviewimageref}[2]{%
|
110
|
-
|
151
|
+
<%= I18n.t("image")%> #1}
|
111
152
|
\newcommand{\reviewtableref}[2]{%
|
112
|
-
|
153
|
+
<%= I18n.t("table")%> #1}
|
113
154
|
\newcommand{\reviewlistref}[1]{%
|
114
|
-
|
155
|
+
<%= I18n.t("list")%> #1}
|
115
156
|
\newcommand{\reviewbibref}[2]{%
|
116
157
|
#1}
|
117
158
|
\newcommand{\reviewcolumnref}[2]{%
|
118
|
-
|
159
|
+
<%= I18n.t("columnname")%> #1}
|
119
160
|
\newcommand{\reviewsecref}[2]{%
|
120
161
|
#1}
|
121
162
|
|
122
163
|
\newcommand{\reviewminicolumntitle}[1]{%
|
123
|
-
{\large
|
164
|
+
{\large <%= I18n.t("memo_head")%>: #1}\\}
|
165
|
+
|
166
|
+
<% if values["toctitle"].present? %>
|
167
|
+
\renewcommand{\contentsname}{<%= values["toctitle"]%>}
|
168
|
+
<% end %>
|
124
169
|
|
125
170
|
\newenvironment{reviewminicolumn}{%
|
126
171
|
\vspace{1.5zw}\begin{screen}}{%
|
@@ -162,6 +207,8 @@
|
|
162
207
|
\appendix}
|
163
208
|
|
164
209
|
\makeatletter
|
210
|
+
%% maxwidth is the original width if it is less than linewidth
|
211
|
+
%% otherwise use linewidth (to make sure the graphics do not exceed the margin)
|
165
212
|
\def\maxwidth{%
|
166
213
|
\ifdim\Gin@nat@width>\linewidth
|
167
214
|
\linewidth
|
@@ -203,7 +250,7 @@
|
|
203
250
|
<%= authors %>
|
204
251
|
\end{tabular}\par}%
|
205
252
|
\vfill
|
206
|
-
{\large <%= values["date"] %>
|
253
|
+
{\large <%= values["date"] %> <%= I18n.t("version")%>\hspace{2zw}<%= I18n.t("published_by", values["prt"])%>\par}%
|
207
254
|
\vskip4zw\mbox{}
|
208
255
|
\end{center}%
|
209
256
|
\end{titlepage}
|
@@ -49,6 +49,23 @@ module ReVIEW
|
|
49
49
|
puts "\n"
|
50
50
|
end
|
51
51
|
|
52
|
+
def list_header(id, caption, lang)
|
53
|
+
if get_chap.nil?
|
54
|
+
puts %Q[リスト#{@chapter.list(id).number} #{compile_inline(caption)}]
|
55
|
+
else
|
56
|
+
puts %Q[リスト#{get_chap}.#{@chapter.list(id).number} #{compile_inline(caption)}]
|
57
|
+
end
|
58
|
+
lang ||= ""
|
59
|
+
puts "```#{lang}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def list_body(id, lines, lang)
|
63
|
+
lines.each do |line|
|
64
|
+
puts detab(line)
|
65
|
+
end
|
66
|
+
puts '```'
|
67
|
+
end
|
68
|
+
|
52
69
|
def ul_begin
|
53
70
|
blank if @ul_indent == 0
|
54
71
|
@ul_indent += 1
|
@@ -82,12 +99,13 @@ module ReVIEW
|
|
82
99
|
blank
|
83
100
|
end
|
84
101
|
|
85
|
-
def emlist(lines, caption = nil)
|
102
|
+
def emlist(lines, caption = nil, lang = nil)
|
86
103
|
blank
|
87
104
|
if caption
|
88
105
|
puts caption
|
89
106
|
end
|
90
|
-
|
107
|
+
lang ||= ""
|
108
|
+
puts "```#{lang}"
|
91
109
|
lines.each do |line|
|
92
110
|
puts detab(line)
|
93
111
|
end
|
@@ -161,7 +179,7 @@ module ReVIEW
|
|
161
179
|
end
|
162
180
|
|
163
181
|
def cmd(lines)
|
164
|
-
puts "```"
|
182
|
+
puts "```shell-session"
|
165
183
|
lines.each do |line|
|
166
184
|
puts detab(line)
|
167
185
|
end
|
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-2015 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
|
@@ -22,6 +22,10 @@ module ReVIEW
|
|
22
22
|
include FileUtils
|
23
23
|
include ReVIEW::LaTeXUtils
|
24
24
|
|
25
|
+
def system_or_raise(*args)
|
26
|
+
Kernel.system(*args) or raise("failed to run command: #{args.join(' ')}")
|
27
|
+
end
|
28
|
+
|
25
29
|
def error(msg)
|
26
30
|
$stderr.puts "#{File.basename($0, '.*')}: error: #{msg}"
|
27
31
|
exit 1
|
@@ -33,9 +37,7 @@ module ReVIEW
|
|
33
37
|
|
34
38
|
def check_book(config)
|
35
39
|
pdf_file = config["bookname"]+".pdf"
|
36
|
-
if File.exist?
|
37
|
-
error "file already exists:#{pdf_file}"
|
38
|
-
end
|
40
|
+
File.unlink(pdf_file) if File.exist?(pdf_file)
|
39
41
|
end
|
40
42
|
|
41
43
|
def build_path(config)
|
@@ -89,10 +91,11 @@ module ReVIEW
|
|
89
91
|
config.merge!(YAML.load_file(yamlfile))
|
90
92
|
# YAML configs will be overridden by command line options.
|
91
93
|
config.merge!(cmd_config)
|
92
|
-
|
94
|
+
I18n.setup(config["language"])
|
95
|
+
generate_pdf(config, yamlfile)
|
93
96
|
end
|
94
97
|
|
95
|
-
def generate_pdf(config)
|
98
|
+
def generate_pdf(config, yamlfile)
|
96
99
|
check_book(config)
|
97
100
|
@basedir = Dir.pwd
|
98
101
|
@path = build_path(config)
|
@@ -102,10 +105,12 @@ module ReVIEW
|
|
102
105
|
@chaps_fnames = Hash.new{|h, key| h[key] = ""}
|
103
106
|
@compile_errors = nil
|
104
107
|
|
105
|
-
ReVIEW::Book.load(@basedir)
|
108
|
+
book = ReVIEW::Book.load(@basedir)
|
109
|
+
book.config = config
|
110
|
+
book.parts.each do |part|
|
106
111
|
if part.name.present?
|
107
112
|
if part.file?
|
108
|
-
|
113
|
+
output_chaps(part.name, config, yamlfile)
|
109
114
|
@chaps_fnames["CHAPS"] << %Q|\\input{#{part.name}.tex}\n|
|
110
115
|
else
|
111
116
|
@chaps_fnames["CHAPS"] << %Q|\\part{#{part.name}}\n|
|
@@ -113,12 +118,12 @@ module ReVIEW
|
|
113
118
|
end
|
114
119
|
|
115
120
|
part.chapters.each do |chap|
|
116
|
-
filename =
|
117
|
-
output_chaps(filename, config)
|
118
|
-
@chaps_fnames["PREDEF"] << "\\input{#{filename}}\n" if chap.on_PREDEF?
|
119
|
-
@chaps_fnames["CHAPS"] << "\\input{#{filename}}\n" if chap.on_CHAPS?
|
120
|
-
@chaps_fnames["APPENDIX"] << "\\input{#{filename}}\n" if chap.on_APPENDIX?
|
121
|
-
@chaps_fnames["POSTDEF"] << "\\input{#{filename}}\n" if chap.on_POSTDEF?
|
121
|
+
filename = File.basename(chap.path, ".*")
|
122
|
+
output_chaps(filename, config, yamlfile)
|
123
|
+
@chaps_fnames["PREDEF"] << "\\input{#{filename}.tex}\n" if chap.on_PREDEF?
|
124
|
+
@chaps_fnames["CHAPS"] << "\\input{#{filename}.tex}\n" if chap.on_CHAPS?
|
125
|
+
@chaps_fnames["APPENDIX"] << "\\input{#{filename}.tex}\n" if chap.on_APPENDIX?
|
126
|
+
@chaps_fnames["POSTDEF"] << "\\input{#{filename}.tex}\n" if chap.on_POSTDEF?
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
@@ -136,26 +141,47 @@ module ReVIEW
|
|
136
141
|
|
137
142
|
copy_images("./images", "#{@path}/images")
|
138
143
|
copyStyToDir(Dir.pwd + "/sty", @path)
|
144
|
+
copyStyToDir(Dir.pwd + "/sty", @path, "fd")
|
145
|
+
copyStyToDir(Dir.pwd + "/sty", @path, "cls")
|
139
146
|
copyStyToDir(Dir.pwd, @path, "tex")
|
140
147
|
|
141
148
|
Dir.chdir(@path) {
|
142
149
|
template = get_template(config)
|
143
150
|
File.open("./book.tex", "wb"){|f| f.write(template)}
|
144
151
|
|
152
|
+
call_hook("hook_beforetexcompile", config)
|
153
|
+
|
145
154
|
## do compile
|
146
155
|
enc = config["params"].to_s.split(/\s+/).find{|i| i =~ /\A--outencoding=/ }
|
147
156
|
kanji = 'utf8'
|
148
|
-
|
149
|
-
|
157
|
+
texcommand = "platex"
|
158
|
+
texoptions = "-kanji=#{kanji}"
|
159
|
+
dvicommand = "dvipdfmx"
|
160
|
+
dvioptions = "-d 5"
|
161
|
+
|
162
|
+
if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0
|
163
|
+
warn "command configuration is prohibited in safe mode. ignored."
|
164
|
+
else
|
165
|
+
texcommand = config["texcommand"] if config["texcommand"]
|
166
|
+
dvicommand = config["dvicommand"] if config["dvicommand"]
|
167
|
+
dvioptions = config["dvioptions"] if config["dvioptions"]
|
168
|
+
if enc
|
169
|
+
kanji = enc.split(/\=/).last.gsub(/-/, '').downcase
|
170
|
+
texoptions = "-kanji=#{kanji}"
|
171
|
+
end
|
172
|
+
texoptions = config["texoptions"] if config["texoptions"]
|
150
173
|
end
|
151
|
-
texcommand = config["texcommand"] || "platex"
|
152
174
|
3.times do
|
153
|
-
|
175
|
+
system_or_raise("#{texcommand} #{texoptions} book.tex")
|
154
176
|
end
|
155
|
-
|
156
|
-
|
177
|
+
call_hook("hook_aftertexcompile", config)
|
178
|
+
|
179
|
+
if File.exist?("book.dvi")
|
180
|
+
system_or_raise("#{dvicommand} #{dvioptions} book.dvi")
|
157
181
|
end
|
158
182
|
}
|
183
|
+
call_hook("hook_afterdvipdf", config)
|
184
|
+
|
159
185
|
FileUtils.cp("#{@path}/book.pdf", "#{@basedir}/#{bookname}.pdf")
|
160
186
|
|
161
187
|
unless config["debug"]
|
@@ -163,20 +189,9 @@ module ReVIEW
|
|
163
189
|
end
|
164
190
|
end
|
165
191
|
|
166
|
-
def output_chaps(filename, config)
|
167
|
-
$stderr.puts "compiling #{filename}"
|
168
|
-
cmd = "#{ReVIEW::MakerHelper.bindir}/review-compile --target=latex --level=#{config["secnolevel"]} --toclevel=#{config["toclevel"]} #{config["params"]} #{filename} > #{@path}/#{filename}"
|
169
|
-
if system cmd
|
170
|
-
# OK
|
171
|
-
else
|
172
|
-
@compile_errors = true
|
173
|
-
warn cmd
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def output_parts(filename, config)
|
192
|
+
def output_chaps(filename, config, yamlfile)
|
178
193
|
$stderr.puts "compiling #{filename}.tex"
|
179
|
-
cmd = "review-compile --target=latex --level=#{config["secnolevel"]} --toclevel=#{config["toclevel"]} #{config["params"]} #{filename}.re
|
194
|
+
cmd = "#{ReVIEW::MakerHelper.bindir}/review-compile --yaml=#{yamlfile} --target=latex --level=#{config["secnolevel"]} --toclevel=#{config["toclevel"]} #{config["params"]} #{filename}.re > #{@path}/#{filename}.tex"
|
180
195
|
if system cmd
|
181
196
|
# OK
|
182
197
|
else
|
@@ -185,7 +200,6 @@ module ReVIEW
|
|
185
200
|
end
|
186
201
|
end
|
187
202
|
|
188
|
-
|
189
203
|
def copy_images(from, to)
|
190
204
|
if File.exist?(from)
|
191
205
|
Dir.mkdir(to)
|
@@ -194,9 +208,10 @@ module ReVIEW
|
|
194
208
|
images = Dir.glob("**/*").find_all{|f|
|
195
209
|
File.file?(f) and f =~ /\.(jpg|jpeg|png|pdf)\z/
|
196
210
|
}
|
211
|
+
break if images.empty?
|
197
212
|
system("extractbb", *images)
|
198
213
|
unless system("extractbb", "-m", *images)
|
199
|
-
|
214
|
+
system_or_raise("ebb", *images)
|
200
215
|
end
|
201
216
|
end
|
202
217
|
end
|
@@ -238,13 +253,16 @@ module ReVIEW
|
|
238
253
|
def make_authors(config)
|
239
254
|
authors = ""
|
240
255
|
if config["aut"].present?
|
241
|
-
|
256
|
+
author_names = join_with_separator(config["aut"], ReVIEW::I18n.t("names_splitter"))
|
257
|
+
authors = ReVIEW::I18n.t("author_with_label", author_names)
|
242
258
|
end
|
243
259
|
if config["csl"].present?
|
244
|
-
|
260
|
+
csl_names = join_with_separator(config["csl"], ReVIEW::I18n.t("names_splitter"))
|
261
|
+
authors += " \\\\\n"+ ReVIEW::I18n.t("supervisor_with_label", csl_names)
|
245
262
|
end
|
246
263
|
if config["trl"].present?
|
247
|
-
|
264
|
+
trl_names = join_with_separator(config["trl"], ReVIEW::I18n.t("names_splitter"))
|
265
|
+
authors += " \\\\\n"+ ReVIEW::I18n.t("translator_with_label", trl_names)
|
248
266
|
end
|
249
267
|
authors
|
250
268
|
end
|
@@ -286,6 +304,17 @@ module ReVIEW
|
|
286
304
|
}
|
287
305
|
}
|
288
306
|
end
|
307
|
+
|
308
|
+
def call_hook(hookname, config)
|
309
|
+
if config["pdfmaker"].instance_of?(Hash) && config["pdfmaker"][hookname]
|
310
|
+
hook = File.absolute_path(config["pdfmaker"][hookname], @basedir)
|
311
|
+
if ENV["REVIEW_SAFE_MODE"].to_i & 1 > 0
|
312
|
+
warn "hook configuration is prohibited in safe mode. ignored."
|
313
|
+
else
|
314
|
+
system_or_raise("#{hook} #{Dir.pwd} #{@basedir}")
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
289
318
|
end
|
290
319
|
end
|
291
320
|
|
data/lib/review/sec_counter.rb
CHANGED
data/lib/review/tocparser.rb
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
require 'review/preprocessor'
|
14
14
|
require 'review/book'
|
15
15
|
require 'review/textbuilder'
|
16
|
-
require 'forwardable'
|
17
16
|
|
18
17
|
module ReVIEW
|
19
18
|
|
@@ -44,7 +43,7 @@ module ReVIEW
|
|
44
43
|
error! filename, f.lineno, "section level too deep: #{lev}" if lev > 5
|
45
44
|
if path.empty?
|
46
45
|
# missing chapter label
|
47
|
-
path.push Chapter.new(get_label(line), id, filename)
|
46
|
+
path.push Chapter.new(get_label(line), id, filename, chap.book.page_metric)
|
48
47
|
roots.push path.first
|
49
48
|
end
|
50
49
|
next if get_label(line) =~ /\A\[\// # ex) "[/column]"
|
@@ -57,7 +56,7 @@ module ReVIEW
|
|
57
56
|
|
58
57
|
when /\A= /
|
59
58
|
path.clear
|
60
|
-
path.push Chapter.new(get_label(line), id, filename)
|
59
|
+
path.push Chapter.new(get_label(line), id, filename, chap.book.page_metric)
|
61
60
|
roots.push path.first
|
62
61
|
|
63
62
|
when %r<\A//\w+(?:\[.*?\])*\{\s*\z>
|
@@ -99,7 +98,10 @@ module ReVIEW
|
|
99
98
|
|
100
99
|
def compile_label(line)
|
101
100
|
b = ReVIEW::TEXTBuilder.new
|
102
|
-
|
101
|
+
dummy_book = ReVIEW::Book::Base.load
|
102
|
+
dummy_chapter = ReVIEW::Book::Chapter.new(dummy_book, 1, '-', nil, StringIO.new)
|
103
|
+
dummy_loc = Location.new("", StringIO.new)
|
104
|
+
b.bind(ReVIEW::Compiler.new(b), dummy_chapter, dummy_loc)
|
103
105
|
b.compile_inline(line)
|
104
106
|
end
|
105
107
|
|
@@ -206,10 +208,11 @@ module ReVIEW
|
|
206
208
|
|
207
209
|
class Chapter < Section
|
208
210
|
|
209
|
-
def initialize(label, id, path)
|
211
|
+
def initialize(label, id, path, page_metric)
|
210
212
|
super 1, label, path
|
211
213
|
@chapter_id = id
|
212
214
|
@path = path
|
215
|
+
@page_metric = page_metric
|
213
216
|
@volume = nil
|
214
217
|
@number = nil
|
215
218
|
end
|
@@ -226,6 +229,7 @@ module ReVIEW
|
|
226
229
|
return @volume if @volume
|
227
230
|
return Book::Volume.dummy unless @path
|
228
231
|
@volume = Book::Volume.count_file(@path)
|
232
|
+
@volume.page_per_kbyte = @page_metric.page_per_kbyte
|
229
233
|
@volume.lines = estimated_lines()
|
230
234
|
@volume
|
231
235
|
end
|
data/lib/review/topbuilder.rb
CHANGED
@@ -242,7 +242,7 @@ module ReVIEW
|
|
242
242
|
|
243
243
|
end
|
244
244
|
|
245
|
-
def list_header(id, caption)
|
245
|
+
def list_header(id, caption, lang)
|
246
246
|
blank
|
247
247
|
puts "◆→開始:#{@titles["list"]}←◆"
|
248
248
|
if get_chap.nil?
|
@@ -253,7 +253,7 @@ module ReVIEW
|
|
253
253
|
blank
|
254
254
|
end
|
255
255
|
|
256
|
-
def list_body(id, lines)
|
256
|
+
def list_body(id, lines, lang)
|
257
257
|
lines.each do |line|
|
258
258
|
puts detab(line)
|
259
259
|
end
|
@@ -279,11 +279,11 @@ module ReVIEW
|
|
279
279
|
blank
|
280
280
|
end
|
281
281
|
|
282
|
-
def emlist(lines, caption = nil)
|
282
|
+
def emlist(lines, caption = nil, lang = nil)
|
283
283
|
base_block "emlist", lines, caption
|
284
284
|
end
|
285
285
|
|
286
|
-
def emlistnum(lines, caption = nil)
|
286
|
+
def emlistnum(lines, caption = nil, lang = nil)
|
287
287
|
blank
|
288
288
|
puts "◆→開始:#{@titles["emlist"]}←◆"
|
289
289
|
puts "■#{compile_inline(caption)}" unless caption.nil?
|
@@ -295,7 +295,7 @@ module ReVIEW
|
|
295
295
|
blank
|
296
296
|
end
|
297
297
|
|
298
|
-
def listnum_body(lines)
|
298
|
+
def listnum_body(lines, lang)
|
299
299
|
lines.each_with_index do |line, i|
|
300
300
|
puts (i + 1).to_s.rjust(2) + ": #{line}"
|
301
301
|
end
|
@@ -750,7 +750,7 @@ module ReVIEW
|
|
750
750
|
end
|
751
751
|
else
|
752
752
|
end
|
753
|
-
"#{chs[0]}#{@
|
753
|
+
"#{chs[0]}#{@book.chapter_index.number(id)}#{chs[1]}#{@book.chapter_index.title(id)}#{chs[2]}"
|
754
754
|
rescue KeyError
|
755
755
|
error "unknown chapter: #{id}"
|
756
756
|
nofunc_text("[UnknownChapter:#{id}]")
|