tmtms-review 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +9 -0
  3. data/COPYING +515 -0
  4. data/ChangeLog +2083 -0
  5. data/README.rdoc +50 -0
  6. data/Rakefile +56 -0
  7. data/VERSION +1 -0
  8. data/bin/review-check +178 -0
  9. data/bin/review-checkdep +63 -0
  10. data/bin/review-compile +205 -0
  11. data/bin/review-epubmaker +661 -0
  12. data/bin/review-epubmaker-ng +176 -0
  13. data/bin/review-index +118 -0
  14. data/bin/review-pdfmaker +208 -0
  15. data/bin/review-preproc +142 -0
  16. data/bin/review-validate +51 -0
  17. data/bin/review-vol +102 -0
  18. data/debian/README.Debian +12 -0
  19. data/debian/README.source +5 -0
  20. data/debian/changelog +5 -0
  21. data/debian/compat +1 -0
  22. data/debian/control +22 -0
  23. data/debian/copyright +62 -0
  24. data/debian/docs +6 -0
  25. data/debian/manpage.1.ex +59 -0
  26. data/debian/patches/path.diff +91 -0
  27. data/debian/patches/series +1 -0
  28. data/debian/review.install +13 -0
  29. data/debian/review.links +4 -0
  30. data/debian/rules +13 -0
  31. data/debian/source/format +1 -0
  32. data/doc/format.rdoc +582 -0
  33. data/doc/format_idg.rdoc +180 -0
  34. data/doc/libepubmaker/sample.yaml +90 -0
  35. data/doc/quickstart.rdoc +188 -0
  36. data/doc/ruby-uuid/README +11 -0
  37. data/doc/ruby-uuid/README.ja +34 -0
  38. data/doc/sample.css +108 -0
  39. data/doc/sample.yaml +62 -0
  40. data/lib/epubmaker.rb +28 -0
  41. data/lib/epubmaker/content.rb +82 -0
  42. data/lib/epubmaker/epubv2.rb +418 -0
  43. data/lib/epubmaker/epubv3.rb +249 -0
  44. data/lib/epubmaker/producer.rb +204 -0
  45. data/lib/epubmaker/resource.rb +66 -0
  46. data/lib/lineinput.rb +155 -0
  47. data/lib/review.rb +3 -0
  48. data/lib/review/book.rb +46 -0
  49. data/lib/review/book/base.rb +235 -0
  50. data/lib/review/book/chapter.rb +81 -0
  51. data/lib/review/book/compilable.rb +159 -0
  52. data/lib/review/book/index.rb +339 -0
  53. data/lib/review/book/page_metric.rb +38 -0
  54. data/lib/review/book/parameters.rb +97 -0
  55. data/lib/review/book/part.rb +44 -0
  56. data/lib/review/book/volume.rb +65 -0
  57. data/lib/review/builder.rb +444 -0
  58. data/lib/review/compiler.rb +550 -0
  59. data/lib/review/configure.rb +38 -0
  60. data/lib/review/epubbuilder.rb +18 -0
  61. data/lib/review/exception.rb +21 -0
  62. data/lib/review/extentions.rb +3 -0
  63. data/lib/review/extentions/object.rb +9 -0
  64. data/lib/review/extentions/string.rb +33 -0
  65. data/lib/review/htmlbuilder.rb +1097 -0
  66. data/lib/review/htmllayout.rb +19 -0
  67. data/lib/review/htmlutils.rb +36 -0
  68. data/lib/review/i18n.rb +30 -0
  69. data/lib/review/i18n.yaml +34 -0
  70. data/lib/review/idgxmlbuilder.rb +1145 -0
  71. data/lib/review/latexbuilder.rb +815 -0
  72. data/lib/review/latexindex.rb +35 -0
  73. data/lib/review/latexutils.rb +79 -0
  74. data/lib/review/preprocessor.rb +563 -0
  75. data/lib/review/review.tex.erb +232 -0
  76. data/lib/review/textbuilder.rb +17 -0
  77. data/lib/review/textutils.rb +66 -0
  78. data/lib/review/tocparser.rb +342 -0
  79. data/lib/review/tocprinter.rb +221 -0
  80. data/lib/review/topbuilder.rb +785 -0
  81. data/lib/review/unfold.rb +138 -0
  82. data/lib/uuid.rb +312 -0
  83. data/review.gemspec +141 -0
  84. data/test/CHAPS +2 -0
  85. data/test/bib.re +13 -0
  86. data/test/book_test_helper.rb +35 -0
  87. data/test/test.re +43 -0
  88. data/test/test_book.rb +598 -0
  89. data/test/test_book_chapter.rb +418 -0
  90. data/test/test_book_parameter.rb +42 -0
  91. data/test/test_book_part.rb +50 -0
  92. data/test/test_builder.rb +144 -0
  93. data/test/test_compiler.rb +44 -0
  94. data/test/test_epubmaker.rb +507 -0
  95. data/test/test_helper.rb +27 -0
  96. data/test/test_htmlbuilder.rb +554 -0
  97. data/test/test_htmlutils.rb +28 -0
  98. data/test/test_i18n.rb +64 -0
  99. data/test/test_idgxmlbuilder.rb +589 -0
  100. data/test/test_index.rb +31 -0
  101. data/test/test_latexbuilder.rb +656 -0
  102. data/test/test_lineinput.rb +198 -0
  103. data/test/test_preprocessor.rb +23 -0
  104. data/test/test_textutils.rb +68 -0
  105. data/test/test_topbuilder.rb +244 -0
  106. data/test/test_uuid.rb +156 -0
  107. metadata +161 -0
@@ -0,0 +1,221 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # $Id: tocprinter.rb 4309 2009-07-19 04:15:02Z aamine $
4
+ #
5
+ # Copyright (c) 2002-2007 Minero Aoki
6
+ # 2008-2009 Minero Aoki, Kenshi Muto
7
+ #
8
+ # This program is free software.
9
+ # You can distribute or modify this program under the terms of
10
+ # the GNU LGPL, Lesser General Public License version 2.1.
11
+ # For details of LGPL, see the file "COPYING".
12
+ #
13
+
14
+ require 'review/htmlutils'
15
+ require 'review/htmllayout'
16
+ require 'nkf'
17
+
18
+ module ReVIEW
19
+
20
+ class TOCPrinter
21
+
22
+ def TOCPrinter.default_upper_level
23
+ 99 # no one use 99 level nest
24
+ end
25
+
26
+ def initialize(print_upper, param)
27
+ @print_upper = print_upper
28
+ @param = param
29
+ end
30
+
31
+ def print?(level)
32
+ level <= @print_upper
33
+ end
34
+
35
+ def nkffilter(line)
36
+ inc = ""
37
+ outc = "-w"
38
+ if @param["inencoding"] =~ /^EUC$/
39
+ inc = "-E"
40
+ elsif @param["inencoding"] =~ /^SJIS$/
41
+ inc = "-S"
42
+ elsif @param["inencoding"] =~ /^JIS$/
43
+ inc = "-J"
44
+ end
45
+
46
+ if @param["outencoding"] =~ /^EUC$/
47
+ outc = "-e"
48
+ elsif @param["outencoding"] =~ /^SJIS$/
49
+ outc = "-s"
50
+ elsif @param["outencoding"] =~ /^JIS$/
51
+ outc = "-j"
52
+ end
53
+
54
+ NKF.nkf("#{inc} #{outc}", line)
55
+ end
56
+ end
57
+
58
+
59
+ class TextTOCPrinter < TOCPrinter
60
+ def print_book(book)
61
+ print_children book
62
+ end
63
+
64
+ private
65
+
66
+ def print_children(node)
67
+ return unless print?(node.level + 1)
68
+ node.each_section_with_index do |section, idx|
69
+ print_node idx+1, section
70
+ print_children section
71
+ end
72
+ end
73
+
74
+ def print_node(number, node)
75
+ if node.chapter?
76
+ vol = node.volume
77
+ printf "%3s %3dKB %6dC %5dL %s (%s)\n",
78
+ chapnumstr(node.number),
79
+ vol.kbytes, vol.chars, vol.lines,
80
+ nkffilter(node.label), node.chapter_id
81
+ else
82
+ printf "%17s %5dL %s\n",
83
+ '', node.estimated_lines,
84
+ nkffilter(" #{' ' * (node.level - 1)}#{number} #{node.label}")
85
+ end
86
+ end
87
+
88
+ def chapnumstr(n)
89
+ n ? sprintf('%2d.', n) : ' '
90
+ end
91
+
92
+ def volume_columns(level, volstr)
93
+ cols = ["", "", "", nil]
94
+ cols[level - 1] = volstr
95
+ cols[0, 3] # does not display volume of level-4 section
96
+ end
97
+
98
+ end
99
+
100
+
101
+ class HTMLTOCPrinter < TOCPrinter
102
+
103
+ include HTMLUtils
104
+
105
+ def print_book(book)
106
+ return unless print?(1)
107
+ html = ""
108
+ book.each_part do |part|
109
+ html << h1(part.name) if part.name
110
+ part.each_section do |chap|
111
+ if chap.number
112
+ name = "chap#{chap.number}"
113
+ label = "第#{chap.number}章 #{chap.label}"
114
+ html << h2(a_name(escape_html(name), escape_html(label)))
115
+ else
116
+ label = "#{chap.label}"
117
+ html << h2(escape_html(label))
118
+ end
119
+ return unless print?(2)
120
+ if print?(3)
121
+ html << chap_sections_to_s(chap)
122
+ else
123
+ html << chapter_to_s(chap)
124
+ end
125
+ end
126
+ end
127
+ puts HTMLLayout.new(html, "目次", File.join(book.basedir, "layouts", "layout.erb")).result
128
+ end
129
+
130
+ private
131
+
132
+ def chap_sections_to_s(chap)
133
+ res = []
134
+ res << "<ol>"
135
+ chap.each_section do |sec|
136
+ res << li(escape_html(sec.label))
137
+ end
138
+ res << "</ol>"
139
+ return res.join("\n")
140
+ end
141
+
142
+ def print_chapter_to_s(chap)
143
+ res = []
144
+ chap.each_section do |sec|
145
+ res << h3(escape_html(sec.label))
146
+ next unless print?(4)
147
+ next if sec.n_sections == 0
148
+ res << "<ul>"
149
+ sec.each_section do |node|
150
+ res << li(escape_html(node.label))
151
+ end
152
+ res << "</ul>"
153
+ end
154
+ return res.join("\n")
155
+ end
156
+
157
+ def h1(label)
158
+ "<h1>#{label}</h1>"
159
+ end
160
+
161
+ def h2(label)
162
+ "<h2>#{label}</h2>"
163
+ end
164
+
165
+ def h3(label)
166
+ "<h3>#{label}</h3>"
167
+ end
168
+
169
+ def li(content)
170
+ "<li>#{content}</li>"
171
+ end
172
+
173
+ def a_name(name, label)
174
+ %Q(<a name="#{name}">#{label}</a>)
175
+ end
176
+
177
+ end
178
+
179
+ class IDGTOCPrinter < TOCPrinter
180
+ def print_book(book)
181
+ puts %Q(<?xml version="1.0" encoding="UTF-8"?>)
182
+ puts nkffilter(%Q(<doc xmlns:aid='http://ns.adobe.com/AdobeInDesign/4.0/'><title aid:pstyle="h0">1 パート1</title><?dtp level="0" section="第1部 パート1"?>)) # FIXME: 部タイトルを取るには? & 部ごとに結果を分けるには?
183
+ puts %Q(<ul aid:pstyle='ul-partblock'>)
184
+ print_children book
185
+ puts %Q(</ul></doc>)
186
+ end
187
+
188
+ private
189
+
190
+ def print_children(node)
191
+ return unless print?(node.level + 1)
192
+ node.each_section_with_index do |sec, idx|
193
+ print_node idx+1, sec
194
+ print_children sec
195
+ end
196
+ end
197
+
198
+ LABEL_LEN = 54
199
+
200
+ def print_node(seq, node)
201
+ if node.chapter?
202
+ vol = node.volume
203
+ printf "<li aid:pstyle='ul-part'>%s</li>\n",
204
+ nkffilter("#{chapnumstr(node.number)}#{node.label}")
205
+ else
206
+ printf "<li>%-#{LABEL_LEN}s\n",
207
+ nkffilter(" #{' ' * (node.level - 1)}#{seq} #{node.label}</li>")
208
+ end
209
+ end
210
+
211
+ def chapnumstr(n)
212
+ n ? nkffilter(sprintf('第%d章 ', n)) : ''
213
+ end
214
+
215
+ def volume_columns(level, volstr)
216
+ cols = ["", "", "", nil]
217
+ cols[level - 1] = volstr
218
+ cols[0, 3]
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,785 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2002-2006 Minero Aoki
4
+ # 2008-2010 Minero Aoki, Kenshi Muto
5
+ #
6
+ # This program is free software.
7
+ # You can distribute or modify this program under the terms of
8
+ # the GNU LGPL, Lesser General Public License version 2.1.
9
+ #
10
+
11
+ require 'review/builder'
12
+ require 'review/textutils'
13
+
14
+ module ReVIEW
15
+
16
+ class TOPBuilder < Builder
17
+
18
+ include TextUtils
19
+
20
+ [:ttbold, :hint, :maru, :keytop, :labelref, :ref, :pageref, :balloon].each {|e|
21
+ Compiler.definline(e)
22
+ }
23
+ Compiler.defsingle(:dtp, 1)
24
+
25
+ Compiler.defblock(:insn, 1)
26
+ Compiler.defblock(:memo, 0..1)
27
+ Compiler.defblock(:tip, 0..1)
28
+ Compiler.defblock(:info, 0..1)
29
+ Compiler.defblock(:planning, 0..1)
30
+ Compiler.defblock(:best, 0..1)
31
+ Compiler.defblock(:important, 0..1)
32
+ Compiler.defblock(:securty, 0..1)
33
+ Compiler.defblock(:caution, 0..1)
34
+ Compiler.defblock(:notice, 0..1)
35
+ Compiler.defblock(:point, 0..1)
36
+ Compiler.defblock(:reference, 0)
37
+ Compiler.defblock(:term, 0)
38
+ Compiler.defblock(:practice, 0)
39
+ Compiler.defblock(:expert, 0)
40
+
41
+ def pre_paragraph
42
+ ''
43
+ end
44
+
45
+ def post_paragraph
46
+ ''
47
+ end
48
+
49
+ def extname
50
+ '.txt'
51
+ end
52
+
53
+ def builder_init_file
54
+ @section = 0
55
+ @subsection = 0
56
+ @subsubsection = 0
57
+ @subsubsubsection = 0
58
+ @blank_seen = true
59
+
60
+ @titles = {
61
+ "emlist" => "インラインリスト",
62
+ "cmd" => "コマンド",
63
+ "quote" => "引用",
64
+ "centering" => "中央揃え",
65
+ "flushright" => "右寄せ",
66
+ "note" => "ノート",
67
+ "memo" => "メモ",
68
+ "important" => "重要",
69
+ "info" => "情報",
70
+ "planning" => "プランニング",
71
+ "shoot" => "トラブルシュート",
72
+ "term" => "用語解説",
73
+ "notice" => "注意",
74
+ "caution" => "警告",
75
+ "point" => "ここがポイント",
76
+ "reference" => "参考",
77
+ "link" => "リンク",
78
+ "best" => "ベストプラクティス",
79
+ "practice" => "練習問題",
80
+ "security" => "セキュリティ",
81
+ "expert" => "エキスパートに訊け",
82
+ "tip" => "TIP",
83
+ "box" => "書式",
84
+ "insn" => "書式",
85
+ "column" => "コラム",
86
+ "xcolumn" => "コラムパターン2",
87
+ "world" => "Worldコラム",
88
+ "hood" => "Under The Hoodコラム",
89
+ "edition" => "Editionコラム",
90
+ "insideout" => "InSideOutコラム",
91
+ "ref" => "参照",
92
+ "sup" => "補足",
93
+ "read" => "リード",
94
+ "lead" => "リード",
95
+ "list" => "リスト",
96
+ "image" => "図",
97
+ "texequation" => "TeX式",
98
+ "table" => "表",
99
+ "bpo" => "bpo",
100
+ "source" => "ソースコードリスト",
101
+ }
102
+ end
103
+ private :builder_init_file
104
+
105
+ def print(s)
106
+ @blank_seen = false
107
+ super
108
+ end
109
+ private :print
110
+
111
+ def puts(s)
112
+ @blank_seen = false
113
+ super
114
+ end
115
+ private :puts
116
+
117
+ def blank
118
+ @output.puts unless @blank_seen
119
+ @blank_seen = true
120
+ end
121
+ private :blank
122
+
123
+ def result
124
+ @output.string
125
+ end
126
+
127
+ def warn(msg)
128
+ $stderr.puts "#{@location.filename}:#{@location.lineno}: warning: #{msg}"
129
+ end
130
+
131
+ def error(msg)
132
+ $stderr.puts "#{@location.filename}:#{@location.lineno}: error: #{msg}"
133
+ end
134
+
135
+ def messages
136
+ error_messages() + warning_messages()
137
+ end
138
+
139
+ def headline(level, label, caption)
140
+ prefix = ""
141
+ blank
142
+ case level
143
+ when 1
144
+ if @chapter.number.to_s =~ /\A\d+\Z/
145
+ prefix = "第#{@chapter.number}章 "
146
+ elsif @chapter.number.present?
147
+ prefix = "#{@chapter.number} "
148
+ end
149
+ @section = 0
150
+ @subsection = 0
151
+ @subsubsection = 0
152
+ @subsubsubsection = 0
153
+ when 2
154
+ @section += 1
155
+ prefix = @chapter.number.present? ? "#{@chapter.number}.#{@section} " : ""
156
+ @subsection = 0
157
+ @subsubsection = 0
158
+ @subsubsubsection = 0
159
+ when 3
160
+ @subsection += 1
161
+ prefix = @chapter.number.present? ? "#{@chapter.number}.#{@section}.#{@subsection} " : ""
162
+ @subsubsection = 0
163
+ @subsubsubsection = 0
164
+ when 4
165
+ @subsubsection += 1
166
+ prefix = @chapter.number.present? ? "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection} " : ""
167
+ @subsubsubsection = 0
168
+ when 5
169
+ @subsubsubsection += 1
170
+ prefix = @chapter.number.present? ? "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection} " : ""
171
+ else
172
+ raise "caption level too deep or unsupported: #{level}"
173
+ end
174
+ prefix = "" if (level.to_i > ReVIEW.book.param["secnolevel"])
175
+ puts "■H#{level}■#{prefix}#{compile_inline(caption)}"
176
+ end
177
+
178
+ def ul_begin
179
+ blank
180
+ end
181
+
182
+ def ul_item(lines)
183
+ puts "●\t#{lines.join}"
184
+ end
185
+
186
+ def ul_end
187
+ blank
188
+ end
189
+
190
+ def ol_begin
191
+ blank
192
+ @olitem = 0
193
+ end
194
+
195
+ def ol_item(lines, num)
196
+ puts "#{num}\t#{lines.join}"
197
+ end
198
+
199
+ def ol_end
200
+ blank
201
+ @olitem = nil
202
+ end
203
+
204
+ def dl_begin
205
+ blank
206
+ end
207
+
208
+ def dt(line)
209
+ puts "★#{line}☆"
210
+ end
211
+
212
+ def dd(lines)
213
+ split_paragraph(lines).each do |paragraph|
214
+ puts "\t#{paragraph.gsub(/\n/, '')}"
215
+ end
216
+ end
217
+
218
+ def dl_end
219
+ blank
220
+ end
221
+
222
+ def paragraph(lines)
223
+ puts lines.join
224
+ end
225
+
226
+ def read(lines)
227
+ puts "◆→開始:#{@titles["lead"]}←◆"
228
+ puts split_paragraph(lines).join("\n")
229
+ puts "◆→終了:#{@titles["lead"]}←◆"
230
+ blank
231
+ end
232
+
233
+ alias :lead read
234
+
235
+ def inline_list(id)
236
+ chapter, id = extract_chapter_id(id)
237
+ if get_chap(chapter).nil?
238
+ %Q[#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [@chapter.list(id).number])}]
239
+ else
240
+ %Q[#{I18n.t("list")}#{I18n.t("format_number", [get_chap(chapter), @chapter.list(id).number])}]
241
+ end
242
+
243
+ end
244
+
245
+ def list_header(id, caption)
246
+ blank
247
+ puts "◆→開始:#{@titles["list"]}←◆"
248
+ if get_chap.nil?
249
+ puts %Q[#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}]
250
+ else
251
+ puts %Q[#{I18n.t("list")}#{I18n.t("format_number", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}]
252
+ end
253
+ blank
254
+ end
255
+
256
+ def list_body(lines)
257
+ lines.each do |line|
258
+ puts detab(line)
259
+ end
260
+ puts "◆→終了:#{@titles["list"]}←◆"
261
+ blank
262
+ end
263
+
264
+ def base_block(type, lines, caption = nil)
265
+ blank
266
+ puts "◆→開始:#{@titles[type]}←◆"
267
+ puts "■#{compile_inline(caption)}" unless caption.nil?
268
+ puts lines.join("\n")
269
+ puts "◆→終了:#{@titles[type]}←◆"
270
+ blank
271
+ end
272
+
273
+ def base_parablock(type, lines, caption = nil)
274
+ blank
275
+ puts "◆→開始:#{@titles[type]}←◆"
276
+ puts "■#{compile_inline(caption)}" unless caption.nil?
277
+ puts split_paragraph(lines).join("\n")
278
+ puts "◆→終了:#{@titles[type]}←◆"
279
+ blank
280
+ end
281
+
282
+ def emlist(lines, caption = nil)
283
+ base_block "emlist", lines, caption
284
+ end
285
+
286
+ def emlistnum(lines, caption = nil)
287
+ blank
288
+ puts "◆→開始:#{@titles["emlist"]}←◆"
289
+ puts "■#{compile_inline(caption)}" unless caption.nil?
290
+ _lines = []
291
+ lines.each_with_index do |line, i|
292
+ puts (i + 1).to_s.rjust(2) + ": #{line}"
293
+ end
294
+ puts "◆→終了:#{@titles["emlist"]}←◆"
295
+ blank
296
+ end
297
+
298
+ def listnum_body(lines)
299
+ lines.each_with_index do |line, i|
300
+ puts (i + 1).to_s.rjust(2) + ": #{line}"
301
+ end
302
+ puts "◆→終了:#{@titles["list"]}←◆"
303
+ blank
304
+ end
305
+
306
+ def cmd(lines, caption = nil)
307
+ base_block "cmd", lines, caption
308
+ end
309
+
310
+ def quote(lines)
311
+ base_parablock "quote", lines, nil
312
+ end
313
+
314
+ def inline_table(id)
315
+ chapter, id = extract_chapter_id(id)
316
+ if get_chap(chapter).nil?
317
+ "#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [chapter.table(id).number])}"
318
+ else
319
+ "#{I18n.t("table")}#{I18n.t("format_number", [get_chap(chapter), chapter.table(id).number])}"
320
+ end
321
+ end
322
+
323
+ def inline_img(id)
324
+ chapter, id = extract_chapter_id(id)
325
+ if get_chap(chapter).nil?
326
+ "#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}"
327
+ else
328
+ "#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}"
329
+ end
330
+ end
331
+
332
+ def image(lines, id, caption, metric=nil)
333
+ blank
334
+ puts "◆→開始:#{@titles["image"]}←◆"
335
+ if get_chap.nil?
336
+ puts "#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
337
+ else
338
+ puts "#{I18n.t("image")}#{I18n.t("format_number", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
339
+ end
340
+ blank
341
+ if @chapter.image(id).bound?
342
+ puts "◆→#{@chapter.image(id).path}←◆"
343
+ else
344
+ lines.each do |line|
345
+ puts line
346
+ end
347
+ end
348
+ puts "◆→終了:#{@titles["image"]}←◆"
349
+ blank
350
+ end
351
+
352
+ def texequation(lines)
353
+ puts "◆→開始:#{@titles["texequation"]}←◆"
354
+ puts "#{lines.join("\n")}"
355
+ puts "◆→終了:#{@titles["texequation"]}←◆"
356
+ blank
357
+ end
358
+
359
+ def table_header(id, caption)
360
+ blank
361
+ puts "◆→開始:#{@titles["table"]}←◆"
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
367
+ blank
368
+ end
369
+
370
+ def table_begin(ncols)
371
+ end
372
+
373
+ def tr(rows)
374
+ puts rows.join("\t")
375
+ end
376
+
377
+ def th(str)
378
+ "★#{str}☆"
379
+ end
380
+
381
+ def td(str)
382
+ str
383
+ end
384
+
385
+ def table_end
386
+ puts "◆→終了:#{@titles["table"]}←◆"
387
+ blank
388
+ end
389
+
390
+ def comment(str)
391
+ puts "◆→DTP連絡:#{str}←◆"
392
+ end
393
+
394
+ def footnote(id, str)
395
+ puts "【注#{@chapter.footnote(id).number}】#{compile_inline(str)}"
396
+ end
397
+
398
+ def inline_fn(id)
399
+ "【注#{@chapter.footnote(id).number}】"
400
+ end
401
+
402
+ def compile_ruby(base, ruby)
403
+ "#{base}◆→DTP連絡:「#{base}」に「#{ruby}」とルビ←◆"
404
+ end
405
+
406
+ def compile_kw(word, alt)
407
+ if alt
408
+ then "★#{word}☆(#{alt.strip})"
409
+ else "★#{word}☆"
410
+ end
411
+ end
412
+
413
+ def compile_href(url, label)
414
+ if label.nil?
415
+ %Q[△#{url}☆]
416
+ else
417
+ %Q[#{label}(△#{url}☆)]
418
+ end
419
+ end
420
+
421
+ def inline_sup(str)
422
+ "#{str}◆→DTP連絡:「#{str}」は上付き←◆"
423
+ end
424
+
425
+ def inline_sub(str)
426
+ "#{str}◆→DTP連絡:「#{str}」は下付き←◆"
427
+ end
428
+
429
+ def inline_raw(str)
430
+ %Q[#{super(str).gsub("\\n", "\n")}]
431
+ end
432
+
433
+ def inline_hint(str)
434
+ "◆→ヒントスタイルここから←◆#{str}◆→ヒントスタイルここまで←◆"
435
+ end
436
+
437
+ def inline_maru(str)
438
+ "#{str}◆→丸数字#{str}←◆"
439
+ end
440
+
441
+ def inline_idx(str)
442
+ "#{str}◆→索引項目:#{str}←◆"
443
+ end
444
+
445
+ def inline_hidx(str)
446
+ "◆→索引項目:#{str}←◆"
447
+ end
448
+
449
+ def inline_ami(str)
450
+ "#{str}◆→DTP連絡:「#{str}」に網カケ←◆"
451
+ end
452
+
453
+ def inline_i(str)
454
+ "▲#{str}☆"
455
+ end
456
+
457
+ def inline_b(str)
458
+ "★#{str}☆"
459
+ end
460
+
461
+ def inline_tt(str)
462
+ "△#{str}☆"
463
+ end
464
+
465
+ def inline_ttb(str)
466
+ "★#{str}☆◆→等幅フォント太字←◆"
467
+ end
468
+
469
+ alias :inline_ttbold inline_ttb
470
+
471
+ def inline_tti(str)
472
+ "▲#{str}☆◆→等幅フォントイタ←◆"
473
+ end
474
+
475
+ def inline_u(str)
476
+ "@#{str}@◆→@〜@部分に下線←◆"
477
+ end
478
+
479
+ def inline_icon(id)
480
+ begin
481
+ return "◆→画像 #{@chapter.image(id).path.sub(/\A\.\//, "")}←◆"
482
+ rescue
483
+ warn "no such icon image: #{id}"
484
+ return "◆→画像 #{id}←◆"
485
+ end
486
+ end
487
+
488
+ def inline_bou(str)
489
+ "#{str}◆→DTP連絡:「#{str}」に傍点←◆"
490
+ end
491
+
492
+ def inline_keytop(str)
493
+ "#{str}◆→キートップ#{str}←◆"
494
+ end
495
+
496
+ def inline_balloon(str)
497
+ %Q(\t←#{str.gsub(/@maru\[(\d+)\]/, inline_maru('\1'))})
498
+ end
499
+
500
+ def inline_uchar(str)
501
+ [str.to_i(16)].pack("U")
502
+ end
503
+
504
+ def inline_m(str)
505
+ %Q[◆→TeX式ここから←◆#{str}◆→TeX式ここまで←◆]
506
+ end
507
+
508
+ def noindent
509
+ puts "◆→DTP連絡:次の1行インデントなし←◆"
510
+ end
511
+
512
+ def nonum_begin(level, label, caption)
513
+ puts "■H#{level}■#{compile_inline(caption)}"
514
+ end
515
+
516
+ def nonum_end(level)
517
+ end
518
+
519
+ def common_column_begin(type, caption)
520
+ blank
521
+ puts "◆→開始:#{@titles["type"]}←◆"
522
+ puts %Q[■#{compile_inline(caption)}]
523
+ end
524
+
525
+ def common_column_end(type)
526
+ puts %Q[◆→終了:#{@titles["type"]}←◆]
527
+ blank
528
+ end
529
+
530
+ def column_begin(level, label, caption)
531
+ common_column_begin("column", caption)
532
+ end
533
+
534
+ def column_end(level)
535
+ common_column_end("column")
536
+ end
537
+
538
+ def xcolumn_begin(level, label, caption)
539
+ common_column_begin("xcolumn", caption)
540
+ end
541
+
542
+ def xcolumn_end(level)
543
+ common_column_end("xcolumn")
544
+ end
545
+
546
+ def world_begin(level, label, caption)
547
+ common_column_begin("world", caption)
548
+ end
549
+
550
+ def world_end(level)
551
+ common_column_end("world")
552
+ end
553
+
554
+ def hood_begin(level, label, caption)
555
+ common_column_begin("hood", caption)
556
+ end
557
+
558
+ def hood_end(level)
559
+ common_column_end("hood")
560
+ end
561
+
562
+ def edition_begin(level, label, caption)
563
+ common_column_begin("edition", caption)
564
+ end
565
+
566
+ def edition_end(level)
567
+ common_column_end("edition")
568
+ end
569
+
570
+ def insideout_begin(level, label, caption)
571
+ common_column_begin("insideout", caption)
572
+ end
573
+
574
+ def insideout_end(level)
575
+ common_column_end("insideout")
576
+ end
577
+
578
+ def ref_begin(level, label, caption)
579
+ common_column_begin("ref", caption)
580
+ end
581
+
582
+ def ref_end(level)
583
+ common_column_end("ref")
584
+ end
585
+
586
+ def sup_begin(level, label, caption)
587
+ common_column_begin("sup", caption)
588
+ end
589
+
590
+ def sup_end(level)
591
+ common_column_end("sup")
592
+ end
593
+
594
+ def flushright(lines)
595
+ base_parablock "flushright", lines, nil
596
+ end
597
+
598
+ def centering(lines)
599
+ base_parablock "centering", lines, nil
600
+ end
601
+
602
+ def note(lines, caption = nil)
603
+ base_parablock "note", lines, caption
604
+ end
605
+
606
+ def memo(lines, caption = nil)
607
+ base_parablock "memo", lines, caption
608
+ end
609
+
610
+ def tip(lines, caption = nil)
611
+ base_parablock "tip", lines, caption
612
+ end
613
+
614
+ def info(lines, caption = nil)
615
+ base_parablock "info", lines, caption
616
+ end
617
+
618
+ def planning(lines, caption = nil)
619
+ base_parablock "planning", lines, caption
620
+ end
621
+
622
+ def best(lines, caption = nil)
623
+ base_parablock "best", lines, caption
624
+ end
625
+
626
+ def important(lines, caption = nil)
627
+ base_parablock "important", lines, caption
628
+ end
629
+
630
+ def security(lines, caption = nil)
631
+ base_parablock "security", lines, caption
632
+ end
633
+
634
+ def caution(lines, caption = nil)
635
+ base_parablock "caution", lines, caption
636
+ end
637
+
638
+ def term(lines)
639
+ base_parablock "term", lines, nil
640
+ end
641
+
642
+ def link(lines, caption = nil)
643
+ base_parablock "link", lines, caption
644
+ end
645
+
646
+ def notice(lines, caption = nil)
647
+ base_parablock "notice", lines, caption
648
+ end
649
+
650
+ def point(lines, caption = nil)
651
+ base_parablock "point", lines, caption
652
+ end
653
+
654
+ def shoot(lines, caption = nil)
655
+ base_parablock "shoot", lines, caption
656
+ end
657
+
658
+ def reference(lines)
659
+ base_parablock "reference", lines, nil
660
+ end
661
+
662
+ def practice(lines)
663
+ base_parablock "practice", lines, nil
664
+ end
665
+
666
+ def expert(lines)
667
+ base_parablock "expert", lines, nil
668
+ end
669
+
670
+ def insn(lines, caption = nil)
671
+ base_block "insn", lines, caption
672
+ end
673
+
674
+ alias :box insn
675
+
676
+ def indepimage(id, caption=nil, metric=nil)
677
+ blank
678
+ begin
679
+ puts "◆→画像 #{@chapter.image(id).path.sub(/\A\.\//, "")} #{metric.join(" ")}←◆"
680
+ rescue
681
+ warn "no such image: #{id}"
682
+ puts "◆→画像 #{id}←◆"
683
+ end
684
+ puts "図 #{compile_inline(caption)}" if caption.present?
685
+ blank
686
+ end
687
+
688
+ alias :numberlessimage indepimage
689
+
690
+ def label(id)
691
+ # FIXME
692
+ ""
693
+ end
694
+
695
+ def tsize(id)
696
+ # FIXME
697
+ ""
698
+ end
699
+
700
+ def dtp(str)
701
+ # FIXME
702
+ end
703
+
704
+ def bpo(lines)
705
+ base_block "bpo", lines, nil
706
+ end
707
+
708
+ def inline_dtp(str)
709
+ # FIXME
710
+ ""
711
+ end
712
+
713
+ def inline_del(str)
714
+ # FIXME
715
+ ""
716
+ end
717
+
718
+ def inline_code(str)
719
+ %Q[△#{str}☆]
720
+ end
721
+
722
+ def inline_br(str)
723
+ %Q(\n)
724
+ end
725
+
726
+ def text(str)
727
+ str
728
+ end
729
+
730
+ def inline_chap(id)
731
+ #"「第#{super}章 #{inline_title(id)}」"
732
+ # "第#{super}章"
733
+ super
734
+ end
735
+
736
+ def inline_chapref(id)
737
+ chs = ["", "「", "」"]
738
+ unless ReVIEW.book.param["chapref"].nil?
739
+ _chs = convert_inencoding(ReVIEW.book.param["chapref"],
740
+ ReVIEW.book.param["inencoding"]).split(",")
741
+ if _chs.size != 3
742
+ error "--chapsplitter must have exactly 3 parameters with comma."
743
+ else
744
+ chs = _chs
745
+ end
746
+ else
747
+ end
748
+ "#{chs[0]}#{@chapter.env.chapter_index.number(id)}#{chs[1]}#{@chapter.env.chapter_index.title(id)}#{chs[2]}"
749
+ rescue KeyError
750
+ error "unknown chapter: #{id}"
751
+ nofunc_text("[UnknownChapter:#{id}]")
752
+ end
753
+
754
+ def source(lines, caption = nil)
755
+ base_block "source", lines, caption
756
+ end
757
+
758
+ def inline_ttibold(str)
759
+ "▲#{str}☆◆→等幅フォント太字イタ←◆"
760
+ end
761
+
762
+ def inline_labelref(idref)
763
+ %Q(「◆→#{idref}←◆」) # 節、項を参照
764
+ end
765
+
766
+ alias inline_ref inline_labelref
767
+
768
+ def inline_pageref(idref)
769
+ %Q(●ページ◆→#{idref}←◆) # ページ番号を参照
770
+ end
771
+
772
+ def circle_begin(level, label, caption)
773
+ puts "・\t#{caption}"
774
+ end
775
+
776
+ def circle_end(level)
777
+ end
778
+
779
+ def nofunc_text(str)
780
+ str
781
+ end
782
+
783
+ end
784
+
785
+ end # module ReVIEW