review 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,7 +47,12 @@ module ReVIEW
47
47
 
48
48
  def highlight(ops)
49
49
  body = ops[:body] || ''
50
- lexer = ops[:lexer].blank? ? 'text' : ops[:lexer]
50
+ if @book.config["highlight"] && @book.config["highlight"]["lang"]
51
+ lexer = @book.config["highlight"]["lang"] # default setting
52
+ else
53
+ lexer = 'text'
54
+ end
55
+ lexer = ops[:lexer] if ops[:lexer].present?
51
56
  format = ops[:format] || ''
52
57
  options = {:nowrap => true, :noclasses => true}
53
58
  if ops[:options] && ops[:options].kind_of?(Hash)
data/lib/review/i18n.rb CHANGED
@@ -67,11 +67,10 @@ module ReVIEW
67
67
  user_i18n.delete("locale")
68
68
  @store[locale].merge!(user_i18n)
69
69
  else
70
- key = user_i18n.keys.first
71
- if !user_i18n[key].kind_of? Hash
72
- raise KeyError, "Invalid locale file: #{path}"
70
+ user_i18n.each do |key, values|
71
+ raise KeyError, "Invalid locale file: #{path}" unless values.kind_of? Hash
72
+ @store[key].merge!(values)
73
73
  end
74
- @store.merge!(user_i18n)
75
74
  end
76
75
  end
77
76
 
data/lib/review/i18n.yml CHANGED
@@ -139,6 +139,7 @@ zh_TW:
139
139
  aut: "著作人"
140
140
  csl: "監 修"
141
141
  dsr: "美術編輯"
142
+ ill: "插 畫"
142
143
  cov: "封面設計"
143
144
  edt: "編 輯"
144
145
  pht: "攝 影"
@@ -155,4 +156,14 @@ zh_TW:
155
156
  published_by1: "%s %s 出版"
156
157
  published_by2: "%s 出版"
157
158
  published_by3: "%s %s"
159
+ date_format: '%%Y年%%-m月%%-d日'
158
160
  impression: "刷"
161
+ toctitle: "目次"
162
+ covertitle: "封面"
163
+ titlepagetitle: "標題頁"
164
+ originaltitle: "原標題頁"
165
+ credittitle: "Credit"
166
+ colophontitle: "版權頁"
167
+ advtitle: "廣告"
168
+ profiletitle: "作者介紹"
169
+ backcovertitle: "封底"
@@ -1143,7 +1143,7 @@ module ReVIEW
1143
1143
  puts %Q[<caption>#{compile_inline(caption)}</caption>]
1144
1144
  end
1145
1145
 
1146
- def source_body(lines)
1146
+ def source_body(lines, lang)
1147
1147
  puts %Q[<pre>]
1148
1148
  codelines_body(lines)
1149
1149
  puts %Q[</pre></source>]
@@ -1174,10 +1174,10 @@ module ReVIEW
1174
1174
  if chap.number
1175
1175
  n = chap.headline_index.number(id)
1176
1176
  if @book.config["secnolevel"] >= n.split('.').size
1177
- return "「#{n} #{compile_inline(chap.headline(id).caption)}"
1177
+ return I18n.t("chapter_quote", "#{n} #{compile_inline(chap.headline(id).caption)}")
1178
1178
  end
1179
1179
  end
1180
- "「#{compile_inline(chap.headline(id).caption)}」"
1180
+ I18n.t("chapter_quote", compile_inline(chap.headline(id).caption))
1181
1181
  end
1182
1182
 
1183
1183
  def inline_recipe(id)
@@ -320,7 +320,12 @@ module ReVIEW
320
320
  caption_str = "\\relax" ## dummy charactor to remove lstname
321
321
  print "\\vspace{-1.5em}"
322
322
  end
323
- lexer = lang || ""
323
+ if @book.config["highlight"] && @book.config["highlight"]["lang"]
324
+ lexer = @book.config["highlight"]["lang"] # default setting
325
+ else
326
+ lexer = ""
327
+ end
328
+ lexer = lang if lang.present?
324
329
  body = lines.inject(''){|i, j| i + detab(unescape_latex(j)) + "\n"}
325
330
  puts "\\begin{"+command+"}["+title+"={"+caption_str+"},language={"+ lexer+"}]"
326
331
  print body
@@ -328,14 +333,18 @@ module ReVIEW
328
333
  blank
329
334
  end
330
335
 
331
- def source(lines, caption)
332
- puts '\begin{reviewlist}'
333
- puts macro('reviewlistcaption', compile_inline(caption))
334
- lines.each do |line|
335
- puts detab(line)
336
+ def source(lines, caption, lang = nil)
337
+ if highlight_listings?
338
+ common_code_block_lst(lines, 'reviewlistlst', 'title', caption, lang)
339
+ else
340
+ puts '\begin{reviewlist}'
341
+ puts macro('reviewlistcaption', compile_inline(caption))
342
+ lines.each do |line|
343
+ puts detab(line)
344
+ end
345
+ puts '\end{reviewlist}'
346
+ puts ""
336
347
  end
337
- puts '\end{reviewlist}'
338
- puts ""
339
348
  end
340
349
 
341
350
 
@@ -751,9 +760,9 @@ module ReVIEW
751
760
  def inline_hd_chap(chap, id)
752
761
  n = chap.headline_index.number(id)
753
762
  if chap.number and @book.config["secnolevel"] >= n.split('.').size
754
- str = "「#{chap.headline_index.number(id)} #{compile_inline(chap.headline(id).caption)}"
763
+ str = I18n.t("chapter_quote", "#{chap.headline_index.number(id)} #{compile_inline(chap.headline(id).caption)}")
755
764
  else
756
- str = "「#{compile_inline(chap.headline(id).caption)}」"
765
+ str = I18n.t("chapter_quote", compile_inline(chap.headline(id).caption))
757
766
  end
758
767
  if @book.config["chapterlink"]
759
768
  anchor = n.gsub(/\./, "-")
@@ -52,7 +52,7 @@
52
52
  <% else %>
53
53
  \usepackage{listings}
54
54
  <% end %>
55
- \renewcommand{\lstlistingname}{<%I18n.t("list")%>}
55
+ \renewcommand{\lstlistingname}{<%= I18n.t("list")%>}
56
56
  \lstset{%
57
57
  breaklines=true,%
58
58
  breakautoindent=false,%
@@ -250,7 +250,7 @@
250
250
  <%= authors %>
251
251
  \end{tabular}\par}%
252
252
  \vfill
253
- {\large <%= values["date"] %> <%= I18n.t("version")%>\hspace{2zw}<%= I18n.t("published_by", values["prt"])%>\par}%
253
+ {\large <%= values["date"] %> <%= I18n.t("edition")%>\hspace{2zw}<%= I18n.t("published_by", values["prt"])%>\par}%
254
254
  \vskip4zw\mbox{}
255
255
  \end{center}%
256
256
  \end{titlepage}
@@ -260,6 +260,17 @@
260
260
  \renewcommand{\chaptermark}[1]{{}}
261
261
  \frontmatter
262
262
 
263
+ %%% originaltitle
264
+ <% if values["originaltitlefile"] %>
265
+ <%= custom_originaltitlepage %>
266
+ <% end %>
267
+
268
+ %%% credit
269
+ <% if values["creditfile"] %>
270
+ <%= custom_creditpage %>
271
+ <% end %>
272
+
273
+
263
274
  %% preface
264
275
  <%= values["pre_str"] %>
265
276
 
@@ -284,7 +295,22 @@
284
295
  <%= values["post_str"] %>
285
296
  <% end %>
286
297
 
298
+
299
+ %%% profile
300
+ <% if values["profile"] %>
301
+ <%= custom_profilepage %>
302
+ <% end %>
303
+
304
+ %%% advfile
305
+ <% if values["advfile"] %>
306
+ <%= custom_advfilepage %>
307
+ <% end %>
308
+
309
+ %%% colophon
287
310
  <% if values["colophon"] %>
311
+ <% if custom_colophonpage %>
312
+ <%= custom_colophonpage %>
313
+ <% else %>
288
314
  %% okuduke
289
315
  \reviewcolophon
290
316
  \thispagestyle{empty}
@@ -303,7 +329,12 @@
303
329
   \\
304
330
  \rule[0pt]{14cm}{1pt} \\
305
331
  <%= values["rights"] %> \\
332
+ <% end %>
306
333
  <% end %>
307
334
 
335
+ %%% backcover
336
+ <% if values["backcover"] %>
337
+ <%= custom_backcoverpage %>
338
+ <% end %>
308
339
 
309
340
  \end{document}
@@ -0,0 +1,17 @@
1
+ require 'lineinput'
2
+
3
+ module ReVIEW
4
+ class LineInput < LineInput
5
+ def skip_comment_lines
6
+ n = 0
7
+ while line = gets()
8
+ unless line.strip =~ /\A\#@/
9
+ ungets line
10
+ return n
11
+ end
12
+ n += 1
13
+ end
14
+ n
15
+ end
16
+ end
17
+ end
@@ -22,6 +22,10 @@ module ReVIEW
22
22
  include FileUtils
23
23
  include ReVIEW::LaTeXUtils
24
24
 
25
+ def initialize
26
+ @basedir = Dir.pwd
27
+ end
28
+
25
29
  def system_or_raise(*args)
26
30
  Kernel.system(*args) or raise("failed to run command: #{args.join(' ')}")
27
31
  end
@@ -97,7 +101,6 @@ module ReVIEW
97
101
 
98
102
  def generate_pdf(config, yamlfile)
99
103
  check_book(config)
100
- @basedir = Dir.pwd
101
104
  @path = build_path(config)
102
105
  bookname = config["bookname"]
103
106
  Dir.mkdir(@path)
@@ -217,10 +220,10 @@ module ReVIEW
217
220
  end
218
221
  end
219
222
 
220
- def make_custom_titlepage(coverfile)
221
- coverfile_sty = coverfile.to_s.sub(/\.[^.]+$/, ".tex")
222
- if File.exist?(coverfile_sty)
223
- File.read(coverfile_sty)
223
+ def make_custom_page(file)
224
+ file_sty = file.to_s.sub(/\.[^.]+$/, ".tex")
225
+ if File.exist?(file_sty)
226
+ File.read(file_sty)
224
227
  else
225
228
  nil
226
229
  end
@@ -275,7 +278,16 @@ module ReVIEW
275
278
  okuduke = make_colophon(config)
276
279
  authors = make_authors(config)
277
280
 
278
- custom_titlepage = make_custom_titlepage(config["coverfile"])
281
+ custom_titlepage = make_custom_page(config["cover"]) || make_custom_page(config["coverfile"])
282
+ custom_originaltitlepage = make_custom_page(config["originaltitlefile"])
283
+ custom_creditpage = make_custom_page(config["creditfile"])
284
+
285
+ custom_profilepage = make_custom_page(config["profile"])
286
+ custom_advfilepage = make_custom_page(config["advfile"])
287
+ if config["colophon"] && config["colophon"].kind_of?(String)
288
+ custom_colophonpage = make_custom_page(config["colophon"])
289
+ end
290
+ custom_backcoverpage = make_custom_page(config["backcover"])
279
291
 
280
292
  template = File.expand_path('layout.tex.erb', File.dirname(__FILE__))
281
293
  layout_file = File.join(@basedir, "layouts", "layout.tex.erb")
@@ -756,7 +756,7 @@ module ReVIEW
756
756
  nofunc_text("[UnknownChapter:#{id}]")
757
757
  end
758
758
 
759
- def source(lines, caption = nil)
759
+ def source(lines, caption = nil, lang = nil)
760
760
  base_block "source", lines, caption
761
761
  end
762
762
 
@@ -1,3 +1,3 @@
1
1
  module ReVIEW
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.0"
3
3
  end
data/review.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.summary = "Re:VIEW: a easy-to-use digital publishing system"
14
14
  gem.description = "Re:VIEW is a digital publishing system for books and ebooks. It supports InDesign, EPUB and LaTeX."
15
15
  gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version=
16
- gem.date = "2015-02-28"
16
+ gem.date = "2015-06-29"
17
17
 
18
18
  gem.files = `git ls-files`.split("\n")
19
19
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -0,0 +1,255 @@
1
+ \documentclass[oneside]{jsbook}
2
+ \usepackage[deluxe]{otf}
3
+ \usepackage[dvipdfmx]{color}
4
+ \usepackage[dvipdfmx]{graphicx}
5
+ \usepackage{framed}
6
+ \usepackage{wrapfig}
7
+ \definecolor{shadecolor}{gray}{0.9}
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}
13
+ \usepackage[utf8]{inputenc}
14
+ \usepackage{ascmac}
15
+ \usepackage{float}
16
+ \usepackage{alltt}
17
+ \usepackage{amsmath}
18
+
19
+ %% if you use @<u>{} (underline), use jumoline.sty
20
+ %%\usepackage{jumoline}
21
+
22
+ \newenvironment{shadedb}{%
23
+ \def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolorb}}%
24
+ \MakeFramed {\FrameRestore}}%
25
+ {\endMakeFramed}
26
+
27
+ \usepackage[top=10zw,bottom=12zw,left=10zw,right=10zw]{geometry}
28
+ %\usepackage[top=5zw,bottom=5zw,left=1zw,right=1zw]{geometry}
29
+
30
+
31
+ \newcommand{\parasep}{\vspace*{3zh}}
32
+ \setlength{\footskip}{30pt}
33
+
34
+ %% Bookmarkの文字化け対策(日本語向け)
35
+ \ifnum 46273=\euc"B4C1 % 46273 == 0xB4C1 == 漢(EUC-JP)
36
+ \usepackage{atbegshi}%
37
+ \AtBeginShipoutFirst{\special{pdf:tounicode EUC-UCS2}}%
38
+ %%\AtBeginDvi{\special{pdf:tounicode EUC-UCS2}}%
39
+ \else
40
+ \usepackage{atbegshi}%
41
+ \AtBeginShipoutFirst{\special{pdf:tounicode 90ms-RKSJ-UCS2}}%
42
+ %%\AtBeginDvi{\special{pdf:tounicode 90ms-RKSJ-UCS2}}%
43
+ \fi
44
+
45
+ \usepackage[dvipdfm,bookmarks=true,bookmarksnumbered=true,colorlinks=true,%
46
+ pdftitle={Re:VIEW Sample Book},%
47
+ pdfauthor={}]{hyperref}
48
+
49
+
50
+
51
+ \newenvironment{reviewimage}{%
52
+ \begin{figure}[H]
53
+ \begin{center}}{%
54
+ \end{center}
55
+ \end{figure}}
56
+
57
+ \newenvironment{reviewdummyimage}{%
58
+ \begin{figure}[H]
59
+ \begin{center}\begin{alltt}}{%
60
+ \end{alltt}\end{center}
61
+ \end{figure}}
62
+
63
+ \newenvironment{reviewemlist}{%
64
+ \medskip\small\begin{shaded}\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
65
+ \end{alltt}\end{shaded}}
66
+
67
+ \newenvironment{reviewlist}{%
68
+ \begin{shaded}\small\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
69
+ \end{alltt}\end{shaded}\par\vspace*{0.5zw}}
70
+
71
+ \newenvironment{reviewcmd}{%
72
+ \color{white}\medskip\small\begin{shadedb}\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
73
+ \end{alltt}\end{shadedb}}
74
+
75
+ \newenvironment{reviewbox}{%
76
+ \medskip\small\begin{framed}\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
77
+ \end{alltt}\end{framed}}
78
+
79
+ \newenvironment{reviewtable}[1]{%
80
+ \begin{center}\small\setlength{\baselineskip}{1.2zw}
81
+ \begin{tabular}{#1}}{%
82
+ \end{tabular}
83
+ \end{center}}
84
+
85
+ \newenvironment{reviewcolumn}{%
86
+ \begin{framed}
87
+ }{%
88
+ \end{framed}
89
+ \vspace{2zw}}
90
+
91
+ \newcommand{\reviewcolumnhead}[2]{%
92
+ {\noindent\large ■コラム: #2}}
93
+
94
+ \newcommand{\reviewtablecaption}[1]{%
95
+ \caption{#1}}
96
+
97
+ \newcommand{\reviewbackslash}[0]{%
98
+ \textbackslash{}}
99
+
100
+ \newcommand{\reviewlistcaption}[1]{%
101
+ \medskip{\small\noindent #1}\vspace*{-1.3zw}}
102
+
103
+ \newcommand{\reviewemlistcaption}[1]{%
104
+ \medskip{\small\noindent #1}\vspace*{-1.3zw}}
105
+
106
+ \newcommand{\reviewcmdcaption}[1]{%
107
+ \medskip{\small\noindent #1}\vspace*{-1.3zw}}
108
+
109
+ \newcommand{\reviewindepimagecaption}[1]{%
110
+ \begin{center}#1\end{center}}
111
+
112
+ \newcommand{\reviewboxcaption}[1]{%
113
+ \medskip{\small\noindent #1}\vspace*{-1.3zw}}
114
+
115
+ \newcommand{\reviewimageref}[2]{%
116
+ 図 #1}
117
+ \newcommand{\reviewtableref}[2]{%
118
+ 表 #1}
119
+ \newcommand{\reviewlistref}[1]{%
120
+ リスト #1}
121
+ \newcommand{\reviewbibref}[2]{%
122
+ #1}
123
+ \newcommand{\reviewcolumnref}[2]{%
124
+ コラム #1}
125
+ \newcommand{\reviewsecref}[2]{%
126
+ #1}
127
+
128
+ \newcommand{\reviewminicolumntitle}[1]{%
129
+ {\large ■メモ: #1}\\}
130
+
131
+
132
+
133
+ \newenvironment{reviewminicolumn}{%
134
+ \vspace{1.5zw}\begin{screen}}{%
135
+ \end{screen}\vspace{2zw}}
136
+
137
+ \newcommand{\reviewkw}[1]{%
138
+ \textbf{\textgt{#1}}}
139
+
140
+ \newcommand{\reviewami}[1]{%
141
+ \mask{#1}{A}}
142
+
143
+ \newcommand{\reviewem}[1]{%
144
+ \textbf{#1}}
145
+
146
+ \newcommand{\reviewstrong}[1]{%
147
+ \textbf{#1}}
148
+
149
+ %% @<del> is ignored in LaTeX with default style
150
+ \newcommand{\reviewstrike}[1]{#1}
151
+
152
+ %%%% for ulem.sty:
153
+ %%\renewcommand{\reviewstrike}[1]{\sout{#1}}
154
+ %%
155
+ %%%% for jumoline.sty:
156
+ %%\renewcommand{\reviewstrike}[1]{\Middleline{#1}}
157
+
158
+ \newcommand{\reviewth}[1]{%
159
+ \textgt{#1}}
160
+
161
+ \newcommand{\reviewtitlefont}[0]{%
162
+ \usefont{T1}{phv}{b}{n}\gtfamily}
163
+
164
+ \newcommand{\reviewmainfont}[0]{%
165
+ }
166
+
167
+ \newcommand{\reviewcolophon}[0]{%
168
+ \clearpage}
169
+ \newcommand{\reviewappendix}[0]{%
170
+ \appendix}
171
+
172
+ \makeatletter
173
+ %% maxwidth is the original width if it is less than linewidth
174
+ %% otherwise use linewidth (to make sure the graphics do not exceed the margin)
175
+ \def\maxwidth{%
176
+ \ifdim\Gin@nat@width>\linewidth
177
+ \linewidth
178
+ \else
179
+ \Gin@nat@width
180
+ \fi
181
+ }
182
+ \makeatother
183
+
184
+
185
+
186
+ \usepackage[T1]{fontenc}
187
+
188
+ \begin{document}
189
+
190
+ \reviewmainfont
191
+
192
+
193
+
194
+ \begin{titlepage}
195
+
196
+ \thispagestyle{empty}
197
+ \begin{center}%
198
+ \mbox{} \vskip5zw
199
+ \reviewtitlefont%
200
+ {\Huge Re:VIEW Sample Book \par}%
201
+ \vskip 15em%
202
+ {\huge
203
+ \lineskip .75em
204
+ \begin{tabular}[t]{c}%
205
+
206
+ \end{tabular}\par}%
207
+ \vfill
208
+ {\large 2011-01-01 版\hspace{2zw} 発行\par}%
209
+ \vskip4zw\mbox{}
210
+ \end{center}%
211
+ \end{titlepage}
212
+
213
+
214
+
215
+ \renewcommand{\chaptermark}[1]{{}}
216
+ \frontmatter
217
+
218
+ %%% originaltitle
219
+
220
+
221
+ %%% credit
222
+
223
+
224
+
225
+ %% preface
226
+
227
+
228
+
229
+
230
+ \renewcommand{\chaptermark}[1]{\markboth{\prechaptername\thechapter\postchaptername~#1}{}}
231
+ \mainmatter
232
+
233
+ \renewcommand{\chaptermark}[1]{\markboth{\appendixname\thechapter~#1}{}}
234
+ \reviewappendix
235
+
236
+
237
+ %% backmatter begins
238
+
239
+
240
+
241
+
242
+
243
+ %%% profile
244
+
245
+
246
+ %%% advfile
247
+
248
+
249
+ %%% colophon
250
+
251
+
252
+ %%% backcover
253
+
254
+
255
+ \end{document}