tmtms-review 1.0.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 +7 -0
- data/.travis.yml +9 -0
- data/COPYING +515 -0
- data/ChangeLog +2083 -0
- data/README.rdoc +50 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/bin/review-check +178 -0
- data/bin/review-checkdep +63 -0
- data/bin/review-compile +205 -0
- data/bin/review-epubmaker +661 -0
- data/bin/review-epubmaker-ng +176 -0
- data/bin/review-index +118 -0
- data/bin/review-pdfmaker +208 -0
- data/bin/review-preproc +142 -0
- data/bin/review-validate +51 -0
- data/bin/review-vol +102 -0
- data/debian/README.Debian +12 -0
- data/debian/README.source +5 -0
- data/debian/changelog +5 -0
- data/debian/compat +1 -0
- data/debian/control +22 -0
- data/debian/copyright +62 -0
- data/debian/docs +6 -0
- data/debian/manpage.1.ex +59 -0
- data/debian/patches/path.diff +91 -0
- data/debian/patches/series +1 -0
- data/debian/review.install +13 -0
- data/debian/review.links +4 -0
- data/debian/rules +13 -0
- data/debian/source/format +1 -0
- data/doc/format.rdoc +582 -0
- data/doc/format_idg.rdoc +180 -0
- data/doc/libepubmaker/sample.yaml +90 -0
- data/doc/quickstart.rdoc +188 -0
- data/doc/ruby-uuid/README +11 -0
- data/doc/ruby-uuid/README.ja +34 -0
- data/doc/sample.css +108 -0
- data/doc/sample.yaml +62 -0
- data/lib/epubmaker.rb +28 -0
- data/lib/epubmaker/content.rb +82 -0
- data/lib/epubmaker/epubv2.rb +418 -0
- data/lib/epubmaker/epubv3.rb +249 -0
- data/lib/epubmaker/producer.rb +204 -0
- data/lib/epubmaker/resource.rb +66 -0
- data/lib/lineinput.rb +155 -0
- data/lib/review.rb +3 -0
- data/lib/review/book.rb +46 -0
- data/lib/review/book/base.rb +235 -0
- data/lib/review/book/chapter.rb +81 -0
- data/lib/review/book/compilable.rb +159 -0
- data/lib/review/book/index.rb +339 -0
- data/lib/review/book/page_metric.rb +38 -0
- data/lib/review/book/parameters.rb +97 -0
- data/lib/review/book/part.rb +44 -0
- data/lib/review/book/volume.rb +65 -0
- data/lib/review/builder.rb +444 -0
- data/lib/review/compiler.rb +550 -0
- data/lib/review/configure.rb +38 -0
- data/lib/review/epubbuilder.rb +18 -0
- data/lib/review/exception.rb +21 -0
- data/lib/review/extentions.rb +3 -0
- data/lib/review/extentions/object.rb +9 -0
- data/lib/review/extentions/string.rb +33 -0
- data/lib/review/htmlbuilder.rb +1097 -0
- data/lib/review/htmllayout.rb +19 -0
- data/lib/review/htmlutils.rb +36 -0
- data/lib/review/i18n.rb +30 -0
- data/lib/review/i18n.yaml +34 -0
- data/lib/review/idgxmlbuilder.rb +1145 -0
- data/lib/review/latexbuilder.rb +815 -0
- data/lib/review/latexindex.rb +35 -0
- data/lib/review/latexutils.rb +79 -0
- data/lib/review/preprocessor.rb +563 -0
- data/lib/review/review.tex.erb +232 -0
- data/lib/review/textbuilder.rb +17 -0
- data/lib/review/textutils.rb +66 -0
- data/lib/review/tocparser.rb +342 -0
- data/lib/review/tocprinter.rb +221 -0
- data/lib/review/topbuilder.rb +785 -0
- data/lib/review/unfold.rb +138 -0
- data/lib/uuid.rb +312 -0
- data/review.gemspec +141 -0
- data/test/CHAPS +2 -0
- data/test/bib.re +13 -0
- data/test/book_test_helper.rb +35 -0
- data/test/test.re +43 -0
- data/test/test_book.rb +598 -0
- data/test/test_book_chapter.rb +418 -0
- data/test/test_book_parameter.rb +42 -0
- data/test/test_book_part.rb +50 -0
- data/test/test_builder.rb +144 -0
- data/test/test_compiler.rb +44 -0
- data/test/test_epubmaker.rb +507 -0
- data/test/test_helper.rb +27 -0
- data/test/test_htmlbuilder.rb +554 -0
- data/test/test_htmlutils.rb +28 -0
- data/test/test_i18n.rb +64 -0
- data/test/test_idgxmlbuilder.rb +589 -0
- data/test/test_index.rb +31 -0
- data/test/test_latexbuilder.rb +656 -0
- data/test/test_lineinput.rb +198 -0
- data/test/test_preprocessor.rb +23 -0
- data/test/test_textutils.rb +68 -0
- data/test/test_topbuilder.rb +244 -0
- data/test/test_uuid.rb +156 -0
- metadata +161 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Copyright (c) 2009 Narihiro Nakamura <authornari@gmail.com>
|
|
2
|
+
require 'erb'
|
|
3
|
+
|
|
4
|
+
class HTMLLayout
|
|
5
|
+
def initialize(src, title, template)
|
|
6
|
+
@body = src
|
|
7
|
+
@title = title
|
|
8
|
+
@template = template
|
|
9
|
+
end
|
|
10
|
+
attr_reader :body, :title
|
|
11
|
+
|
|
12
|
+
def result
|
|
13
|
+
if File.exist?(@template)
|
|
14
|
+
return ERB.new(IO.read(@template)).result(binding)
|
|
15
|
+
else
|
|
16
|
+
return @src
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#
|
|
2
|
+
# $Id: htmlutils.rb 2227 2006-05-13 00:09:08Z aamine $
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2002-2006 Minero Aoki
|
|
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
|
+
module ReVIEW
|
|
12
|
+
|
|
13
|
+
module HTMLUtils
|
|
14
|
+
ESC = {
|
|
15
|
+
'&' => '&',
|
|
16
|
+
'<' => '<',
|
|
17
|
+
'>' => '>',
|
|
18
|
+
'"' => '"'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
def escape_html(str)
|
|
22
|
+
t = ESC
|
|
23
|
+
str.gsub(/[&"<>]/) {|c| t[c] }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def unescape_html(str)
|
|
27
|
+
# FIXME better code
|
|
28
|
+
str.gsub('"', '"').gsub('>', '>').gsub('<', '<').gsub('&', '&')
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def strip_html(str)
|
|
32
|
+
str.gsub(/<\/?[^>]*>/, "")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end # module ReVIEW
|
data/lib/review/i18n.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'yaml'
|
|
3
|
+
|
|
4
|
+
module ReVIEW
|
|
5
|
+
class I18n
|
|
6
|
+
def self.setup
|
|
7
|
+
user_i18n = YAML.load_file(File.expand_path "locale.yaml", ENV["PWD"])
|
|
8
|
+
I18n.i18n user_i18n["locale"], user_i18n
|
|
9
|
+
rescue
|
|
10
|
+
I18n.i18n "ja"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.i18n(locale, user_i18n = {})
|
|
14
|
+
locale ||= "ja"
|
|
15
|
+
i18n_yaml_path = File.expand_path "i18n.yaml", File.dirname(__FILE__)
|
|
16
|
+
@i18n = YAML.load_file(i18n_yaml_path)[locale]
|
|
17
|
+
if @i18n
|
|
18
|
+
@i18n.merge!(user_i18n)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.t(str, args = nil)
|
|
23
|
+
@i18n[str] % args
|
|
24
|
+
rescue
|
|
25
|
+
str
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
I18n.setup
|
|
30
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
ja:
|
|
2
|
+
image: 図
|
|
3
|
+
table: 表
|
|
4
|
+
list: リスト
|
|
5
|
+
part: 第%d部
|
|
6
|
+
chapter: 第%d章
|
|
7
|
+
chapter_postfix: " "
|
|
8
|
+
appendix: 付録%s
|
|
9
|
+
numberless_image: "図:"
|
|
10
|
+
format_number: "%s.%d"
|
|
11
|
+
format_number_header: "%s.%d:"
|
|
12
|
+
format_number_without_chapter: "%d"
|
|
13
|
+
format_number_header_without_chapter: "%d:"
|
|
14
|
+
caption_prefix: " "
|
|
15
|
+
caption_prefix_idgxml: " "
|
|
16
|
+
ruby_prefix: "("
|
|
17
|
+
ruby_postfix: ")"
|
|
18
|
+
|
|
19
|
+
en:
|
|
20
|
+
image: "Figure "
|
|
21
|
+
table: "Table "
|
|
22
|
+
list: "List "
|
|
23
|
+
chapter: Chapter %d
|
|
24
|
+
chapter_postfix: ". "
|
|
25
|
+
appendix: Appendix %s
|
|
26
|
+
numberless_image: "Figure:"
|
|
27
|
+
format_number: "%s.%d"
|
|
28
|
+
format_number_header: "%s.%d:"
|
|
29
|
+
format_number_without_chapter: "%d"
|
|
30
|
+
format_number_header_without_chapter: "%d:"
|
|
31
|
+
caption_prefix: " "
|
|
32
|
+
caption_prefix_idgxml: " "
|
|
33
|
+
ruby_prefix: "("
|
|
34
|
+
ruby_postfix: ")"
|
|
@@ -0,0 +1,1145 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2002-2007 Minero Aoki
|
|
4
|
+
# 2008-2012 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/htmlutils'
|
|
13
|
+
require 'review/textutils'
|
|
14
|
+
require 'nkf'
|
|
15
|
+
|
|
16
|
+
module ReVIEW
|
|
17
|
+
|
|
18
|
+
class IDGXMLBuilder < Builder
|
|
19
|
+
|
|
20
|
+
include TextUtils
|
|
21
|
+
include HTMLUtils
|
|
22
|
+
|
|
23
|
+
[:ttbold, :hint, :maru, :keytop, :labelref, :ref, :pageref, :balloon].each {|e| Compiler.definline(e) }
|
|
24
|
+
Compiler.defsingle(:dtp, 1)
|
|
25
|
+
|
|
26
|
+
Compiler.defblock(:insn, 0..1)
|
|
27
|
+
Compiler.defblock(:memo, 0..1)
|
|
28
|
+
Compiler.defblock(:tip, 0..1)
|
|
29
|
+
Compiler.defblock(:info, 0..1)
|
|
30
|
+
Compiler.defblock(:planning, 0..1)
|
|
31
|
+
Compiler.defblock(:best, 0..1)
|
|
32
|
+
Compiler.defblock(:important, 0..1)
|
|
33
|
+
Compiler.defblock(:security, 0..1)
|
|
34
|
+
Compiler.defblock(:caution, 0..1)
|
|
35
|
+
Compiler.defblock(:notice, 0..1)
|
|
36
|
+
Compiler.defblock(:point, 0..1)
|
|
37
|
+
Compiler.defblock(:shoot, 0..1)
|
|
38
|
+
Compiler.defblock(:reference, 0)
|
|
39
|
+
Compiler.defblock(:term, 0)
|
|
40
|
+
Compiler.defblock(:link, 0..1)
|
|
41
|
+
Compiler.defblock(:practice, 0)
|
|
42
|
+
Compiler.defblock(:expert, 0)
|
|
43
|
+
Compiler.defblock(:rawblock, 0)
|
|
44
|
+
|
|
45
|
+
def pre_paragraph
|
|
46
|
+
'<p>'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def post_paragraph
|
|
50
|
+
'</p>'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def extname
|
|
54
|
+
'.xml'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def builder_init(no_error = false)
|
|
58
|
+
@no_error = no_error
|
|
59
|
+
end
|
|
60
|
+
private :builder_init
|
|
61
|
+
|
|
62
|
+
def builder_init_file
|
|
63
|
+
@warns = []
|
|
64
|
+
@errors = []
|
|
65
|
+
@section = 0
|
|
66
|
+
@subsection = 0
|
|
67
|
+
@subsubsection = 0
|
|
68
|
+
@subsubsubsection = 0
|
|
69
|
+
@noindent = nil
|
|
70
|
+
@rootelement = "doc"
|
|
71
|
+
@secttags = nil
|
|
72
|
+
@tsize = nil
|
|
73
|
+
@texblockequation = 0
|
|
74
|
+
@texinlineequation = 0
|
|
75
|
+
|
|
76
|
+
print %Q(<?xml version="1.0" encoding="UTF-8"?>\n)
|
|
77
|
+
print %Q(<#{@rootelement} xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">)
|
|
78
|
+
alias puts print unless ReVIEW.book.param["nolf"].nil?
|
|
79
|
+
@secttags = true unless ReVIEW.book.param["structuredxml"].nil?
|
|
80
|
+
end
|
|
81
|
+
private :builder_init_file
|
|
82
|
+
|
|
83
|
+
def result
|
|
84
|
+
s = ""
|
|
85
|
+
unless @secttags.nil?
|
|
86
|
+
s += "</sect4>" if @subsubsubsection > 0
|
|
87
|
+
s += "</sect3>" if @subsubsection > 0
|
|
88
|
+
s += "</sect2>" if @subsection > 0
|
|
89
|
+
s += "</sect>" if @section > 0
|
|
90
|
+
s += "</chapter>" if @chapter.number > 0
|
|
91
|
+
end
|
|
92
|
+
messages() + @output.string + s + "</#{@rootelement}>\n"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def warn(msg)
|
|
96
|
+
if @no_error
|
|
97
|
+
@warns.push [@location.filename, @location.lineno, msg]
|
|
98
|
+
puts "----WARNING: #{escape_html(msg)}----"
|
|
99
|
+
else
|
|
100
|
+
$stderr.puts "#{@location}: warning: #{msg}"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def error(msg)
|
|
105
|
+
if @no_error
|
|
106
|
+
@errors.push [@location.filename, @location.lineno, msg]
|
|
107
|
+
puts "----ERROR: #{escape_html(msg)}----"
|
|
108
|
+
else
|
|
109
|
+
$stderr.puts "#{@location}: error: #{msg}"
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def messages
|
|
114
|
+
error_messages() + warning_messages()
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def error_messages
|
|
118
|
+
return '' if @errors.empty?
|
|
119
|
+
"<h2>Syntax Errors</h2>\n" +
|
|
120
|
+
"<ul>\n" +
|
|
121
|
+
@errors.map {|file, line, msg|
|
|
122
|
+
"<li>#{escape_html(file)}:#{line}: #{escape_html(msg.to_s)}</li>\n"
|
|
123
|
+
}.join('') +
|
|
124
|
+
"</ul>\n"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def warning_messages
|
|
128
|
+
return '' if @warns.empty?
|
|
129
|
+
"<h2>Warnings</h2>\n" +
|
|
130
|
+
"<ul>\n" +
|
|
131
|
+
@warns.map {|file, line, msg|
|
|
132
|
+
"<li>#{escape_html(file)}:#{line}: #{escape_html(msg)}</li>\n"
|
|
133
|
+
}.join('') +
|
|
134
|
+
"</ul>\n"
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def headline(level, label, caption)
|
|
138
|
+
prefix = ""
|
|
139
|
+
case level
|
|
140
|
+
when 1
|
|
141
|
+
unless @secttags.nil?
|
|
142
|
+
print "</sect4>" if @subsubsubsection > 0
|
|
143
|
+
print "</sect3>" if @subsubsection > 0
|
|
144
|
+
print "</sect2>" if @subsection > 0
|
|
145
|
+
print "</sect>" if @section > 0
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
print %Q(<chapter id="chap:#{@chapter.number}">) unless @secttags.nil?
|
|
149
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
|
150
|
+
prefix = "#{I18n.t("chapter", @chapter.number)}#{I18n.t("chapter_postfix")}"
|
|
151
|
+
elsif @chapter.number.present?
|
|
152
|
+
prefix = "#{@chapter.number}#{I18n.t("chapter_postfix")}"
|
|
153
|
+
end
|
|
154
|
+
@section = 0
|
|
155
|
+
@subsection = 0
|
|
156
|
+
@subsubsection = 0
|
|
157
|
+
@subsubsubsection = 0
|
|
158
|
+
when 2
|
|
159
|
+
unless @secttags.nil?
|
|
160
|
+
print "</sect4>" if @subsubsubsection > 0
|
|
161
|
+
print "</sect3>" if @subsubsection > 0
|
|
162
|
+
print "</sect2>" if @subsection > 0
|
|
163
|
+
print "</sect>" if @section > 0
|
|
164
|
+
end
|
|
165
|
+
@section += 1
|
|
166
|
+
print %Q(<sect id="sect:#{@chapter.number}.#{@section}">) unless @secttags.nil?
|
|
167
|
+
|
|
168
|
+
prefix = @chapter.present? ? "#{@chapter.number}.#{@section} " : ""
|
|
169
|
+
|
|
170
|
+
@subsection = 0
|
|
171
|
+
@subsubsection = 0
|
|
172
|
+
@subsubsubsection = 0
|
|
173
|
+
when 3
|
|
174
|
+
unless @secttags.nil?
|
|
175
|
+
print "</sect4>" if @subsubsubsection > 0
|
|
176
|
+
print "</sect3>" if @subsubsection > 0
|
|
177
|
+
print "</sect2>" if @subsection > 0
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
@subsection += 1
|
|
181
|
+
print %Q(<sect2 id="sect:#{@chapter.number}.#{@section}.#{@subsection}">) unless @secttags.nil?
|
|
182
|
+
prefix = @chapter.number.present? ? "#{@chapter.number}.#{@section}.#{@subsection}#{I18n.t("chapter_postfix")}" : ""
|
|
183
|
+
|
|
184
|
+
@subsubsection = 0
|
|
185
|
+
@subsubsubsection = 0
|
|
186
|
+
when 4
|
|
187
|
+
unless @secttags.nil?
|
|
188
|
+
print "</sect4>" if @subsubsubsection > 0
|
|
189
|
+
print "</sect3>" if @subsubsection > 0
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
@subsubsection += 1
|
|
193
|
+
print %Q(<sect3 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}">) unless @secttags.nil?
|
|
194
|
+
prefix = @chapter.number.present? ? "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}#{I18n.t("chapter_postfix")}" : ""
|
|
195
|
+
|
|
196
|
+
@subsubsubsection = 0
|
|
197
|
+
when 5
|
|
198
|
+
unless @secttags.nil?
|
|
199
|
+
print "</sect4>" if @subsubsubsection > 0
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
@subsubsubsection += 1
|
|
203
|
+
print %Q(<sect4 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}">) unless @secttags.nil?
|
|
204
|
+
prefix = @chapter.number.present? ? "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}#{I18n.t("chapter_postfix")}" : ""
|
|
205
|
+
else
|
|
206
|
+
raise "caption level too deep or unsupported: #{level}"
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
prefix = "" if (level.to_i > ReVIEW.book.param["secnolevel"])
|
|
210
|
+
label = label.nil? ? "" : " id=\"#{label}\""
|
|
211
|
+
toccaption = escape_html(compile_inline(caption.gsub(/@<fn>\{.+?\}/, '')).gsub(/<[^>]+>/, ''))
|
|
212
|
+
puts %Q(<title#{label} aid:pstyle="h#{level}">#{prefix}#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{prefix}#{toccaption}"?>)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def ul_begin
|
|
216
|
+
level = block_given? ? yield : ""
|
|
217
|
+
level = nil if level == 1
|
|
218
|
+
puts "<ul#{level == 1 ? nil : level}>"
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def ul_item(lines)
|
|
222
|
+
puts %Q(<li aid:pstyle="ul-item">#{lines.join.chomp}</li>)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def ul_item_begin(lines)
|
|
226
|
+
print %Q(<li aid:pstyle="ul-item">#{lines.join.chomp})
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def ul_item_end
|
|
230
|
+
puts "</li>"
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def choice_single_begin
|
|
234
|
+
puts "<choice type='single'>"
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def choice_multi_begin
|
|
238
|
+
puts "<choice type='multi'>"
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def choice_single_end
|
|
242
|
+
puts "</choice>"
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def choice_multi_end
|
|
246
|
+
puts "</choice>"
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def ul_end
|
|
250
|
+
level = block_given? ? yield : ""
|
|
251
|
+
level = nil if level == 1
|
|
252
|
+
puts "</ul#{level}>"
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def ol_begin
|
|
256
|
+
puts '<ol>'
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def ol_item(lines, num)
|
|
260
|
+
puts %Q(<li aid:pstyle="ol-item" num="#{num}">#{lines.join.chomp}</li>)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def ol_end
|
|
264
|
+
puts '</ol>'
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def dl_begin
|
|
268
|
+
puts '<dl>'
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def dt(line)
|
|
272
|
+
puts "<dt>#{line}</dt>"
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def dd(lines)
|
|
276
|
+
puts "<dd>#{lines.join.chomp}</dd>"
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def dl_end
|
|
280
|
+
puts '</dl>'
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def paragraph(lines)
|
|
284
|
+
if @noindent.nil?
|
|
285
|
+
if lines[0] =~ /\A(\t+)/
|
|
286
|
+
puts %Q(<p inlist="#{$1.size}">#{lines.join('').sub(/\A\t+/, "")}</p>)
|
|
287
|
+
else
|
|
288
|
+
puts "<p>#{lines.join}</p>"
|
|
289
|
+
end
|
|
290
|
+
else
|
|
291
|
+
puts %Q(<p aid:pstyle="noindent" noindent='1'>#{lines.join}</p>)
|
|
292
|
+
@noindent = nil
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def read(lines)
|
|
297
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
|
298
|
+
puts %Q[<lead>#{split_paragraph(lines).join}</lead>]
|
|
299
|
+
else
|
|
300
|
+
puts %Q[<p aid:pstyle="lead">#{lines.join}</p>]
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
alias :lead read
|
|
305
|
+
|
|
306
|
+
def inline_list(id)
|
|
307
|
+
chapter, id = extract_chapter_id(id)
|
|
308
|
+
if get_chap(chapter).nil?
|
|
309
|
+
"<span type='list'>#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [chapter.list(id).number])}</span>"
|
|
310
|
+
else
|
|
311
|
+
"<span type='list'>#{I18n.t("list")}#{I18n.t("format_number", [get_chap(chapter), chapter.list(id).number])}</span>"
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
def list_header(id, caption)
|
|
316
|
+
puts %Q[<codelist>]
|
|
317
|
+
if get_chap.nil?
|
|
318
|
+
puts %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
|
|
319
|
+
else
|
|
320
|
+
puts %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
|
|
321
|
+
end
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def list_body(lines)
|
|
325
|
+
print %Q(<pre>)
|
|
326
|
+
no = 1
|
|
327
|
+
lines.each do |line|
|
|
328
|
+
unless ReVIEW.book.param["listinfo"].nil?
|
|
329
|
+
print "<listinfo line=\"#{no}\""
|
|
330
|
+
print " begin=\"1\"" if no == 1
|
|
331
|
+
print " end=\"#{no}\"" if no == lines.size
|
|
332
|
+
print ">"
|
|
333
|
+
end
|
|
334
|
+
print detab(line)
|
|
335
|
+
print "\n"
|
|
336
|
+
print "</listinfo>" unless ReVIEW.book.param["listinfo"].nil?
|
|
337
|
+
no += 1
|
|
338
|
+
end
|
|
339
|
+
puts "</pre></codelist>"
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def emlist(lines, caption = nil)
|
|
343
|
+
quotedlist lines, 'emlist', caption
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def emlistnum(lines, caption = nil)
|
|
347
|
+
_lines = []
|
|
348
|
+
lines.each_with_index do |line, i|
|
|
349
|
+
_lines << detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
|
|
350
|
+
end
|
|
351
|
+
quotedlist _lines, 'emlistnum', caption
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def listnum_body(lines)
|
|
355
|
+
print %Q(<pre>)
|
|
356
|
+
lines.each_with_index do |line, i|
|
|
357
|
+
print detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
|
|
358
|
+
print "\n"
|
|
359
|
+
end
|
|
360
|
+
puts "</pre></codelist>"
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
def cmd(lines, caption = nil)
|
|
364
|
+
quotedlist lines, 'cmd', caption
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def quotedlist(lines, css_class, caption)
|
|
368
|
+
print %Q[<list type='#{css_class}'>]
|
|
369
|
+
puts "<caption aid:pstyle='#{css_class}-title'>#{compile_inline(caption)}</caption>" unless caption.nil?
|
|
370
|
+
print %Q[<pre>]
|
|
371
|
+
no = 1
|
|
372
|
+
lines.each do |line|
|
|
373
|
+
unless ReVIEW.book.param["listinfo"].nil?
|
|
374
|
+
print "<listinfo line=\"#{no}\""
|
|
375
|
+
print " begin=\"1\"" if no == 1
|
|
376
|
+
print " end=\"#{no}\"" if no == lines.size
|
|
377
|
+
print ">"
|
|
378
|
+
end
|
|
379
|
+
print detab(line)
|
|
380
|
+
print "\n"
|
|
381
|
+
print "</listinfo>" unless ReVIEW.book.param["listinfo"].nil?
|
|
382
|
+
no += 1
|
|
383
|
+
end
|
|
384
|
+
puts '</pre></list>'
|
|
385
|
+
end
|
|
386
|
+
private :quotedlist
|
|
387
|
+
|
|
388
|
+
def quote(lines)
|
|
389
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
|
390
|
+
blocked_lines = split_paragraph(lines)
|
|
391
|
+
puts "<quote>#{blocked_lines.join("")}</quote>"
|
|
392
|
+
else
|
|
393
|
+
puts "<quote>#{lines.join("\n")}</quote>"
|
|
394
|
+
end
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
def inline_table(id)
|
|
398
|
+
chapter, id = extract_chapter_id(id)
|
|
399
|
+
if get_chap(chapter).nil?
|
|
400
|
+
"<span type='table'>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [chapter.table(id).number])}</span>"
|
|
401
|
+
else
|
|
402
|
+
"<span type='table'>#{I18n.t("table")}#{I18n.t("format_number", [get_chap(chapter), chapter.table(id).number])}</span>"
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
def inline_img(id)
|
|
407
|
+
chapter, id = extract_chapter_id(id)
|
|
408
|
+
if get_chap(chapter).nil?
|
|
409
|
+
"<span type='image'>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}</span>"
|
|
410
|
+
else
|
|
411
|
+
"<span type='image'>#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}</span>"
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
def handle_metric(str)
|
|
416
|
+
k, v = str.split('=', 2)
|
|
417
|
+
return %Q|#{k}=\"#{v.sub(/\A["']/, '').sub(/["']\Z/, '')}\"|
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
def result_metric(array)
|
|
421
|
+
" #{array.join(' ')}"
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
def image_image(id, caption, metric=nil)
|
|
425
|
+
metrics = parse_metric("idgxml", metric)
|
|
426
|
+
puts "<img>"
|
|
427
|
+
puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A.\//, "")}"#{metrics} />]
|
|
428
|
+
image_header id, caption
|
|
429
|
+
puts "</img>"
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
def image_dummy(id, caption, lines)
|
|
433
|
+
if ReVIEW.book.param["subdirmode"]
|
|
434
|
+
warn "image file not exist: images/#{@chapter.id}/#{id}.eps" unless File.exist?("images/#{@chapter.id}/#{id}.eps")
|
|
435
|
+
elsif ReVIEW.book.param["singledirmode"]
|
|
436
|
+
warn "image file not exist: images/#{@chapter.id}/#{id}.eps" unless File.exist?("images/#{id}.eps")
|
|
437
|
+
else
|
|
438
|
+
warn "image file not exist: images/#{@chapter.id}-#{id}.eps" unless File.exist?("images/#{@chapter.id}-#{id}.eps")
|
|
439
|
+
end
|
|
440
|
+
puts "<img>"
|
|
441
|
+
print %Q[<pre aid:pstyle="dummyimage">]
|
|
442
|
+
lines.each do |line|
|
|
443
|
+
print detab(line)
|
|
444
|
+
print "\n"
|
|
445
|
+
end
|
|
446
|
+
print %Q[</pre>]
|
|
447
|
+
image_header id, caption
|
|
448
|
+
puts "</img>"
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
def image_header(id, caption)
|
|
452
|
+
if get_chap.nil?
|
|
453
|
+
puts %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
|
|
454
|
+
else
|
|
455
|
+
puts %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
|
|
456
|
+
end
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
def texequation(lines)
|
|
460
|
+
@texblockequation += 1
|
|
461
|
+
puts %Q[<replace idref="texblock-#{@texblockequation}">]
|
|
462
|
+
puts '<pre>'
|
|
463
|
+
puts "#{lines.join("\n")}"
|
|
464
|
+
puts '</pre>'
|
|
465
|
+
puts '</replace>'
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
def table(lines, id = nil, caption = nil)
|
|
469
|
+
tablewidth = nil
|
|
470
|
+
col = 0
|
|
471
|
+
unless ReVIEW.book.param["tableopt"].nil?
|
|
472
|
+
tablewidth = ReVIEW.book.param["tableopt"].split(",")[0].to_f / 0.351 # mm -> pt
|
|
473
|
+
end
|
|
474
|
+
puts "<table>"
|
|
475
|
+
rows = []
|
|
476
|
+
sepidx = nil
|
|
477
|
+
lines.each_with_index do |line, idx|
|
|
478
|
+
if /\A[\=\-]{12}/ =~ line
|
|
479
|
+
sepidx ||= idx
|
|
480
|
+
next
|
|
481
|
+
end
|
|
482
|
+
if tablewidth.nil?
|
|
483
|
+
rows.push(line.gsub(/\t\.\t/, "\t\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\t").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ""))
|
|
484
|
+
else
|
|
485
|
+
rows.push(line.gsub(/\t\.\t/, "\tDUMMYCELLSPLITTER\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\tDUMMYCELLSPLITTER").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ""))
|
|
486
|
+
end
|
|
487
|
+
_col = rows[rows.length - 1].split(/\t/).length
|
|
488
|
+
col = _col if _col > col
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
cellwidth = []
|
|
492
|
+
unless tablewidth.nil?
|
|
493
|
+
if @tsize.nil?
|
|
494
|
+
col.times {|n| cellwidth[n] = tablewidth / col }
|
|
495
|
+
else
|
|
496
|
+
cellwidth = @tsize.split(/\s*,\s*/)
|
|
497
|
+
totallength = 0
|
|
498
|
+
cellwidth.size.times do |n|
|
|
499
|
+
cellwidth[n] = cellwidth[n].to_f / 0.351 # mm -> pt
|
|
500
|
+
totallength = totallength + cellwidth[n]
|
|
501
|
+
warn "total length exceeds limit for table: #{id}" if totallength > tablewidth
|
|
502
|
+
end
|
|
503
|
+
if cellwidth.size < col
|
|
504
|
+
cw = (tablewidth - totallength) / (col - cellwidth.size)
|
|
505
|
+
warn "auto cell sizing exceeds limit for table: #{id}" if cw <= 0
|
|
506
|
+
for i in cellwidth.size..(col - 1)
|
|
507
|
+
cellwidth[i] = cw
|
|
508
|
+
end
|
|
509
|
+
end
|
|
510
|
+
end
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
begin
|
|
514
|
+
table_header id, caption unless caption.nil?
|
|
515
|
+
rescue KeyError => err
|
|
516
|
+
error "no such table: #{id}"
|
|
517
|
+
end
|
|
518
|
+
return if rows.empty?
|
|
519
|
+
|
|
520
|
+
if tablewidth.nil?
|
|
521
|
+
print "<tbody>"
|
|
522
|
+
else
|
|
523
|
+
print %Q[<tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="#{rows.length}" aid:tcols="#{col}">]
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
if sepidx
|
|
527
|
+
sepidx.times do |y|
|
|
528
|
+
if tablewidth.nil?
|
|
529
|
+
puts %Q[<tr type="header">#{rows.shift}</tr>]
|
|
530
|
+
else
|
|
531
|
+
i = 0
|
|
532
|
+
rows.shift.split(/\t/).each_with_index do |cell, x|
|
|
533
|
+
print %Q[<td xyh="#{x + 1},#{y + 1},#{sepidx}" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
|
|
534
|
+
i += 1
|
|
535
|
+
end
|
|
536
|
+
end
|
|
537
|
+
end
|
|
538
|
+
end
|
|
539
|
+
trputs(tablewidth, rows, cellwidth, sepidx)
|
|
540
|
+
puts "</tbody></table>"
|
|
541
|
+
@tsize = nil
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
def trputs(tablewidth, rows, cellwidth, sepidx)
|
|
545
|
+
sepidx = 0 if sepidx.nil?
|
|
546
|
+
if tablewidth.nil?
|
|
547
|
+
lastline = rows.pop
|
|
548
|
+
rows.each {|row| puts %Q[<tr>#{row}</tr>] }
|
|
549
|
+
puts %Q[<tr type="lastline">#{lastline}</tr>] unless lastline.nil?
|
|
550
|
+
else
|
|
551
|
+
rows.each_with_index do |row, y|
|
|
552
|
+
i = 0
|
|
553
|
+
row.split(/\t/).each_with_index do |cell, x|
|
|
554
|
+
print %Q[<td xyh="#{x + 1},#{y + 1 + sepidx},#{sepidx}" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
|
|
555
|
+
i += 1
|
|
556
|
+
end
|
|
557
|
+
end
|
|
558
|
+
end
|
|
559
|
+
end
|
|
560
|
+
|
|
561
|
+
def table_header(id, caption)
|
|
562
|
+
if get_chap.nil?
|
|
563
|
+
puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
|
|
564
|
+
else
|
|
565
|
+
puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
|
|
566
|
+
end
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
def table_begin(ncols)
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
def tr(rows)
|
|
573
|
+
puts %Q[<tr>#{rows.join("\t")}</tr>]
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
def th(str)
|
|
577
|
+
%Q[<?dtp tablerow header?>#{str}]
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
def td(str)
|
|
581
|
+
str
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
def table_end
|
|
585
|
+
print "<?dtp tablerow last?>"
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
def comment(str)
|
|
589
|
+
print %Q(<!-- [Comment] #{escape_html(str)} -->)
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
def footnote(id, str)
|
|
593
|
+
# see inline_fn
|
|
594
|
+
end
|
|
595
|
+
|
|
596
|
+
def inline_fn(id)
|
|
597
|
+
%Q[<footnote>#{compile_inline(@chapter.footnote(id).content.strip)}</footnote>]
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
def compile_ruby(base, ruby)
|
|
601
|
+
%Q[<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>#{escape_html(base.sub(/\A\s+/, "").sub(/\s+$/, ""))}</aid:rb><aid:rt>#{escape_html(ruby.sub(/\A\s+/, "").sub(/\s+$/, ""))}</aid:rt></aid:ruby></GroupRuby>]
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
def compile_kw(word, alt)
|
|
605
|
+
'<keyword>' +
|
|
606
|
+
if alt
|
|
607
|
+
then escape_html("#{word}(#{alt.strip})")
|
|
608
|
+
else escape_html(word)
|
|
609
|
+
end +
|
|
610
|
+
'</keyword>' +
|
|
611
|
+
%Q[<index value="#{escape_html(word)}" />] +
|
|
612
|
+
if alt
|
|
613
|
+
alt.split(/\s*,\s*/).collect! {|e| %Q[<index value="#{escape_html(e.strip)}" />] }.join
|
|
614
|
+
else
|
|
615
|
+
""
|
|
616
|
+
end
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
def compile_href(url, label)
|
|
620
|
+
%Q[<a linkurl='#{escape_html(url)}'>#{label.nil? ? escape_html(url) : escape_html(label)}</a>]
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
def inline_sup(str)
|
|
624
|
+
%Q[<sup>#{escape_html(str)}</sup>]
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
def inline_sub(str)
|
|
628
|
+
%Q[<sub>#{escape_html(str)}</sub>]
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
def inline_raw(str)
|
|
632
|
+
%Q[#{super(str).gsub("\\n", "\n")}]
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
def inline_hint(str)
|
|
636
|
+
if ReVIEW.book.param["nolf"].nil?
|
|
637
|
+
%Q[\n<hint>#{escape_html(str)}</hint>]
|
|
638
|
+
else
|
|
639
|
+
%Q[<hint>#{escape_html(str)}</hint>]
|
|
640
|
+
end
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
def inline_maru(str)
|
|
644
|
+
if str =~ /\A\d+\Z/
|
|
645
|
+
sprintf("&#x%x;", 9311 + str.to_i)
|
|
646
|
+
elsif str =~ /\A[A-Z]\Z/
|
|
647
|
+
begin
|
|
648
|
+
sprintf("&#x%x;", 9398 + str.codepoints.to_a[0] - 65)
|
|
649
|
+
rescue NoMethodError
|
|
650
|
+
sprintf("&#x%x;", 9398 + str[0] - 65)
|
|
651
|
+
end
|
|
652
|
+
elsif str =~ /\A[a-z]\Z/
|
|
653
|
+
begin
|
|
654
|
+
sprintf("&#x%x;", 9392 + str.codepoints.to_a[0] - 65)
|
|
655
|
+
rescue NoMethodError
|
|
656
|
+
sprintf("&#x%x;", 9392 + str[0] - 65)
|
|
657
|
+
end
|
|
658
|
+
else
|
|
659
|
+
raise "can't parse maru: #{str}"
|
|
660
|
+
end
|
|
661
|
+
end
|
|
662
|
+
|
|
663
|
+
def inline_idx(str)
|
|
664
|
+
%Q(#{escape_html(str)}<index value="#{escape_html(str)}" />)
|
|
665
|
+
end
|
|
666
|
+
|
|
667
|
+
def inline_hidx(str)
|
|
668
|
+
%Q(<index value="#{escape_html(str)}" />)
|
|
669
|
+
end
|
|
670
|
+
|
|
671
|
+
def inline_ami(str)
|
|
672
|
+
%Q(<ami>#{escape_html(str)}</ami>)
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
def inline_i(str)
|
|
676
|
+
%Q(<i>#{escape_html(str)}</i>)
|
|
677
|
+
end
|
|
678
|
+
|
|
679
|
+
def inline_b(str)
|
|
680
|
+
%Q(<b>#{escape_html(str)}</b>)
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
def inline_tt(str)
|
|
684
|
+
%Q(<tt>#{escape_html(str)}</tt>)
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
def inline_ttb(str)
|
|
688
|
+
index = escape_html(str).gsub(/<.*?>/, "").gsub(/\*/, "ESCAPED_ASTERISK").gsub(/'/, "")
|
|
689
|
+
%Q(<tt style='bold'>#{escape_html(str)}</tt><index value='#{index}' />)
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
alias :inline_ttbold inline_ttb
|
|
693
|
+
|
|
694
|
+
def inline_tti(str)
|
|
695
|
+
%Q(<tt style='italic'>#{escape_html(str)}</tt>)
|
|
696
|
+
end
|
|
697
|
+
|
|
698
|
+
def inline_u(str)
|
|
699
|
+
%Q(<underline>#{escape_html(str)}</underline>)
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
def inline_icon(id)
|
|
703
|
+
begin
|
|
704
|
+
%Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}" type="inline" />]
|
|
705
|
+
rescue
|
|
706
|
+
warn "no such icon image: #{id}"
|
|
707
|
+
""
|
|
708
|
+
end
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
def inline_bou(str)
|
|
712
|
+
%Q[<bou>#{escape_html(str)}</bou>]
|
|
713
|
+
end
|
|
714
|
+
|
|
715
|
+
def inline_keytop(str)
|
|
716
|
+
%Q[<keytop>#{escape_html(str)}</keytop>]
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
def inline_labelref(idref)
|
|
720
|
+
%Q[<ref idref='#{escape_html(idref)}'>「●● #{escape_html(idref)}」</ref>] # FIXME:節名とタイトルも込みで要出力
|
|
721
|
+
end
|
|
722
|
+
|
|
723
|
+
alias inline_ref inline_labelref
|
|
724
|
+
|
|
725
|
+
def inline_pageref(idref)
|
|
726
|
+
%Q[<pageref idref='#{escape_html(idref)}'>●●</pageref>] # ページ番号を参照
|
|
727
|
+
end
|
|
728
|
+
|
|
729
|
+
def inline_balloon(str)
|
|
730
|
+
%Q[<balloon>#{escape_html(str).gsub(/@maru\[(\d+)\]/) {|m| inline_maru($1)}}</balloon>]
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
def inline_uchar(str)
|
|
734
|
+
%Q[&#x#{str};]
|
|
735
|
+
end
|
|
736
|
+
|
|
737
|
+
def inline_m(str)
|
|
738
|
+
@texinlineequation += 1
|
|
739
|
+
%Q[<replace idref="texinline-#{@texinlineequation}"><pre>#{escape_html(str)}</pre></replace>]
|
|
740
|
+
end
|
|
741
|
+
|
|
742
|
+
def noindent
|
|
743
|
+
@noindent = true
|
|
744
|
+
end
|
|
745
|
+
|
|
746
|
+
def linebreak
|
|
747
|
+
# FIXME:pが閉じちゃってるので一度戻らないといけないが、難しい…。
|
|
748
|
+
puts "<br />"
|
|
749
|
+
end
|
|
750
|
+
|
|
751
|
+
def pagebreak
|
|
752
|
+
puts "<pagebreak />"
|
|
753
|
+
end
|
|
754
|
+
|
|
755
|
+
def nonum_begin(level, label, caption)
|
|
756
|
+
puts %Q[<title aid:pstyle="h#{level}">#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{escape_html(compile_inline(caption))}"?>]
|
|
757
|
+
end
|
|
758
|
+
|
|
759
|
+
def nonum_end(level)
|
|
760
|
+
end
|
|
761
|
+
|
|
762
|
+
def circle_begin(level, label, caption)
|
|
763
|
+
puts %Q[<title aid:pstyle="smallcircle">•#{compile_inline(caption)}</title>]
|
|
764
|
+
end
|
|
765
|
+
|
|
766
|
+
def circle_end(level)
|
|
767
|
+
end
|
|
768
|
+
|
|
769
|
+
def common_column_begin(type, caption)
|
|
770
|
+
print "<#{type}column>"
|
|
771
|
+
puts %Q[<title aid:pstyle="#{type}column-title">#{compile_inline(caption)}</title>]
|
|
772
|
+
end
|
|
773
|
+
|
|
774
|
+
def common_column_end(type)
|
|
775
|
+
puts "</#{type}column>"
|
|
776
|
+
end
|
|
777
|
+
|
|
778
|
+
def column_begin(level, label, caption)
|
|
779
|
+
common_column_begin("", caption)
|
|
780
|
+
end
|
|
781
|
+
|
|
782
|
+
def column_end(level)
|
|
783
|
+
common_column_end("")
|
|
784
|
+
end
|
|
785
|
+
|
|
786
|
+
def xcolumn_begin(level, label, caption)
|
|
787
|
+
common_column_begin("x", caption)
|
|
788
|
+
end
|
|
789
|
+
|
|
790
|
+
def xcolumn_end(level)
|
|
791
|
+
common_column_end("x")
|
|
792
|
+
end
|
|
793
|
+
|
|
794
|
+
def world_begin(level, label, caption)
|
|
795
|
+
common_column_begin("world", caption)
|
|
796
|
+
end
|
|
797
|
+
|
|
798
|
+
def world_end(level)
|
|
799
|
+
common_column_end("world")
|
|
800
|
+
end
|
|
801
|
+
|
|
802
|
+
def hood_begin(level, label, caption)
|
|
803
|
+
common_column_begin("hood", caption)
|
|
804
|
+
end
|
|
805
|
+
|
|
806
|
+
def hood_end(level)
|
|
807
|
+
common_column_end("hood")
|
|
808
|
+
end
|
|
809
|
+
|
|
810
|
+
def edition_begin(level, label, caption)
|
|
811
|
+
common_column_begin("edition", caption)
|
|
812
|
+
end
|
|
813
|
+
|
|
814
|
+
def edition_end(level)
|
|
815
|
+
common_column_end("edition")
|
|
816
|
+
end
|
|
817
|
+
|
|
818
|
+
def insideout_begin(level, label, caption)
|
|
819
|
+
common_column_begin("insideout", caption)
|
|
820
|
+
end
|
|
821
|
+
|
|
822
|
+
def insideout_end(level)
|
|
823
|
+
common_column_end("insideout")
|
|
824
|
+
end
|
|
825
|
+
|
|
826
|
+
def ref_begin(level, label, caption)
|
|
827
|
+
if !label.nil?
|
|
828
|
+
puts "<reference id='#{label}'>"
|
|
829
|
+
else
|
|
830
|
+
puts "<reference>"
|
|
831
|
+
end
|
|
832
|
+
end
|
|
833
|
+
|
|
834
|
+
def ref_end(level)
|
|
835
|
+
puts "</reference>"
|
|
836
|
+
end
|
|
837
|
+
|
|
838
|
+
def sup_begin(level, label, caption)
|
|
839
|
+
if !label.nil?
|
|
840
|
+
puts "<supplement id='#{label}'>"
|
|
841
|
+
else
|
|
842
|
+
puts "<supplement>"
|
|
843
|
+
end
|
|
844
|
+
end
|
|
845
|
+
|
|
846
|
+
def sup_end(level)
|
|
847
|
+
puts "</supplement>"
|
|
848
|
+
end
|
|
849
|
+
|
|
850
|
+
def flushright(lines)
|
|
851
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
|
852
|
+
puts split_paragraph(lines).join.gsub("<p>", "<p align='right'>")
|
|
853
|
+
else
|
|
854
|
+
puts "<p align='right'>#{lines.join("\n")}</p>"
|
|
855
|
+
end
|
|
856
|
+
end
|
|
857
|
+
|
|
858
|
+
def centering(lines)
|
|
859
|
+
puts split_paragraph(lines).join.gsub("<p>", "<p align='center'>")
|
|
860
|
+
end
|
|
861
|
+
|
|
862
|
+
def captionblock(type, lines, caption, specialstyle = nil)
|
|
863
|
+
print "<#{type}>"
|
|
864
|
+
style = specialstyle.nil? ? "#{type}-title" : specialstyle
|
|
865
|
+
puts "<title aid:pstyle='#{style}'>#{compile_inline(caption)}</title>" unless caption.nil?
|
|
866
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
|
867
|
+
blocked_lines = split_paragraph(lines)
|
|
868
|
+
puts "#{blocked_lines.join}</#{type}>"
|
|
869
|
+
else
|
|
870
|
+
puts "#{lines.join("\n")}</#{type}>"
|
|
871
|
+
end
|
|
872
|
+
end
|
|
873
|
+
|
|
874
|
+
def note(lines, caption = nil)
|
|
875
|
+
captionblock("note", lines, caption)
|
|
876
|
+
end
|
|
877
|
+
|
|
878
|
+
def memo(lines, caption = nil)
|
|
879
|
+
captionblock("memo", lines, caption)
|
|
880
|
+
end
|
|
881
|
+
|
|
882
|
+
def tip(lines, caption = nil)
|
|
883
|
+
captionblock("tip", lines, caption)
|
|
884
|
+
end
|
|
885
|
+
|
|
886
|
+
def info(lines, caption = nil)
|
|
887
|
+
captionblock("info", lines, caption)
|
|
888
|
+
end
|
|
889
|
+
|
|
890
|
+
def planning(lines, caption = nil)
|
|
891
|
+
captionblock("planning", lines, caption)
|
|
892
|
+
end
|
|
893
|
+
|
|
894
|
+
def best(lines, caption = nil)
|
|
895
|
+
captionblock("best", lines, caption)
|
|
896
|
+
end
|
|
897
|
+
|
|
898
|
+
def important(lines, caption = nil)
|
|
899
|
+
captionblock("important", lines, caption)
|
|
900
|
+
end
|
|
901
|
+
|
|
902
|
+
def security(lines, caption = nil)
|
|
903
|
+
captionblock("security", lines, caption)
|
|
904
|
+
end
|
|
905
|
+
|
|
906
|
+
def caution(lines, caption = nil)
|
|
907
|
+
captionblock("caution", lines, caption)
|
|
908
|
+
end
|
|
909
|
+
|
|
910
|
+
def term(lines)
|
|
911
|
+
captionblock("term", lines, nil)
|
|
912
|
+
end
|
|
913
|
+
|
|
914
|
+
def link(lines, caption = nil)
|
|
915
|
+
captionblock("link", lines, caption)
|
|
916
|
+
end
|
|
917
|
+
|
|
918
|
+
def notice(lines, caption = nil)
|
|
919
|
+
if caption.nil?
|
|
920
|
+
captionblock("notice", lines, nil)
|
|
921
|
+
else
|
|
922
|
+
captionblock("notice-t", lines, caption, "notice-title")
|
|
923
|
+
end
|
|
924
|
+
end
|
|
925
|
+
|
|
926
|
+
def point(lines, caption = nil)
|
|
927
|
+
if caption.nil?
|
|
928
|
+
captionblock("point", lines, nil)
|
|
929
|
+
else
|
|
930
|
+
captionblock("point-t", lines, caption, "point-title")
|
|
931
|
+
end
|
|
932
|
+
end
|
|
933
|
+
|
|
934
|
+
def shoot(lines, caption = nil)
|
|
935
|
+
if caption.nil?
|
|
936
|
+
captionblock("shoot", lines, nil)
|
|
937
|
+
else
|
|
938
|
+
captionblock("shoot-t", lines, caption, "shoot-title")
|
|
939
|
+
end
|
|
940
|
+
end
|
|
941
|
+
|
|
942
|
+
def reference(lines)
|
|
943
|
+
captionblock("reference", lines, nil)
|
|
944
|
+
end
|
|
945
|
+
|
|
946
|
+
def practice(lines)
|
|
947
|
+
captionblock("practice", lines, nil)
|
|
948
|
+
end
|
|
949
|
+
|
|
950
|
+
def expert(lines)
|
|
951
|
+
captionblock("expert", lines, nil)
|
|
952
|
+
end
|
|
953
|
+
|
|
954
|
+
def syntaxblock(type, lines, caption)
|
|
955
|
+
if caption.nil?
|
|
956
|
+
puts %Q[<#{type}>]
|
|
957
|
+
else
|
|
958
|
+
titleopentag = %Q[caption aid:pstyle="#{type}-title"]
|
|
959
|
+
titleclosetag = "caption"
|
|
960
|
+
if type == "insn"
|
|
961
|
+
titleopentag = %Q[floattitle type="insn"]
|
|
962
|
+
titleclosetag = "floattitle"
|
|
963
|
+
end
|
|
964
|
+
puts %Q[<#{type}><#{titleopentag}>#{compile_inline(caption)}</#{titleclosetag}>]
|
|
965
|
+
end
|
|
966
|
+
no = 1
|
|
967
|
+
lines.each do |line|
|
|
968
|
+
unless ReVIEW.book.param["listinfo"].nil?
|
|
969
|
+
print %Q[<listinfo line="#{no}"]
|
|
970
|
+
print %Q[ begin="1"] if no == 1
|
|
971
|
+
print %Q[ end="#{no}"] if no == lines.size
|
|
972
|
+
print %Q[>]
|
|
973
|
+
end
|
|
974
|
+
print detab(line)
|
|
975
|
+
print "\n"
|
|
976
|
+
print "</listinfo>" unless ReVIEW.book.param["listinfo"].nil?
|
|
977
|
+
no += 1
|
|
978
|
+
end
|
|
979
|
+
puts "</#{type}>"
|
|
980
|
+
end
|
|
981
|
+
|
|
982
|
+
def insn(lines, caption = nil)
|
|
983
|
+
syntaxblock("insn", lines, caption)
|
|
984
|
+
end
|
|
985
|
+
|
|
986
|
+
def box(lines, caption = nil)
|
|
987
|
+
syntaxblock("box", lines, caption)
|
|
988
|
+
end
|
|
989
|
+
|
|
990
|
+
def indepimage(id, caption=nil, metric=nil)
|
|
991
|
+
metrics = parse_metric("idgxml", metric)
|
|
992
|
+
puts "<img>"
|
|
993
|
+
begin
|
|
994
|
+
puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}"#{metrics} />]
|
|
995
|
+
rescue
|
|
996
|
+
warn %Q[no such image: #{id}]
|
|
997
|
+
end
|
|
998
|
+
puts %Q[<caption>#{compile_inline(caption)}</caption>] if !caption.nil? && !caption.empty?
|
|
999
|
+
puts "</img>"
|
|
1000
|
+
end
|
|
1001
|
+
|
|
1002
|
+
alias :numberlessimage indepimage
|
|
1003
|
+
|
|
1004
|
+
def label(id)
|
|
1005
|
+
# FIXME
|
|
1006
|
+
print "<label id='#{id}' />"
|
|
1007
|
+
end
|
|
1008
|
+
|
|
1009
|
+
def tsize(str)
|
|
1010
|
+
@tsize = str
|
|
1011
|
+
end
|
|
1012
|
+
|
|
1013
|
+
def dtp(str)
|
|
1014
|
+
print %Q(<?dtp #{str} ?>)
|
|
1015
|
+
end
|
|
1016
|
+
|
|
1017
|
+
def hr
|
|
1018
|
+
print "<hr />"
|
|
1019
|
+
end
|
|
1020
|
+
|
|
1021
|
+
def bpo(lines)
|
|
1022
|
+
puts %Q[<bpo>#{lines.join("\n")}</bpo>]
|
|
1023
|
+
end
|
|
1024
|
+
|
|
1025
|
+
def inline_dtp(str)
|
|
1026
|
+
"<?dtp #{str} ?>"
|
|
1027
|
+
end
|
|
1028
|
+
|
|
1029
|
+
def inline_code(str)
|
|
1030
|
+
%Q[<tt type='inline-code'>#{escape_html(str)}</tt>]
|
|
1031
|
+
end
|
|
1032
|
+
|
|
1033
|
+
def inline_br(str)
|
|
1034
|
+
"\n"
|
|
1035
|
+
end
|
|
1036
|
+
|
|
1037
|
+
def rawblock(lines)
|
|
1038
|
+
no = 1
|
|
1039
|
+
lines.each do |l|
|
|
1040
|
+
print l.gsub("<", "<").gsub(">", ">").gsub(""", "\"").gsub("&", "&")
|
|
1041
|
+
print "\n" unless lines.length == no
|
|
1042
|
+
no = no + 1
|
|
1043
|
+
end
|
|
1044
|
+
end
|
|
1045
|
+
|
|
1046
|
+
def text(str)
|
|
1047
|
+
str
|
|
1048
|
+
end
|
|
1049
|
+
|
|
1050
|
+
def inline_chapref(id)
|
|
1051
|
+
chs = ["", "「", "」"]
|
|
1052
|
+
unless ReVIEW.book.param["chapref"].nil?
|
|
1053
|
+
_chs = convert_inencoding(ReVIEW.book.param["chapref"],
|
|
1054
|
+
ReVIEW.book.param["inencoding"]).split(",")
|
|
1055
|
+
if _chs.size != 3
|
|
1056
|
+
error "--chapsplitter must have exactly 3 parameters with comma."
|
|
1057
|
+
else
|
|
1058
|
+
chs = _chs
|
|
1059
|
+
end
|
|
1060
|
+
else
|
|
1061
|
+
end
|
|
1062
|
+
s = "#{chs[0]}#{@chapter.env.chapter_index.number(id)}#{chs[1]}#{@chapter.env.chapter_index.title(id)}#{chs[2]}"
|
|
1063
|
+
if ReVIEW.book.param["chapterlink"]
|
|
1064
|
+
%Q(<link href="#{id}">#{s}</link>)
|
|
1065
|
+
else
|
|
1066
|
+
s
|
|
1067
|
+
end
|
|
1068
|
+
rescue KeyError
|
|
1069
|
+
error "unknown chapter: #{id}"
|
|
1070
|
+
nofunc_text("[UnknownChapter:#{id}]")
|
|
1071
|
+
end
|
|
1072
|
+
|
|
1073
|
+
def inline_chap(id)
|
|
1074
|
+
if ReVIEW.book.param["chapterlink"]
|
|
1075
|
+
%Q(<link href="#{id}">#{@chapter.env.chapter_index.number(id)}</link>)
|
|
1076
|
+
else
|
|
1077
|
+
@chapter.env.chapter_index.number(id)
|
|
1078
|
+
end
|
|
1079
|
+
rescue KeyError
|
|
1080
|
+
error "unknown chapter: #{id}"
|
|
1081
|
+
nofunc_text("[UnknownChapter:#{id}]")
|
|
1082
|
+
end
|
|
1083
|
+
|
|
1084
|
+
def inline_title(id)
|
|
1085
|
+
if ReVIEW.book.param["chapterlink"]
|
|
1086
|
+
%Q(<link href="#{id}">#{@chapter.env.chapter_index.title(id)}</link>)
|
|
1087
|
+
else
|
|
1088
|
+
@chapter.env.chapter_index.title(id)
|
|
1089
|
+
end
|
|
1090
|
+
rescue KeyError
|
|
1091
|
+
error "unknown chapter: #{id}"
|
|
1092
|
+
nofunc_text("[UnknownChapter:#{id}]")
|
|
1093
|
+
end
|
|
1094
|
+
|
|
1095
|
+
def source_header(caption)
|
|
1096
|
+
puts %Q[<source>]
|
|
1097
|
+
puts %Q[<caption>#{compile_inline(caption)}</caption>]
|
|
1098
|
+
end
|
|
1099
|
+
|
|
1100
|
+
def source_body(lines)
|
|
1101
|
+
puts %Q[<pre>]
|
|
1102
|
+
lines.each do |line|
|
|
1103
|
+
print detab(line)
|
|
1104
|
+
print "\n"
|
|
1105
|
+
end
|
|
1106
|
+
puts %Q[</pre></source>]
|
|
1107
|
+
end
|
|
1108
|
+
|
|
1109
|
+
def bibpaper(lines, id, caption)
|
|
1110
|
+
bibpaper_header id, caption
|
|
1111
|
+
unless lines.empty?
|
|
1112
|
+
bibpaper_bibpaper id, caption, lines
|
|
1113
|
+
end
|
|
1114
|
+
puts %Q(</bibitem>)
|
|
1115
|
+
end
|
|
1116
|
+
|
|
1117
|
+
def bibpaper_header(id, caption)
|
|
1118
|
+
puts %Q(<bibitem id="bib-#{id}">)
|
|
1119
|
+
puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{compile_inline(caption)}</caption>"
|
|
1120
|
+
end
|
|
1121
|
+
|
|
1122
|
+
def bibpaper_bibpaper(id, caption, lines)
|
|
1123
|
+
print split_paragraph(lines).join("")
|
|
1124
|
+
end
|
|
1125
|
+
|
|
1126
|
+
def inline_bib(id)
|
|
1127
|
+
%Q(<span type='bibref' idref='#{id}'>[#{@chapter.bibpaper(id).number}]</span>)
|
|
1128
|
+
end
|
|
1129
|
+
|
|
1130
|
+
def inline_recipe(id)
|
|
1131
|
+
# FIXME
|
|
1132
|
+
%Q(<recipe idref="#{escape_html(id)}">[XXX]「#{escape_html(id)}」 p.XX</recipe>)
|
|
1133
|
+
end
|
|
1134
|
+
|
|
1135
|
+
def nofunc_text(str)
|
|
1136
|
+
escape_html(str)
|
|
1137
|
+
end
|
|
1138
|
+
|
|
1139
|
+
def image_ext
|
|
1140
|
+
"eps"
|
|
1141
|
+
end
|
|
1142
|
+
|
|
1143
|
+
end
|
|
1144
|
+
|
|
1145
|
+
end # module ReVIEW
|