review 2.5.0 → 3.0.0.preview1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +28 -10
  3. data/.travis.yml +11 -2
  4. data/NEWS.ja.md +89 -17
  5. data/NEWS.md +92 -0
  6. data/README.md +1 -1
  7. data/Rakefile +0 -13
  8. data/bin/review-catalog-converter +83 -37
  9. data/bin/review-check +17 -5
  10. data/bin/review-compile +1 -1
  11. data/bin/review-index +6 -0
  12. data/bin/review-init +3 -155
  13. data/bin/review-preproc +0 -5
  14. data/bin/review-validate +21 -7
  15. data/bin/review-vol +13 -5
  16. data/doc/config.yml.sample +12 -7
  17. data/doc/config.yml.sample-simple +1 -1
  18. data/doc/format.ja.md +39 -3
  19. data/doc/format.md +39 -3
  20. data/doc/format_idg.ja.md +0 -4
  21. data/doc/pdfmaker.ja.md +1 -1
  22. data/doc/pdfmaker.md +1 -1
  23. data/doc/sample.css +7 -0
  24. data/lib/epubmaker/content.rb +31 -12
  25. data/lib/epubmaker/epubcommon.rb +10 -3
  26. data/lib/epubmaker/epubv2.rb +11 -3
  27. data/lib/epubmaker/epubv3.rb +11 -3
  28. data/lib/epubmaker/producer.rb +55 -20
  29. data/lib/review/book/base.rb +63 -48
  30. data/lib/review/book/chapter.rb +19 -7
  31. data/lib/review/book/compilable.rb +5 -20
  32. data/lib/review/book/image_finder.rb +10 -3
  33. data/lib/review/book/index.rb +30 -9
  34. data/lib/review/book/part.rb +9 -6
  35. data/lib/review/book.rb +0 -14
  36. data/lib/review/builder.rb +110 -18
  37. data/lib/review/catalog.rb +24 -4
  38. data/lib/review/compiler.rb +3 -1
  39. data/lib/review/configure.rb +43 -9
  40. data/lib/review/epubmaker/reviewheaderlistener.rb +57 -0
  41. data/lib/review/epubmaker.rb +129 -85
  42. data/lib/review/htmlbuilder.rb +76 -58
  43. data/lib/review/htmlutils.rb +20 -13
  44. data/lib/review/i18n.rb +6 -2
  45. data/lib/review/idgxmlbuilder.rb +52 -41
  46. data/lib/review/init.rb +194 -0
  47. data/lib/review/latexbuilder.rb +118 -34
  48. data/lib/review/latexutils.rb +5 -5
  49. data/lib/review/logger.rb +2 -1
  50. data/lib/review/makerhelper.rb +1 -1
  51. data/lib/review/markdownbuilder.rb +66 -6
  52. data/lib/review/md2inaobuilder.rb +2 -2
  53. data/lib/review/pdfmaker.rb +74 -22
  54. data/lib/review/plaintextbuilder.rb +8 -4
  55. data/lib/review/preprocessor.rb +14 -17
  56. data/lib/review/sec_counter.rb +8 -2
  57. data/lib/review/textmaker.rb +2 -2
  58. data/lib/review/textutils.rb +9 -2
  59. data/lib/review/tocparser.rb +7 -4
  60. data/lib/review/tocprinter.rb +3 -1
  61. data/lib/review/version.rb +1 -1
  62. data/lib/review/webmaker.rb +19 -7
  63. data/lib/review/webtocprinter.rb +8 -4
  64. data/review.gemspec +4 -3
  65. data/templates/latex/config.erb +84 -0
  66. data/templates/latex/layout.tex.erb +76 -361
  67. data/templates/latex/review-jlreq/README.md +22 -0
  68. data/templates/latex/review-jlreq/review-base.sty +178 -0
  69. data/templates/latex/review-jlreq/review-custom.sty +1 -0
  70. data/templates/latex/review-jlreq/review-jlreq.cls +141 -0
  71. data/templates/latex/review-jlreq/review-style.sty +149 -0
  72. data/templates/latex/review-jlreq/reviewmacro.sty +8 -0
  73. data/templates/latex/review-jsbook/jumoline.sty +310 -0
  74. data/templates/latex/review-jsbook/plistings.sty +326 -0
  75. data/templates/latex/review-jsbook/review-base.sty +405 -0
  76. data/templates/latex/review-jsbook/review-custom.sty +1 -0
  77. data/templates/latex/review-jsbook/review-style.sty +38 -0
  78. data/templates/latex/review-jsbook/reviewmacro.sty +8 -0
  79. data/templates/latex-compat2/layout.tex.erb +387 -0
  80. data/test/assets/test_template.tex +105 -235
  81. data/test/assets/test_template_backmatter.tex +133 -14
  82. data/test/book_test_helper.rb +1 -1
  83. data/test/run_test.rb +2 -0
  84. data/test/sample-book/src/Rakefile +11 -6
  85. data/test/sample-book/src/config.yml +2 -2
  86. data/test/sample-book/src/sty/reviewmacro.sty +1 -39
  87. data/test/sample-book/src/style.css +6 -0
  88. data/test/syntax-book/config.yml +1 -1
  89. data/test/test_book.rb +13 -16
  90. data/test/test_book_chapter.rb +4 -10
  91. data/test/test_book_part.rb +4 -3
  92. data/test/test_catalog.rb +15 -4
  93. data/test/test_helper.rb +2 -2
  94. data/test/test_htmlbuilder.rb +78 -10
  95. data/test/test_htmlutils.rb +12 -5
  96. data/test/test_idgxmlbuilder.rb +1 -1
  97. data/test/test_latexbuilder.rb +94 -49
  98. data/test/test_latexbuilder_v2.rb +1077 -0
  99. data/test/test_logger.rb +20 -0
  100. data/test/test_markdownbuilder.rb +10 -0
  101. data/test/test_pdfmaker.rb +6 -7
  102. data/test/test_plaintextbuilder.rb +1 -1
  103. data/test/test_review_ext.rb +0 -1
  104. data/test/test_rstbuilder.rb +1 -1
  105. data/test/test_topbuilder.rb +19 -7
  106. data/test/test_webtocprinter.rb +14 -14
  107. data/{test/sample-book/src/vendor → vendor}/jumoline/README +0 -0
  108. data/{test/sample-book/src/vendor → vendor}/jumoline/jumoline.dtx +0 -0
  109. data/{test/sample-book/src/vendor → vendor}/jumoline/jumoline.ins +0 -0
  110. data/{test/sample-book/src/vendor → vendor}/jumoline/lppl.txt +0 -0
  111. data/vendor/plistings/.gitignore +9 -0
  112. data/vendor/plistings/LICENSE +21 -0
  113. data/vendor/plistings/README.md +18 -0
  114. data/vendor/plistings/plistings.sty +326 -0
  115. data/vendor/plistings/test1.tex +174 -0
  116. data/vendor/plistings/test2.tex +54 -0
  117. metadata +48 -19
  118. data/lib/review/unfold.rb +0 -129
  119. data/test/CHAPS +0 -2
  120. data/test/bib.re +0 -13
  121. data/test/test.re +0 -43
@@ -0,0 +1,326 @@
1
+ %
2
+ % plistings.sty
3
+ %
4
+ % lltjp-listings.sty ベース,コード未整理
5
+
6
+ \NeedsTeXFormat{LaTeX2e}
7
+ \ProvidesPackage{plistings}[2015/12/07 v0.10 Japanese support of listings package]
8
+
9
+ %%%%%%%% Package options
10
+ \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{listings}}
11
+ \ProcessOptions\relax
12
+ \RequirePackage{listings,etoolbox}
13
+
14
+ %%%%%%%% Japanese support
15
+ %% whether letter-space in a fixed mode box is doubled or not
16
+ \newif\if@ltj@lst@double
17
+ \lst@Key{doubleletterspace}f[t]{\lstKV@SetIf{#1}\if@ltj@lst@double}
18
+
19
+ % override \lst@FillFixed@
20
+ \def\lst@FillFixed@#1{%
21
+ \ifx\@empty#1\else\ltj@lst@hss#1\expandafter\lst@FillFixed@\fi}
22
+ \def\ltj@lst@hss@double{\lst@hss\lst@hss}
23
+
24
+ % 最下層の処理
25
+ \newif\if@ltj@lst@kanji
26
+ \lst@AddToHook{InitVars}{\@ltj@lst@kanjifalse}
27
+
28
+ \def\lst@AppendLetter{%
29
+ \ltj@lst@setletterflag\lst@Append}
30
+ \def\lst@AppendOther{%
31
+ \lst@ifletter\lst@Output\lst@letterfalse\fi\@ltj@lst@kanjifalse
32
+ \futurelet\lst@lastother\lst@Append}
33
+
34
+ \def\ltj@lst@setletterflag{%
35
+ \lst@ifletter
36
+ \if@ltj@lst@kanji\lst@Output\@ltj@lst@kanjifalse\fi
37
+ \else
38
+ \lst@lettertrue\if@ltj@lst@kanji\@ltj@lst@kanjifalse\else\lst@OutputOther\fi
39
+ \fi}
40
+
41
+ \def\ltj@lst@setkanjiflag{%
42
+ \lst@ifletter
43
+ \lst@Output
44
+ \else
45
+ \if@ltj@lst@kanji\else\lst@OutputOther\fi\lst@lettertrue
46
+ \fi\@ltj@lst@kanjitrue}
47
+
48
+ \def\ltj@lst@setopenflag{%
49
+ \lst@ifletter
50
+ \lst@letterfalse\lst@Output
51
+ \else
52
+ \if@ltj@lst@kanji\else\lst@OutputOther\fi
53
+ \fi\@ltj@lst@kanjitrue}
54
+
55
+ \def\ltj@lst@setcloseflag{%
56
+ \lst@ifletter\else\lst@lettertrue\fi\@ltj@lst@kanjitrue}
57
+
58
+ %%%% 和文文字の出力命令.
59
+ %%%% 和文文字の前にこれが前置されることになる.
60
+ \def\ltj@lst@ProcessJALetter#1{%
61
+ \lst@whitespacefalse
62
+ \ifnum`#1>255
63
+ \ifnum\postbreakpenalty`#1>0
64
+ \ltj@lst@setopenflag % 開き括弧類
65
+ \else
66
+ \ifnum\prebreakpenalty`#1>0
67
+ \ltj@lst@setcloseflag % 閉じ括弧類,句読点
68
+ \else
69
+ \ltj@lst@setkanjiflag % 通常の和文文字
70
+ \fi\fi
71
+ \advance\lst@length\@ne % 和文文字は通常の2倍の幅
72
+ \else
73
+ \ltj@lst@setletterflag
74
+ \fi
75
+ \lst@Append#1}
76
+
77
+
78
+ %%%% \lst@InsideConvert の処理内容変更
79
+ %%%% active 文字化に加え,^^@ を和文文字の前に前置
80
+ \def\ltj@lst@MakeActive#1{%
81
+ \let\lst@temp\@empty \ltj@lst@MakeActive@#1\relax}
82
+ \begingroup
83
+ \catcode`\^^A=\active
84
+ \catcode`\^^@=\active
85
+ \lowercase{%
86
+ \gdef\ltj@lst@MakeActive@#1{\let\lst@next\relax%
87
+ \ifx#1\relax
88
+ \else\let\lst@next\ltj@lst@MakeActive@
89
+ \ifnum`#1>255
90
+ \lst@lAddTo\lst@temp{^^@#1}%
91
+ \else
92
+ \lccode`\^^A=`#1
93
+ \lowercase{\lst@lAddTo\lst@temp{^^A}}%
94
+ \fi\fi\lst@next}}
95
+ \endgroup
96
+ \begingroup \lccode`\~=`\ \relax \lowercase{%
97
+ \gdef\lst@InsideConvert@#1 #2{%
98
+ \ltj@lst@MakeActive{#1}%
99
+ \ifx\@empty#2%
100
+ \lst@lExtend\lst@arg{\lst@temp}%
101
+ \else
102
+ \lst@lExtend\lst@arg{\lst@temp~}%
103
+ \expandafter\lst@InsideConvert@
104
+ \fi #2}
105
+ }\endgroup
106
+
107
+
108
+ %%%%%%%% \lstinline の再定義.
109
+ %%%% 引数を全部読み込み,\lst@InsideConvert で変換
110
+ \renewcommand\lstinline[1][]{%
111
+ \leavevmode\bgroup % \hbox\bgroup --> \bgroup
112
+ \def\lst@boxpos{b}%
113
+ \lsthk@PreSet\lstset{flexiblecolumns,#1}%
114
+ \lsthk@TextStyle
115
+ \@ifnextchar\bgroup \ltj@lst@InlineG \ltj@lstinline@}
116
+ \def\ltj@lstinline@#1{%
117
+ \edef\ltj@lst@temp{\the\catcode`#1}\lst@Init\relax\catcode`#1\ltj@lst@temp
118
+ \lst@Def{13}{\lst@DeInit\egroup \global\let\lst@inlinechars\@empty
119
+ \PackageError{Listings}{lstinline ended by EOL}\@ehc}%
120
+ \lst@InlineJ#1}
121
+ \def\ltj@lst@InlineG{%
122
+ \lst@Init\relax\edef\ltj@lst@temp{\the\catcode`\}}%
123
+ \catcode`\}=2 \catcode`\ =12\relax
124
+ \lst@Def{13}{\lst@DeInit\egroup \global\let\lst@inlinechars\@empty
125
+ \PackageError{Listings}{lstinline ended by EOL}\@ehc}%
126
+ \let\lst@arg\@empty\afterassignment\ltj@lst@InlineG@@\@temptokena}
127
+ \def\ltj@lst@InlineG@@{%
128
+ \catcode`\}=\ltj@lst@temp
129
+ \expandafter\expandafter\expandafter\lst@InsideConvert%
130
+ \expandafter{\the\@temptokena}\lst@arg\lst@DeInit\egroup}
131
+
132
+ %%%%%%%% \lstenv@process の再定義
133
+ %%%% 基本的にはインライン時と同様に全トークンを読み込み→\lst@InsideConvert で変換
134
+ %%%% その後,変換した中身は \scantokens で読み込み直される
135
+ \begingroup \lccode`\~=`\^^M\lowercase{%
136
+ \gdef\lstenv@Process#1{%
137
+ \ifx~#1%
138
+ \lstenv@DroppedWarning \let\lst@next\ltj@lstenv@ProcessM
139
+ \else\ifx^^J#1%
140
+ \lstenv@DroppedWarning \let\lst@next\lstenv@ProcessJ
141
+ \else
142
+ \let\lst@dropped#1\let\lst@next\lstenv@Process
143
+ \fi \fi
144
+ \lst@next}
145
+ }\endgroup
146
+ \begingroup\lccode`\[=`\{\lccode`\]=`\}\lccode`|=`\\\lowercase{%
147
+ \gdef\ltj@lstenv@ProcessM{%
148
+ \let\lst@arg\@empty
149
+ \edef\lst@temp{|end[\lstenv@name]}%
150
+ \expandafter\expandafter\expandafter\lst@InsideConvert%
151
+ \expandafter{\lst@temp}%
152
+ \@temptokena{%
153
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
154
+ \lst@SkipToFirst\expandafter\expandafter\expandafter\scantokens\expandafter{\lst@arg}%
155
+ }
156
+ \expandafter\expandafter\expandafter\toks@\expandafter{\lst@arg}
157
+ \expandafter\edef\expandafter\lst@temp\expandafter##\expandafter1\lst@arg
158
+ {%
159
+ \noexpand\let\noexpand\lst@arg\noexpand\@empty%
160
+ \noexpand\lst@InsideConvert{\noexpand##1}
161
+ \the\@temptokena\the\toks@
162
+ }%
163
+ \lst@temp}
164
+ }\endgroup
165
+
166
+ \def\lst@BeginDropInput#1{%
167
+ \lst@EnterMode{#1}%
168
+ {\lst@modetrue
169
+ \let\lst@OutputBox\@gobble
170
+ \let\lst@ifdropinput\iftrue
171
+ \let\lst@ProcessLetter\@gobble
172
+ \let\lst@ProcessDigit\@gobble
173
+ \let\lst@ProcessOther\@gobble
174
+ \let\lst@ProcessSpace\@empty
175
+ \let\lst@ProcessTabulator\@empty
176
+ \let\lst@ProcessFormFeed\@empty
177
+ \let\ltj@lst@ProcessJALetter\@gobble % added
178
+ }}
179
+
180
+
181
+ %%%% ^^@ を active 文字化 (\ltj@lst@ProcessJALetter)
182
+ \begingroup\catcode`\^^@=\active
183
+ \lst@AddTo\lst@SelectStdCharTable{\def^^@{\ltj@lst@ProcessJALetter}}
184
+ \endgroup
185
+ \lst@AddToHook{InitVars}{%
186
+ \catcode`\^^@=\active
187
+ \if@ltj@lst@double
188
+ \let\ltj@lst@hss=\ltj@lst@hss@double
189
+ \else
190
+ \let\ltj@lst@hss=\lst@hss
191
+ \fi
192
+ }
193
+
194
+ %%%% 白線対策のため,\lineskiplimit を負の値にする
195
+ \newif\ifltj@lst@frame@top
196
+ \newdimen\ltj@lst@frame@lslimit
197
+ \gdef\lst@frameInit{%
198
+ \ltj@lst@frame@toptrue
199
+ \ifx\lst@framelshape\@empty \let\lst@frameL\@empty \fi
200
+ \ifx\lst@framershape\@empty \let\lst@frameR\@empty \fi
201
+ \def\lst@framevrule{\vrule\@width\lst@framerulewidth\relax}%
202
+ \lst@ifframeround
203
+ \lst@frameCalcDimA\z@ \@getcirc\@tempdima
204
+ \@tempdimb\@tempdima \divide\@tempdimb\tw@
205
+ \advance\@tempdimb -\@wholewidth
206
+ \edef\lst@frametextsep{\the\@tempdimb}%
207
+ \edef\lst@framerulewidth{\the\@wholewidth}%
208
+ \lst@frameCalcDimA\@ne \@getcirc\@tempdima
209
+ \@tempdimb\@tempdima \divide\@tempdimb\tw@
210
+ \advance\@tempdimb -\tw@\@wholewidth
211
+ \advance\@tempdimb -\lst@frametextsep
212
+ \edef\lst@rulesep{\the\@tempdimb}%
213
+ \fi
214
+ \lst@frameMakeBoxV\lst@framebox{\ht\strutbox}{\dp\strutbox}%
215
+ %%%% ここから
216
+ \@tempdima\z@
217
+ \ifdim\ht\strutbox<\cht\@tempdima=\dimexpr\cht-\ht\strutbox\relax\fi
218
+ \ifdim\dp\strutbox<\cdp\advance\@tempdima=\dimexpr\cdp-\dp\strutbox\relax\fi
219
+ \ltj@lst@frame@lslimit=-\@tempdima
220
+ \def\lst@framelr{%
221
+ \ifltj@lst@frame@top\ltj@lst@frame@topfalse\else\lineskiplimit\ltj@lst@frame@lslimit\fi
222
+ \copy\lst@framebox}%
223
+ %%%% ここまで
224
+ \ifx\lst@frametshape\@empty\else
225
+ \lst@frameH T\lst@frametshape
226
+ \ifvoid\z@\else
227
+ \par\lst@parshape
228
+ \@tempdima-\baselineskip \advance\@tempdima\ht\z@
229
+ \ifdim\prevdepth<\@cclvi\p@\else
230
+ \advance\@tempdima\prevdepth
231
+ \fi
232
+ \ifdim\@tempdima<\z@
233
+ \vskip\@tempdima\vskip\lineskip
234
+ \fi
235
+ \noindent\box\z@\par
236
+ \lineskiplimit\maxdimen \lineskip\z@
237
+ \fi
238
+ \lst@frameSpreadV\lst@framextopmargin
239
+ \fi}
240
+
241
+ % lstinputlisting
242
+ % modified from jlisting.sty
243
+ \def\lst@InputListing#1{%
244
+ \begingroup
245
+ \lsthk@PreSet \gdef\lst@intname{#1}%
246
+ \expandafter\lstset\expandafter{\lst@set}%
247
+ \lsthk@DisplayStyle
248
+ \catcode\active=\active
249
+ \lst@Init\relax \let\lst@gobble\z@
250
+ \lst@SkipToFirst
251
+ \lst@ifprint \def\lst@next{\lst@get@filecontents{#1}}%
252
+ \else \let\lst@next\@empty
253
+ \fi
254
+ \lst@next
255
+ \lst@DeInit
256
+ \endgroup}
257
+ \newread\lst@inputfile
258
+ \def\lst@get@filecontents#1{%
259
+ \let\lst@filecontents\@empty
260
+ \openin\lst@inputfile=#1\relax
261
+ \let\@lst@get@filecontents@prevline\relax
262
+ \lst@get@filecontents@loop
263
+ \closein\lst@inputfile
264
+ \lst@filecontents\empty}
265
+ \def\lst@get@filecontents@loop{%
266
+ \read\lst@inputfile to\lst@temp
267
+ \let\lst@arg\@empty\expandafter\expandafter\expandafter\lst@InsideConvert\expandafter{\lst@temp}%
268
+ \ifx\@lst@get@filecontents@prevline\relax\else
269
+ \expandafter\expandafter\expandafter\def
270
+ \expandafter\expandafter\expandafter\lst@filecontents
271
+ \expandafter\expandafter\expandafter{%
272
+ \expandafter\lst@filecontents\@lst@get@filecontents@prevline}%
273
+ \fi
274
+ \let\@lst@get@filecontents@prevline\lst@arg
275
+ \ifeof\lst@inputfile\else
276
+ \expandafter\lst@get@filecontents@loop
277
+ \fi}
278
+
279
+ %%%%%%%% escape to \LaTeX
280
+ %%%% 一旦中身を全部取得した後で,^^@ ( = \ltj@lst@ProcessJALetter) を
281
+ %%%% トークン列から削除,その後 \scantokens で再読み込み
282
+ \lstloadaspects{escape}
283
+ \gdef\lst@Escape#1#2#3#4{%
284
+ \lst@CArgX #1\relax\lst@CDefX
285
+ {}%
286
+ {\lst@ifdropinput\else
287
+ \lst@TrackNewLines\lst@OutputLostSpace \lst@XPrintToken
288
+ \lst@InterruptModes
289
+ \lst@EnterMode{\lst@TeXmode}{\lst@modetrue}%
290
+ \ifx\^^M#2%
291
+ \lst@CArg #2\relax\lst@ActiveCDefX
292
+ {}%
293
+ {\lst@escapeend #4\lst@LeaveAllModes\lst@ReenterModes}%
294
+ {\ltj@lst@MProcessListing}%
295
+ \else
296
+ \lst@CArg #2\relax\lst@ActiveCDefX
297
+ {}%
298
+ {\lst@escapeend #4\lst@LeaveAllModes\lst@ReenterModes
299
+ \lst@newlines\z@ \lst@whitespacefalse}%
300
+ {}%
301
+ \fi%
302
+ \ltj@lst@escape@setup#2
303
+ #3\lst@escapebegin\expandafter\lst@next%
304
+ \fi}%
305
+ {}}
306
+ \def\ltj@lst@escape@setup#1{%
307
+ \begingroup\lccode`\~=`#1\lowercase{%
308
+ \gdef\lst@next##1~{%
309
+ \let\lst@arg\@empty\ltj@lst@remove@jacmd{##1}%
310
+ \expandafter\expandafter\expandafter\scantokens\expandafter{\lst@arg}%
311
+ ~}%
312
+ }\endgroup
313
+ }
314
+
315
+ \begingroup
316
+ \catcode`\^^@=12 %
317
+ \gdef\ltj@lst@remove@jacmd#1{%
318
+ \expandafter\ltj@lst@remove@jacmd@\detokenize{#1}^^@\@nil^^@}
319
+ \gdef\ltj@lst@remove@jacmd@#1^^@{%
320
+ \ifx#1\@nil\else
321
+ \lst@lAddTo\lst@arg{#1}%
322
+ \expandafter\ltj@lst@remove@jacmd@
323
+ \fi}
324
+ \endgroup
325
+
326
+ \endinput