review 2.0.0.beta1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +66 -1
- data/.rubocop_todo.yml +617 -0
- data/.travis.yml +16 -1
- data/ChangeLog +48 -0
- data/Dockerfile +22 -0
- data/Gemfile +0 -1
- data/README.md +97 -0
- data/Rakefile +10 -11
- data/appveyor.yml +9 -0
- data/bin/review +46 -0
- data/bin/review-check +8 -21
- data/bin/review-compile +26 -43
- data/bin/review-index +9 -22
- data/bin/review-init +21 -25
- data/bin/review-preproc +9 -13
- data/bin/review-validate +1 -1
- data/bin/review-vol +3 -17
- data/bin/review-webmaker +15 -0
- data/doc/NEWS.ja.md +534 -0
- data/doc/NEWS.md +538 -0
- data/doc/catalog.ja.md +10 -18
- data/doc/catalog.md +5 -9
- data/doc/config.yml.sample +319 -0
- data/doc/customize_epub.ja.md +42 -0
- data/doc/format.ja.md +320 -288
- data/doc/format.md +277 -170
- data/doc/format_idg.ja.md +82 -175
- data/doc/pdfmaker.ja.md +61 -0
- data/doc/pdfmaker.md +65 -0
- data/doc/quickstart.ja.md +88 -98
- data/doc/quickstart.md +72 -110
- data/doc/sample.css +41 -0
- data/doc/writing_vertical.ja.md +55 -0
- data/doc/writing_vertical.md +5 -0
- data/lib/epubmaker/content.rb +3 -3
- data/lib/epubmaker/epubcommon.rb +173 -145
- data/lib/epubmaker/epubv2.rb +24 -77
- data/lib/epubmaker/epubv3.rb +72 -73
- data/lib/epubmaker/producer.rb +54 -30
- data/lib/lineinput.rb +48 -0
- data/lib/review/book.rb +0 -1
- data/lib/review/book/base.rb +47 -27
- data/lib/review/book/chapter.rb +48 -19
- data/lib/review/book/compilable.rb +10 -14
- data/lib/review/book/index.rb +10 -19
- data/lib/review/book/page_metric.rb +0 -10
- data/lib/review/book/part.rb +17 -3
- data/lib/review/builder.rb +84 -68
- data/lib/review/catalog.rb +5 -1
- data/lib/review/compiler.rb +327 -4657
- data/lib/review/configure.rb +84 -10
- data/lib/review/converter.rb +28 -0
- data/lib/review/epubbuilder.rb +1 -1
- data/lib/review/epubmaker.rb +142 -158
- data/lib/review/ewbbuilder.rb +5 -5
- data/lib/review/exception.rb +1 -1
- data/lib/review/extentions.rb +1 -1
- data/lib/review/extentions/hash.rb +15 -0
- data/lib/review/extentions/string.rb +2 -1
- data/lib/review/htmlbuilder.rb +364 -348
- data/lib/review/htmltoc.rb +44 -0
- data/lib/review/htmlutils.rb +12 -6
- data/lib/review/i18n.rb +78 -6
- data/lib/review/i18n.yml +7 -4
- data/lib/review/idgxmlbuilder.rb +226 -267
- data/lib/review/latexbuilder.rb +281 -274
- data/lib/review/latexutils.rb +56 -49
- data/lib/review/makerhelper.rb +8 -4
- data/lib/review/markdownbuilder.rb +80 -124
- data/lib/review/pdfmaker.rb +197 -138
- data/lib/review/preprocessor.rb +16 -67
- data/lib/review/template.rb +24 -0
- data/lib/review/textbuilder.rb +1 -1
- data/lib/review/textutils.rb +18 -24
- data/lib/review/tocparser.rb +51 -106
- data/lib/review/tocprinter.rb +61 -117
- data/lib/review/topbuilder.rb +119 -126
- data/lib/review/unfold.rb +2 -2
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +302 -0
- data/lib/review/webtocprinter.rb +48 -0
- data/lib/review/yamlloader.rb +47 -0
- data/review.gemspec +3 -3
- data/templates/html/layout-html5.html.erb +17 -0
- data/templates/html/layout-xhtml1.html.erb +20 -0
- data/{lib/review → templates/latex}/layout.tex.erb +107 -115
- data/templates/ncx/epubv2.ncx.erb +11 -0
- data/templates/opf/epubv2.opf.erb +21 -0
- data/templates/opf/epubv3.opf.erb +18 -0
- data/templates/web/html/layout-html5.html.erb +56 -0
- data/templates/web/html/layout-xhtml1.html.erb +20 -0
- data/templates/xml/container.xml.erb +6 -0
- data/test/assets/test.xml.erb +3 -0
- data/test/assets/test_template.tex +28 -71
- data/test/assets/test_template_backmatter.tex +1 -9
- data/test/sample-book/src/Rakefile +12 -3
- data/{doc/sample.yml → test/sample-book/src/config-epub2.yml} +92 -147
- data/test/sample-book/src/config.yml +40 -154
- data/test/sample-book/src/style-web.css +45 -0
- data/test/sample-book/src/style.css +23 -1
- data/test/test.re +1 -1
- data/test/test_book.rb +15 -17
- data/test/test_book_chapter.rb +2 -80
- data/test/test_book_part.rb +1 -1
- data/test/test_builder.rb +28 -6
- data/test/test_catalog.rb +17 -0
- data/test/test_compiler.rb +14 -59
- data/test/test_configure.rb +94 -0
- data/test/test_converter.rb +21 -0
- data/test/test_epub3maker.rb +155 -3
- data/test/test_epubmaker.rb +245 -30
- data/test/test_epubmaker_cmd.rb +2 -2
- data/test/test_extentions_hash.rb +60 -0
- data/test/test_helper.rb +4 -47
- data/test/test_htmlbuilder.rb +282 -175
- data/test/test_htmltoc.rb +33 -0
- data/test/test_i18n.rb +134 -70
- data/test/test_idgxmlbuilder.rb +58 -39
- data/test/test_latexbuilder.rb +132 -14
- data/test/test_lineinput.rb +5 -26
- data/test/test_makerhelper.rb +6 -4
- data/test/test_markdownbuilder.rb +23 -5
- data/test/test_pdfmaker.rb +86 -20
- data/test/test_pdfmaker_cmd.rb +1 -3
- data/test/test_review_ext.rb +1 -1
- data/test/test_template.rb +27 -0
- data/test/test_textutils.rb +36 -0
- data/test/test_tocparser.rb +25 -0
- data/test/test_topbuilder.rb +34 -2
- data/test/test_yamlloader.rb +188 -0
- metadata +71 -29
- data/README.rdoc +0 -81
- data/bin/review-epubmaker-legacy +0 -1024
- data/doc/ruby-uuid/README +0 -11
- data/doc/ruby-uuid/README.ja +0 -34
- data/lib/review/compiler/literals_1_8.kpeg +0 -19
- data/lib/review/compiler/literals_1_8.rb +0 -432
- data/lib/review/compiler/literals_1_9.kpeg +0 -22
- data/lib/review/compiler/literals_1_9.rb +0 -435
- data/lib/review/extentions/array.rb +0 -25
- data/lib/review/htmllayout.rb +0 -41
- data/lib/review/inaobuilder.rb +0 -357
- data/lib/review/location.rb +0 -24
- data/lib/review/node.rb +0 -267
- data/lib/review/review.kpeg +0 -724
- data/lib/uuid.rb +0 -312
- data/rubocop-todo.yml +0 -456
- data/test/test_inaobuilder.rb +0 -247
- data/test/test_uuid.rb +0 -157
@@ -0,0 +1,44 @@
|
|
1
|
+
module ReVIEW
|
2
|
+
class HTMLToc
|
3
|
+
def initialize(basedir)
|
4
|
+
@tochtmltxt = "toc-html.txt"
|
5
|
+
@basedir = basedir
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_item(level, filename, title, args)
|
9
|
+
args_str = encode_args(args)
|
10
|
+
line = [level, filename, title, args_str].join("\t")
|
11
|
+
File.open(tocfilename, "a") do |f|
|
12
|
+
f.write "#{line}\n"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def each_item
|
17
|
+
File.open(tocfilename) do |f|
|
18
|
+
f.each_line do |line|
|
19
|
+
level, file, title, args_str = line.chomp.split("\t")
|
20
|
+
args = decode_args(args_str)
|
21
|
+
yield level, file, title, args
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def tocfilename
|
27
|
+
File.join(@basedir, @tochtmltxt)
|
28
|
+
end
|
29
|
+
|
30
|
+
def decode_args(args_str)
|
31
|
+
args = Hash.new
|
32
|
+
args_str.split(/,\s*/).each do |pair|
|
33
|
+
key, val = pair.split("=")
|
34
|
+
args[key.to_sym] = val
|
35
|
+
end
|
36
|
+
args
|
37
|
+
end
|
38
|
+
|
39
|
+
def encode_args(args)
|
40
|
+
args.delete_if {|k,v| v.nil? }.map{|k,v| "#{k}=#{v}"}.join(",")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/lib/review/htmlutils.rb
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
# the GNU LGPL, Lesser General Public License version 2.1.
|
9
9
|
#
|
10
10
|
|
11
|
+
require 'cgi/util'
|
11
12
|
module ReVIEW
|
12
13
|
|
13
14
|
module HTMLUtils
|
@@ -24,6 +25,7 @@ module ReVIEW
|
|
24
25
|
end
|
25
26
|
|
26
27
|
alias_method :escape, :escape_html
|
28
|
+
alias_method :h, :escape_html
|
27
29
|
|
28
30
|
def unescape_html(str)
|
29
31
|
# FIXME better code
|
@@ -40,12 +42,16 @@ module ReVIEW
|
|
40
42
|
str.gsub('-', '-')
|
41
43
|
end
|
42
44
|
|
43
|
-
def
|
44
|
-
@book.config["
|
45
|
-
@book.config["highlight"]
|
45
|
+
def highlight?
|
46
|
+
@book.config["highlight"] &&
|
47
|
+
@book.config["highlight"]["html"] == "pygments"
|
46
48
|
end
|
47
49
|
|
48
50
|
def highlight(ops)
|
51
|
+
if @book.config["pygments"].present?
|
52
|
+
raise ReVIEW::ConfigError, "'pygments:' in config.yml is obsoleted."
|
53
|
+
end
|
54
|
+
|
49
55
|
body = ops[:body] || ''
|
50
56
|
if @book.config["highlight"] && @book.config["highlight"]["lang"]
|
51
57
|
lexer = @book.config["highlight"]["lang"] # default setting
|
@@ -58,7 +64,7 @@ module ReVIEW
|
|
58
64
|
if ops[:options] && ops[:options].kind_of?(Hash)
|
59
65
|
options.merge!(ops[:options])
|
60
66
|
end
|
61
|
-
return body if !
|
67
|
+
return body if !highlight?
|
62
68
|
|
63
69
|
begin
|
64
70
|
require 'pygments'
|
@@ -72,7 +78,7 @@ module ReVIEW
|
|
72
78
|
body
|
73
79
|
end
|
74
80
|
rescue LoadError
|
75
|
-
|
81
|
+
body
|
76
82
|
end
|
77
83
|
end
|
78
84
|
|
@@ -87,4 +93,4 @@ module ReVIEW
|
|
87
93
|
end
|
88
94
|
end
|
89
95
|
|
90
|
-
end
|
96
|
+
end # module ReVIEW
|
data/lib/review/i18n.rb
CHANGED
@@ -3,6 +3,17 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
module ReVIEW
|
5
5
|
class I18n
|
6
|
+
ALPHA_U = %w[0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
|
7
|
+
ALPHA_L = %w[0 a b c d e f g h i j k l m n o p q r s t u v w x y z]
|
8
|
+
ROMAN_U = %w[0 I II III IV V VI VII VIII IX X XI XII XIII XIV XV XVI XVII XVIII XIX XX XXI XXII XXIII XXIV XXV XXVI XXVII]
|
9
|
+
ROMAN_L = %w[0 i ii iii iv v vi vii viii ix x xi xii xiii xiv xv xvi xvii xviii xix xx xxi xxii xxiii xxiv xxv xxvi xxvii]
|
10
|
+
ALPHA_UW = %w[0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
|
11
|
+
ALPHA_LW = %w[0 a b c d e f g h i j k l m n o p q r s t u v w x y z]
|
12
|
+
ROMAN_UW = %w[0 Ⅰ Ⅱ Ⅲ Ⅳ V Ⅵ Ⅶ Ⅷ Ⅸ X Ⅺ Ⅻ]
|
13
|
+
ARABIC_UW = %w[〇 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27]
|
14
|
+
ARABIC_LW = %w[〇 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27]
|
15
|
+
JAPAN = %w[〇 一 二 三 四 五 六 七 八 九 十 十一 十二 十三 十四 十五 十六 十七 十八 十九 二十 二十一 二十二 二十三 二十四 二十五 二十六 二十七]
|
16
|
+
|
6
17
|
def self.setup(locale="ja", ymlfile = "locale.yml")
|
7
18
|
@i18n = ReVIEW::I18n.new(locale)
|
8
19
|
|
@@ -11,8 +22,8 @@ module ReVIEW
|
|
11
22
|
lfile = File.expand_path(ymlfile, Dir.pwd)
|
12
23
|
|
13
24
|
# backward compatibility
|
14
|
-
if !File.exist?(lfile) && (ymlfile == "locale.yml")
|
15
|
-
|
25
|
+
if !File.exist?(lfile) && (ymlfile == "locale.yml") && File.exist?(File.expand_path("locale.yaml", Dir.pwd))
|
26
|
+
raise ReVIEW::ConfigError, "locale.yaml is obsoleted. Please use locale.yml."
|
16
27
|
end
|
17
28
|
end
|
18
29
|
|
@@ -38,13 +49,17 @@ module ReVIEW
|
|
38
49
|
end
|
39
50
|
|
40
51
|
class << self
|
41
|
-
|
52
|
+
alias_method :v, :t ## for EPUBMaker backward compatibility
|
42
53
|
end
|
43
54
|
|
44
55
|
def self.update(user_i18n, locale = nil)
|
45
56
|
@i18n.update(user_i18n, locale)
|
46
57
|
end
|
47
58
|
|
59
|
+
def self.get(word, locale = nil)
|
60
|
+
@i18n.get(word, locale)
|
61
|
+
end
|
62
|
+
|
48
63
|
attr_accessor :locale
|
49
64
|
|
50
65
|
def initialize(locale = nil)
|
@@ -53,7 +68,7 @@ module ReVIEW
|
|
53
68
|
end
|
54
69
|
|
55
70
|
def load_default
|
56
|
-
load_file(File.expand_path
|
71
|
+
load_file(File.expand_path("i18n.yml", File.dirname(__FILE__)))
|
57
72
|
end
|
58
73
|
|
59
74
|
def load_file(path)
|
@@ -65,7 +80,11 @@ module ReVIEW
|
|
65
80
|
locale = user_i18n["locale"]
|
66
81
|
if locale
|
67
82
|
user_i18n.delete("locale")
|
68
|
-
@store[locale]
|
83
|
+
if @store[locale]
|
84
|
+
@store[locale].merge!(user_i18n)
|
85
|
+
else
|
86
|
+
@store[locale] = user_i18n
|
87
|
+
end
|
69
88
|
else
|
70
89
|
user_i18n.each do |key, values|
|
71
90
|
raise KeyError, "Invalid locale file: #{path}" unless values.kind_of? Hash
|
@@ -83,8 +102,61 @@ module ReVIEW
|
|
83
102
|
end
|
84
103
|
end
|
85
104
|
|
105
|
+
def get(word, locale = nil)
|
106
|
+
locale ||= @locale
|
107
|
+
@store[locale][word]
|
108
|
+
end
|
109
|
+
|
86
110
|
def t(str, args = nil)
|
87
|
-
@store[@locale][str]
|
111
|
+
frmt = @store[@locale][str].dup
|
112
|
+
frmt.gsub!('%%', '##')
|
113
|
+
|
114
|
+
if !args.is_a?(Array)
|
115
|
+
if args.nil? && frmt !~ /\%/
|
116
|
+
args = []
|
117
|
+
else
|
118
|
+
args = [args]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
percents = frmt.scan(/%\w{1,3}/)
|
123
|
+
percents.each_with_index do |i, idx|
|
124
|
+
case i
|
125
|
+
when "%pA"
|
126
|
+
frmt.sub!(i, ALPHA_U[args[idx]])
|
127
|
+
args.delete idx
|
128
|
+
when "%pa"
|
129
|
+
frmt.sub!(i, ALPHA_L[args[idx]])
|
130
|
+
args.delete idx
|
131
|
+
when "%pAW"
|
132
|
+
frmt.sub!(i, ALPHA_UW[args[idx]])
|
133
|
+
args.delete idx
|
134
|
+
when "%paW"
|
135
|
+
frmt.sub!(i, ALPHA_LW[args[idx]])
|
136
|
+
args.delete idx
|
137
|
+
when "%pR"
|
138
|
+
frmt.sub!(i, ROMAN_U[args[idx]])
|
139
|
+
args.delete idx
|
140
|
+
when "%pr"
|
141
|
+
frmt.sub!(i, ROMAN_L[args[idx]])
|
142
|
+
args.delete idx
|
143
|
+
when "%pRW"
|
144
|
+
frmt.sub!(i, ROMAN_UW[args[idx]])
|
145
|
+
args.delete idx
|
146
|
+
when "%pJ"
|
147
|
+
frmt.sub!(i, JAPAN[args[idx]])
|
148
|
+
args.delete idx
|
149
|
+
when "%pdW"
|
150
|
+
frmt.sub!(i, ARABIC_LW[args[idx]])
|
151
|
+
args.delete idx
|
152
|
+
when "%pDW"
|
153
|
+
frmt.sub!(i, ARABIC_UW[args[idx]])
|
154
|
+
args.delete idx
|
155
|
+
end
|
156
|
+
end
|
157
|
+
args_matched = (frmt.count("%") == args.size)
|
158
|
+
frmt.gsub!('##', '%%')
|
159
|
+
args_matched ? (frmt % args) : frmt
|
88
160
|
rescue
|
89
161
|
str
|
90
162
|
end
|
data/lib/review/i18n.yml
CHANGED
@@ -9,7 +9,7 @@ ja:
|
|
9
9
|
chapter: 第%d章
|
10
10
|
chapter_postfix: " "
|
11
11
|
chapter_quote: "「%s」"
|
12
|
-
appendix: 付録%
|
12
|
+
appendix: 付録%pA
|
13
13
|
numberless_image: "図:"
|
14
14
|
memo_head: ■メモ
|
15
15
|
format_number: "%s.%d"
|
@@ -21,6 +21,7 @@ ja:
|
|
21
21
|
caption_prefix_idgxml: " "
|
22
22
|
ruby_prefix: "("
|
23
23
|
ruby_postfix: ")"
|
24
|
+
external_link: "%s(%s)"
|
24
25
|
label_marker: "●● "
|
25
26
|
aut: "著 者"
|
26
27
|
csl: "監 修"
|
@@ -30,8 +31,8 @@ ja:
|
|
30
31
|
edt: "編 集"
|
31
32
|
pht: "撮 影"
|
32
33
|
trl: "翻 訳"
|
33
|
-
## XXX
|
34
|
-
prt: "
|
34
|
+
## XXX Breaking Change: now `prt` is "印刷所", not "発行所"
|
35
|
+
prt: "印刷所"
|
35
36
|
pbl: "発行所"
|
36
37
|
contact: "連絡先"
|
37
38
|
author_with_label: "%s 著"
|
@@ -78,6 +79,7 @@ en:
|
|
78
79
|
image_quote: '"%s"'
|
79
80
|
caption_prefix: " "
|
80
81
|
caption_prefix_idgxml: " "
|
82
|
+
external_link: "%s (%s)"
|
81
83
|
ruby_prefix: "("
|
82
84
|
ruby_postfix: ")"
|
83
85
|
label_marker: "●● "
|
@@ -116,7 +118,7 @@ en:
|
|
116
118
|
profiletitle: "Profile"
|
117
119
|
backcovertitle: "Back Cover"
|
118
120
|
|
119
|
-
|
121
|
+
zh-TW:
|
120
122
|
image: 圖
|
121
123
|
table: 表
|
122
124
|
list: List
|
@@ -135,6 +137,7 @@ zh_TW:
|
|
135
137
|
caption_prefix_idgxml: " "
|
136
138
|
ruby_prefix: "("
|
137
139
|
ruby_postfix: ")"
|
140
|
+
external_link: "%s (%s)"
|
138
141
|
label_marker: "●● "
|
139
142
|
aut: "著作人"
|
140
143
|
csl: "監 修"
|
data/lib/review/idgxmlbuilder.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Copyright (c) 2002-2007 Minero Aoki
|
4
|
-
# 2008-
|
4
|
+
# 2008-2016 Minero Aoki, Kenshi Muto
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
7
|
# You can distribute or modify this program under the terms of
|
@@ -23,16 +23,10 @@ module ReVIEW
|
|
23
23
|
[:ttbold, :hint, :maru, :keytop, :labelref, :ref, :pageref, :balloon].each {|e| Compiler.definline(e) }
|
24
24
|
Compiler.defsingle(:dtp, 1)
|
25
25
|
|
26
|
-
Compiler.
|
27
|
-
Compiler.defblock(:memo, 0..1)
|
28
|
-
Compiler.defblock(:tip, 0..1)
|
29
|
-
Compiler.defblock(:info, 0..1)
|
26
|
+
Compiler.defblock(:insn, 0..1)
|
30
27
|
Compiler.defblock(:planning, 0..1)
|
31
28
|
Compiler.defblock(:best, 0..1)
|
32
|
-
Compiler.defblock(:important, 0..1)
|
33
29
|
Compiler.defblock(:security, 0..1)
|
34
|
-
Compiler.defblock(:caution, 0..1)
|
35
|
-
Compiler.defblock(:notice, 0..1)
|
36
30
|
Compiler.defblock(:point, 0..1)
|
37
31
|
Compiler.defblock(:shoot, 0..1)
|
38
32
|
Compiler.defblock(:reference, 0)
|
@@ -42,6 +36,14 @@ module ReVIEW
|
|
42
36
|
Compiler.defblock(:expert, 0)
|
43
37
|
Compiler.defblock(:rawblock, 0)
|
44
38
|
|
39
|
+
def pre_paragraph
|
40
|
+
'<p>'
|
41
|
+
end
|
42
|
+
|
43
|
+
def post_paragraph
|
44
|
+
'</p>'
|
45
|
+
end
|
46
|
+
|
45
47
|
def extname
|
46
48
|
'.xml'
|
47
49
|
end
|
@@ -61,22 +63,25 @@ module ReVIEW
|
|
61
63
|
@sec_counter = SecCounter.new(5, @chapter)
|
62
64
|
@column = 0
|
63
65
|
@noindent = nil
|
66
|
+
@ol_num = nil
|
64
67
|
@rootelement = "doc"
|
65
68
|
@secttags = nil
|
66
69
|
@tsize = nil
|
67
70
|
@texblockequation = 0
|
68
71
|
@texinlineequation = 0
|
72
|
+
print %Q(<?xml version="1.0" encoding="UTF-8"?>\n)
|
73
|
+
print %Q(<#{@rootelement} xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">)
|
74
|
+
@secttags = true unless @book.config["structuredxml"].nil?
|
75
|
+
end
|
76
|
+
private :builder_init_file
|
69
77
|
|
70
|
-
|
71
|
-
@output << %Q(<#{@rootelement} xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">)
|
78
|
+
def puts(arg)
|
72
79
|
if @book.config["nolf"].present?
|
73
|
-
|
80
|
+
print arg
|
74
81
|
else
|
75
|
-
|
82
|
+
super
|
76
83
|
end
|
77
|
-
@secttags = true unless @book.config["structuredxml"].nil?
|
78
84
|
end
|
79
|
-
private :builder_init_file
|
80
85
|
|
81
86
|
def result
|
82
87
|
s = ""
|
@@ -93,7 +98,7 @@ module ReVIEW
|
|
93
98
|
def warn(msg)
|
94
99
|
if @no_error
|
95
100
|
@warns.push [@location.filename, @location.lineno, msg]
|
96
|
-
|
101
|
+
puts "----WARNING: #{escape_html(msg)}----"
|
97
102
|
else
|
98
103
|
$stderr.puts "#{@location}: warning: #{msg}"
|
99
104
|
end
|
@@ -102,7 +107,7 @@ module ReVIEW
|
|
102
107
|
def error(msg)
|
103
108
|
if @no_error
|
104
109
|
@errors.push [@location.filename, @location.lineno, msg]
|
105
|
-
|
110
|
+
puts "----ERROR: #{escape_html(msg)}----"
|
106
111
|
else
|
107
112
|
$stderr.puts "#{@location}: error: #{msg}"
|
108
113
|
end
|
@@ -133,57 +138,63 @@ module ReVIEW
|
|
133
138
|
end
|
134
139
|
|
135
140
|
def headline(level, label, caption)
|
136
|
-
buf = ""
|
137
141
|
case level
|
138
142
|
when 1
|
139
143
|
unless @secttags.nil?
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
+
print "</sect4>" if @subsubsubsection > 0
|
145
|
+
print "</sect3>" if @subsubsection > 0
|
146
|
+
print "</sect2>" if @subsection > 0
|
147
|
+
print "</sect>" if @section > 0
|
144
148
|
end
|
145
|
-
|
149
|
+
|
150
|
+
print %Q(<chapter id="chap:#{@chapter.number}">) unless @secttags.nil?
|
151
|
+
|
146
152
|
@section = 0
|
147
153
|
@subsection = 0
|
148
154
|
@subsubsection = 0
|
149
155
|
@subsubsubsection = 0
|
150
156
|
when 2
|
151
157
|
unless @secttags.nil?
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
158
|
+
print "</sect4>" if @subsubsubsection > 0
|
159
|
+
print "</sect3>" if @subsubsection > 0
|
160
|
+
print "</sect2>" if @subsection > 0
|
161
|
+
print "</sect>" if @section > 0
|
156
162
|
end
|
157
163
|
@section += 1
|
158
|
-
|
164
|
+
print %Q(<sect id="sect:#{@chapter.number}.#{@section}">) unless @secttags.nil?
|
165
|
+
|
159
166
|
@subsection = 0
|
160
167
|
@subsubsection = 0
|
161
168
|
@subsubsubsection = 0
|
162
169
|
when 3
|
163
170
|
unless @secttags.nil?
|
164
|
-
|
165
|
-
|
166
|
-
|
171
|
+
print "</sect4>" if @subsubsubsection > 0
|
172
|
+
print "</sect3>" if @subsubsection > 0
|
173
|
+
print "</sect2>" if @subsection > 0
|
167
174
|
end
|
175
|
+
|
168
176
|
@subsection += 1
|
169
|
-
|
177
|
+
print %Q(<sect2 id="sect:#{@chapter.number}.#{@section}.#{@subsection}">) unless @secttags.nil?
|
178
|
+
|
170
179
|
@subsubsection = 0
|
171
180
|
@subsubsubsection = 0
|
172
181
|
when 4
|
173
182
|
unless @secttags.nil?
|
174
|
-
|
175
|
-
|
183
|
+
print "</sect4>" if @subsubsubsection > 0
|
184
|
+
print "</sect3>" if @subsubsection > 0
|
176
185
|
end
|
186
|
+
|
177
187
|
@subsubsection += 1
|
178
|
-
|
188
|
+
print %Q(<sect3 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}">) unless @secttags.nil?
|
189
|
+
|
179
190
|
@subsubsubsection = 0
|
180
191
|
when 5
|
181
192
|
unless @secttags.nil?
|
182
|
-
|
193
|
+
print "</sect4>" if @subsubsubsection > 0
|
183
194
|
end
|
184
195
|
|
185
196
|
@subsubsubsection += 1
|
186
|
-
|
197
|
+
print %Q(<sect4 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}">) unless @secttags.nil?
|
187
198
|
else
|
188
199
|
raise "caption level too deep or unsupported: #{level}"
|
189
200
|
end
|
@@ -191,68 +202,65 @@ module ReVIEW
|
|
191
202
|
prefix, anchor = headline_prefix(level)
|
192
203
|
|
193
204
|
label = label.nil? ? "" : " id=\"#{label}\""
|
194
|
-
toccaption = escape_html(caption.gsub(/@<fn>\{.+?\}/, '').gsub(/<[^>]+>/, ''))
|
195
|
-
|
196
|
-
|
197
|
-
buf
|
205
|
+
toccaption = escape_html(compile_inline(caption.gsub(/@<fn>\{.+?\}/, '')).gsub(/<[^>]+>/, ''))
|
206
|
+
puts %Q(<title#{label} aid:pstyle="h#{level}">#{prefix}#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{prefix}#{toccaption}"?>)
|
198
207
|
end
|
199
208
|
|
200
209
|
def ul_begin
|
201
210
|
level = block_given? ? yield : ""
|
202
211
|
level = nil if level == 1
|
203
|
-
"<ul#{level == 1 ? nil : level}>"
|
212
|
+
puts "<ul#{level == 1 ? nil : level}>"
|
204
213
|
end
|
205
214
|
|
206
215
|
def ul_item(lines)
|
207
|
-
%Q(<li aid:pstyle="ul-item">#{lines.join.chomp}</li>)
|
216
|
+
puts %Q(<li aid:pstyle="ul-item">#{lines.join.chomp}</li>)
|
208
217
|
end
|
209
218
|
|
210
219
|
def ul_item_begin(lines)
|
211
|
-
%Q(<li aid:pstyle="ul-item">#{lines.join.chomp})
|
220
|
+
print %Q(<li aid:pstyle="ul-item">#{lines.join.chomp})
|
212
221
|
end
|
213
222
|
|
214
223
|
def ul_item_end
|
215
|
-
"</li>"
|
224
|
+
puts "</li>"
|
216
225
|
end
|
217
226
|
|
218
227
|
def choice_single_begin
|
219
|
-
"<choice type='single'>"
|
228
|
+
puts "<choice type='single'>"
|
220
229
|
end
|
221
230
|
|
222
231
|
def choice_multi_begin
|
223
|
-
"<choice type='multi'>"
|
232
|
+
puts "<choice type='multi'>"
|
224
233
|
end
|
225
234
|
|
226
235
|
def choice_single_end
|
227
|
-
"</choice>"
|
236
|
+
puts "</choice>"
|
228
237
|
end
|
229
238
|
|
230
239
|
def choice_multi_end
|
231
|
-
"</choice>"
|
240
|
+
puts "</choice>"
|
232
241
|
end
|
233
242
|
|
234
243
|
def ul_end
|
235
244
|
level = block_given? ? yield : ""
|
236
245
|
level = nil if level == 1
|
237
|
-
"</ul#{level}>"
|
246
|
+
puts "</ul#{level}>"
|
238
247
|
end
|
239
248
|
|
240
249
|
def ol_begin
|
250
|
+
puts '<ol>'
|
241
251
|
if !@ol_num
|
242
252
|
@ol_num = 1
|
243
253
|
end
|
244
|
-
'<ol>' + @lf
|
245
254
|
end
|
246
255
|
|
247
256
|
def ol_item(lines, num)
|
248
|
-
|
257
|
+
puts %Q(<li aid:pstyle="ol-item" olnum="#{@ol_num}" num="#{num}">#{lines.join.chomp}</li>)
|
249
258
|
@ol_num += 1
|
250
|
-
buf
|
251
259
|
end
|
252
260
|
|
253
261
|
def ol_end
|
262
|
+
puts '</ol>'
|
254
263
|
@ol_num = nil
|
255
|
-
'</ol>' + @lf
|
256
264
|
end
|
257
265
|
|
258
266
|
def olnum(num)
|
@@ -260,43 +268,36 @@ module ReVIEW
|
|
260
268
|
end
|
261
269
|
|
262
270
|
def dl_begin
|
263
|
-
'<dl>'
|
271
|
+
puts '<dl>'
|
264
272
|
end
|
265
273
|
|
266
274
|
def dt(line)
|
267
|
-
"<dt>#{line}</dt>"
|
275
|
+
puts "<dt>#{line}</dt>"
|
268
276
|
end
|
269
277
|
|
270
278
|
def dd(lines)
|
271
|
-
"<dd>#{lines.join.chomp}</dd>"
|
279
|
+
puts "<dd>#{lines.join.chomp}</dd>"
|
272
280
|
end
|
273
281
|
|
274
282
|
def dl_end
|
275
|
-
'</dl>'
|
283
|
+
puts '</dl>'
|
276
284
|
end
|
277
285
|
|
278
286
|
def paragraph(lines)
|
279
|
-
buf = ""
|
280
287
|
if @noindent.nil?
|
281
288
|
if lines[0] =~ /\A(\t+)/
|
282
|
-
|
289
|
+
puts %Q(<p inlist="#{$1.size}">#{lines.join('').sub(/\A\t+/, "")}</p>)
|
283
290
|
else
|
284
|
-
|
291
|
+
puts "<p>#{lines.join}</p>"
|
285
292
|
end
|
286
293
|
else
|
287
|
-
|
294
|
+
puts %Q(<p aid:pstyle="noindent" noindent='1'>#{lines.join}</p>)
|
288
295
|
@noindent = nil
|
289
296
|
end
|
290
|
-
buf
|
291
297
|
end
|
292
298
|
|
293
299
|
def read(lines)
|
294
|
-
|
295
|
-
%Q[<lead>#{lines.join}</lead>] + @lf
|
296
|
-
else
|
297
|
-
str = lines.map{|l| l.sub(/^<p>/,"").sub(/<\/p>$/,"")}.join()
|
298
|
-
%Q[<p aid:pstyle="lead">#{str}</p>] + @lf
|
299
|
-
end
|
300
|
+
puts %Q[<lead>#{split_paragraph(lines).join}</lead>]
|
300
301
|
end
|
301
302
|
|
302
303
|
alias_method :lead, :read
|
@@ -307,15 +308,12 @@ module ReVIEW
|
|
307
308
|
end
|
308
309
|
private :column_label
|
309
310
|
|
310
|
-
def
|
311
|
+
def inline_column_chap(chapter, id)
|
311
312
|
if @book.config["chapterlink"]
|
312
|
-
%Q(<link href="#{column_label(id)}">#{escape_html(
|
313
|
+
%Q(<link href="#{column_label(id)}">#{escape_html(chapter.column(id).caption)}</link>)
|
313
314
|
else
|
314
|
-
escape_html(
|
315
|
+
escape_html(chapter.column(id).caption)
|
315
316
|
end
|
316
|
-
rescue KeyError
|
317
|
-
error "unknown column: #{id}"
|
318
|
-
nofunc_text("[UnknownColumn:#{id}]")
|
319
317
|
end
|
320
318
|
|
321
319
|
def inline_list(id)
|
@@ -328,40 +326,34 @@ module ReVIEW
|
|
328
326
|
end
|
329
327
|
|
330
328
|
def list_header(id, caption, lang)
|
331
|
-
|
332
|
-
buf << %Q[<codelist>] << @lf
|
329
|
+
puts %Q[<codelist>]
|
333
330
|
if get_chap.nil?
|
334
|
-
|
331
|
+
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>]
|
335
332
|
else
|
336
|
-
|
333
|
+
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>]
|
337
334
|
end
|
338
|
-
buf
|
339
335
|
end
|
340
336
|
|
341
337
|
def codelines_body(lines)
|
342
|
-
buf = ""
|
343
338
|
no = 1
|
344
339
|
lines.each do |line|
|
345
340
|
unless @book.config["listinfo"].nil?
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
341
|
+
print "<listinfo line=\"#{no}\""
|
342
|
+
print " begin=\"1\"" if no == 1
|
343
|
+
print " end=\"#{no}\"" if no == lines.size
|
344
|
+
print ">"
|
350
345
|
end
|
351
|
-
|
352
|
-
|
353
|
-
|
346
|
+
print detab(line)
|
347
|
+
print "\n"
|
348
|
+
print "</listinfo>" unless @book.config["listinfo"].nil?
|
354
349
|
no += 1
|
355
350
|
end
|
356
|
-
buf
|
357
351
|
end
|
358
352
|
|
359
353
|
def list_body(id, lines, lang)
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
buf << "</pre></codelist>" << @lf
|
364
|
-
buf
|
354
|
+
print %Q(<pre>)
|
355
|
+
codelines_body(lines)
|
356
|
+
puts "</pre></codelist>"
|
365
357
|
end
|
366
358
|
|
367
359
|
def emlist(lines, caption = nil, lang = nil)
|
@@ -371,30 +363,27 @@ module ReVIEW
|
|
371
363
|
def emlistnum(lines, caption = nil, lang = nil)
|
372
364
|
_lines = []
|
373
365
|
lines.each_with_index do |line, i|
|
374
|
-
line.chomp! ## new parser don't remove LF in table (code block)
|
375
366
|
_lines << detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
|
376
367
|
end
|
377
368
|
quotedlist _lines, 'emlistnum', caption
|
378
369
|
end
|
379
370
|
|
380
371
|
def listnum_body(lines, lang)
|
381
|
-
|
382
|
-
buf << %Q(<pre>)
|
372
|
+
print %Q(<pre>)
|
383
373
|
no = 1
|
384
374
|
lines.each_with_index do |line, i|
|
385
375
|
unless @book.config["listinfo"].nil?
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
376
|
+
print "<listinfo line=\"#{no}\""
|
377
|
+
print " begin=\"1\"" if no == 1
|
378
|
+
print " end=\"#{no}\"" if no == lines.size
|
379
|
+
print ">"
|
390
380
|
end
|
391
|
-
|
392
|
-
|
393
|
-
|
381
|
+
print detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
|
382
|
+
print "\n"
|
383
|
+
print "</listinfo>" unless @book.config["listinfo"].nil?
|
394
384
|
no += 1
|
395
385
|
end
|
396
|
-
|
397
|
-
buf
|
386
|
+
puts "</pre></codelist>"
|
398
387
|
end
|
399
388
|
|
400
389
|
def cmd(lines, caption = nil)
|
@@ -402,35 +391,29 @@ module ReVIEW
|
|
402
391
|
end
|
403
392
|
|
404
393
|
def quotedlist(lines, css_class, caption)
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
buf << %Q[<pre>]
|
394
|
+
print %Q[<list type='#{css_class}'>]
|
395
|
+
puts "<caption aid:pstyle='#{css_class}-title'>#{compile_inline(caption)}</caption>" unless caption.nil?
|
396
|
+
print %Q[<pre>]
|
409
397
|
no = 1
|
410
398
|
lines.each do |line|
|
411
399
|
unless @book.config["listinfo"].nil?
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
400
|
+
print "<listinfo line=\"#{no}\""
|
401
|
+
print " begin=\"1\"" if no == 1
|
402
|
+
print " end=\"#{no}\"" if no == lines.size
|
403
|
+
print ">"
|
416
404
|
end
|
417
|
-
|
418
|
-
|
419
|
-
|
405
|
+
print detab(line)
|
406
|
+
print "\n"
|
407
|
+
print "</listinfo>" unless @book.config["listinfo"].nil?
|
420
408
|
no += 1
|
421
409
|
end
|
422
|
-
|
423
|
-
buf
|
410
|
+
puts '</pre></list>'
|
424
411
|
end
|
425
412
|
private :quotedlist
|
426
413
|
|
427
414
|
def quote(lines)
|
428
|
-
|
429
|
-
|
430
|
-
else
|
431
|
-
str = lines.map{|l| l.sub(/^<p>/,"").sub(/<\/p>$/,"")}.join("\n")
|
432
|
-
"<quote>#{str}</quote>" + @lf
|
433
|
-
end
|
415
|
+
blocked_lines = split_paragraph(lines)
|
416
|
+
puts "<quote>#{blocked_lines.join("")}</quote>"
|
434
417
|
end
|
435
418
|
|
436
419
|
def inline_table(id)
|
@@ -474,59 +457,53 @@ module ReVIEW
|
|
474
457
|
end
|
475
458
|
|
476
459
|
def image_image(id, caption, metric=nil)
|
477
|
-
buf = ""
|
478
460
|
metrics = parse_metric("idgxml", metric)
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
buf
|
461
|
+
puts "<img>"
|
462
|
+
puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A.\//, "")}"#{metrics} />]
|
463
|
+
image_header id, caption
|
464
|
+
puts "</img>"
|
484
465
|
end
|
485
466
|
|
486
467
|
def image_dummy(id, caption, lines)
|
487
|
-
|
488
|
-
|
468
|
+
puts "<img>"
|
469
|
+
print %Q[<pre aid:pstyle="dummyimage">]
|
489
470
|
lines.each do |line|
|
490
|
-
|
491
|
-
|
471
|
+
print detab(line)
|
472
|
+
print "\n"
|
492
473
|
end
|
493
|
-
|
474
|
+
print %Q[</pre>]
|
494
475
|
image_header id, caption
|
495
|
-
|
476
|
+
puts "</img>"
|
496
477
|
warn "no such image: #{id}"
|
497
|
-
buf
|
498
478
|
end
|
499
479
|
|
500
480
|
def image_header(id, caption)
|
501
481
|
if get_chap.nil?
|
502
|
-
%Q[<caption>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}</caption>]
|
482
|
+
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>]
|
503
483
|
else
|
504
|
-
%Q[<caption>#{I18n.t("image")}#{I18n.t("format_number", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}</caption>]
|
484
|
+
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>]
|
505
485
|
end
|
506
486
|
end
|
507
487
|
|
508
488
|
def texequation(lines)
|
509
|
-
buf = ""
|
510
489
|
@texblockequation += 1
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
490
|
+
puts %Q[<replace idref="texblock-#{@texblockequation}">]
|
491
|
+
puts '<pre>'
|
492
|
+
puts "#{lines.join("\n")}"
|
493
|
+
puts '</pre>'
|
494
|
+
puts '</replace>'
|
516
495
|
end
|
517
496
|
|
518
497
|
def table(lines, id = nil, caption = nil)
|
519
|
-
buf = ""
|
520
498
|
tablewidth = nil
|
521
499
|
col = 0
|
522
|
-
|
523
|
-
tablewidth = @book.config["tableopt"].split(",")[0].to_f /
|
500
|
+
if @book.config["tableopt"]
|
501
|
+
tablewidth = @book.config["tableopt"].split(",")[0].to_f / @book.config["pt_to_mm_unit"].to_f
|
524
502
|
end
|
525
|
-
|
503
|
+
puts "<table>"
|
526
504
|
rows = []
|
527
505
|
sepidx = nil
|
528
506
|
lines.each_with_index do |line, idx|
|
529
|
-
line.chomp! ## new parser don't remove LF in table (code block)
|
530
507
|
if /\A[\=\-]{12}/ =~ line
|
531
508
|
sepidx ||= idx
|
532
509
|
next
|
@@ -548,8 +525,8 @@ module ReVIEW
|
|
548
525
|
cellwidth = @tsize.split(/\s*,\s*/)
|
549
526
|
totallength = 0
|
550
527
|
cellwidth.size.times do |n|
|
551
|
-
cellwidth[n] = cellwidth[n].to_f /
|
552
|
-
totallength
|
528
|
+
cellwidth[n] = cellwidth[n].to_f / @book.config["pt_to_mm_unit"].to_f
|
529
|
+
totallength += cellwidth[n]
|
553
530
|
warn "total length exceeds limit for table: #{id}" if totallength > tablewidth
|
554
531
|
end
|
555
532
|
if cellwidth.size < col
|
@@ -563,71 +540,66 @@ module ReVIEW
|
|
563
540
|
end
|
564
541
|
|
565
542
|
begin
|
566
|
-
|
543
|
+
table_header id, caption unless caption.nil?
|
567
544
|
rescue KeyError
|
568
545
|
error "no such table: #{id}"
|
569
546
|
end
|
570
547
|
return if rows.empty?
|
571
548
|
|
572
549
|
if tablewidth.nil?
|
573
|
-
|
550
|
+
print "<tbody>"
|
574
551
|
else
|
575
|
-
|
552
|
+
print %Q[<tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="#{rows.length}" aid:tcols="#{col}">]
|
576
553
|
end
|
577
554
|
|
578
555
|
if sepidx
|
579
556
|
sepidx.times do |y|
|
580
557
|
if tablewidth.nil?
|
581
|
-
|
558
|
+
puts %Q[<tr type="header">#{rows.shift}</tr>]
|
582
559
|
else
|
583
560
|
i = 0
|
584
561
|
rows.shift.split(/\t/).each_with_index do |cell, x|
|
585
|
-
|
562
|
+
print %Q[<td xyh="#{x + 1},#{y + 1},#{sepidx}" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.3f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
|
586
563
|
i += 1
|
587
564
|
end
|
588
565
|
end
|
589
566
|
end
|
590
567
|
end
|
591
|
-
|
592
|
-
|
568
|
+
trputs(tablewidth, rows, cellwidth, sepidx)
|
569
|
+
puts "</tbody></table>"
|
593
570
|
@tsize = nil
|
594
|
-
buf
|
595
571
|
end
|
596
572
|
|
597
573
|
def trputs(tablewidth, rows, cellwidth, sepidx)
|
598
|
-
buf = ""
|
599
574
|
sepidx = 0 if sepidx.nil?
|
600
575
|
if tablewidth.nil?
|
601
576
|
lastline = rows.pop
|
602
|
-
rows.each {|row|
|
603
|
-
|
577
|
+
rows.each {|row| puts %Q[<tr>#{row}</tr>] }
|
578
|
+
puts %Q[<tr type="lastline">#{lastline}</tr>] unless lastline.nil?
|
604
579
|
else
|
605
580
|
rows.each_with_index do |row, y|
|
606
581
|
i = 0
|
607
582
|
row.split(/\t/).each_with_index do |cell, x|
|
608
|
-
|
583
|
+
print %Q[<td xyh="#{x + 1},#{y + 1 + sepidx},#{sepidx}" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.3f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
|
609
584
|
i += 1
|
610
585
|
end
|
611
586
|
end
|
612
587
|
end
|
613
|
-
buf
|
614
588
|
end
|
615
589
|
|
616
590
|
def table_header(id, caption)
|
617
|
-
buf = ""
|
618
591
|
if get_chap.nil?
|
619
|
-
|
592
|
+
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>]
|
620
593
|
else
|
621
|
-
|
594
|
+
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>]
|
622
595
|
end
|
623
|
-
buf
|
624
596
|
end
|
625
597
|
|
626
598
|
def table_begin(ncols)
|
627
599
|
end
|
628
600
|
|
629
601
|
def tr(rows)
|
630
|
-
%Q[<tr>#{rows.join("\t")}</tr>]
|
602
|
+
puts %Q[<tr>#{rows.join("\t")}</tr>]
|
631
603
|
end
|
632
604
|
|
633
605
|
def th(str)
|
@@ -639,11 +611,24 @@ module ReVIEW
|
|
639
611
|
end
|
640
612
|
|
641
613
|
def table_end
|
642
|
-
"<?dtp tablerow last?>"
|
614
|
+
print "<?dtp tablerow last?>"
|
615
|
+
end
|
616
|
+
|
617
|
+
def imgtable(lines, id, caption = nil, metric = nil)
|
618
|
+
if @chapter.image(id).bound?
|
619
|
+
metrics = parse_metric("idgxml", metric)
|
620
|
+
puts "<table>"
|
621
|
+
table_header id, caption
|
622
|
+
puts %Q[<imgtable><Image href="file://#{@chapter.image(id).path.sub(/\A.\//, "")}"#{metrics} /></imgtable>]
|
623
|
+
puts "</table>"
|
624
|
+
else
|
625
|
+
warn "image not bound: #{id}" if @strict
|
626
|
+
image_dummy id, caption, lines
|
627
|
+
end
|
643
628
|
end
|
644
629
|
|
645
630
|
def comment(str)
|
646
|
-
%Q(<!-- [Comment] #{escape_html(str)} -->)
|
631
|
+
print %Q(<!-- [Comment] #{escape_html(str)} -->)
|
647
632
|
end
|
648
633
|
|
649
634
|
def footnote(id, str)
|
@@ -651,7 +636,7 @@ module ReVIEW
|
|
651
636
|
end
|
652
637
|
|
653
638
|
def inline_fn(id)
|
654
|
-
%Q[<footnote>#{@chapter.footnote(id).content.strip}</footnote>]
|
639
|
+
%Q[<footnote>#{compile_inline(@chapter.footnote(id).content.strip)}</footnote>]
|
655
640
|
end
|
656
641
|
|
657
642
|
def compile_ruby(base, ruby)
|
@@ -661,13 +646,13 @@ module ReVIEW
|
|
661
646
|
def compile_kw(word, alt)
|
662
647
|
'<keyword>' +
|
663
648
|
if alt
|
664
|
-
then ("#{word}(#{alt.strip})")
|
665
|
-
else (word)
|
649
|
+
then escape_html("#{word}(#{alt.strip})")
|
650
|
+
else escape_html(word)
|
666
651
|
end +
|
667
652
|
'</keyword>' +
|
668
|
-
%Q[<index value="#{word}" />] +
|
653
|
+
%Q[<index value="#{escape_html(word)}" />] +
|
669
654
|
if alt
|
670
|
-
alt.split(/\s*,\s*/).collect! {|e| %Q[<index value="#{(e.strip)}" />] }.join
|
655
|
+
alt.split(/\s*,\s*/).collect! {|e| %Q[<index value="#{escape_html(e.strip)}" />] }.join
|
671
656
|
else
|
672
657
|
""
|
673
658
|
end
|
@@ -738,11 +723,11 @@ module ReVIEW
|
|
738
723
|
end
|
739
724
|
|
740
725
|
def inline_tt(str)
|
741
|
-
%Q(<tt>#{str}</tt>)
|
726
|
+
%Q(<tt>#{escape_html(str)}</tt>)
|
742
727
|
end
|
743
728
|
|
744
729
|
def inline_ttb(str)
|
745
|
-
%Q(<tt style='bold'>#{str}</tt>)
|
730
|
+
%Q(<tt style='bold'>#{escape_html(str)}</tt>)
|
746
731
|
end
|
747
732
|
|
748
733
|
alias_method :inline_ttbold, :inline_ttb
|
@@ -773,13 +758,13 @@ module ReVIEW
|
|
773
758
|
end
|
774
759
|
|
775
760
|
def inline_labelref(idref)
|
776
|
-
%Q[<ref idref='#{(idref)}'>「#{I18n.t("label_marker")}#{(idref)}」</ref>] # FIXME:節名とタイトルも込みで要出力
|
761
|
+
%Q[<ref idref='#{escape_html(idref)}'>「#{I18n.t("label_marker")}#{escape_html(idref)}」</ref>] # FIXME:節名とタイトルも込みで要出力
|
777
762
|
end
|
778
763
|
|
779
764
|
alias_method :inline_ref, :inline_labelref
|
780
765
|
|
781
766
|
def inline_pageref(idref)
|
782
|
-
%Q[<pageref idref='#{(idref)}'>●●</pageref>] # ページ番号を参照
|
767
|
+
%Q[<pageref idref='#{escape_html(idref)}'>●●</pageref>] # ページ番号を参照
|
783
768
|
end
|
784
769
|
|
785
770
|
def inline_balloon(str)
|
@@ -797,43 +782,40 @@ module ReVIEW
|
|
797
782
|
|
798
783
|
def noindent
|
799
784
|
@noindent = true
|
800
|
-
""
|
801
785
|
end
|
802
786
|
|
803
787
|
def linebreak
|
804
788
|
# FIXME:pが閉じちゃってるので一度戻らないといけないが、難しい…。
|
805
|
-
"<br />"
|
789
|
+
puts "<br />"
|
806
790
|
end
|
807
791
|
|
808
792
|
def pagebreak
|
809
|
-
"<pagebreak />"
|
793
|
+
puts "<pagebreak />"
|
810
794
|
end
|
811
795
|
|
812
796
|
def nonum_begin(level, label, caption)
|
813
|
-
%Q[<title aid:pstyle="h#{level}">#{caption}</title><?dtp level="#{level}" section="#{escape_html(caption)}"?>]
|
797
|
+
puts %Q[<title aid:pstyle="h#{level}">#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{escape_html(compile_inline(caption))}"?>]
|
814
798
|
end
|
815
799
|
|
816
800
|
def nonum_end(level)
|
817
801
|
end
|
818
802
|
|
819
803
|
def circle_begin(level, label, caption)
|
820
|
-
%Q[<title aid:pstyle="smallcircle">•#{caption}</title>]
|
804
|
+
puts %Q[<title aid:pstyle="smallcircle">•#{compile_inline(caption)}</title>]
|
821
805
|
end
|
822
806
|
|
823
807
|
def circle_end(level)
|
824
808
|
end
|
825
809
|
|
826
810
|
def common_column_begin(type, caption)
|
827
|
-
buf = ""
|
828
811
|
@column += 1
|
829
812
|
a_id = %Q[id="column-#{@column}"]
|
830
|
-
|
831
|
-
|
832
|
-
buf
|
813
|
+
print "<#{type}column #{a_id}>"
|
814
|
+
puts %Q[<title aid:pstyle="#{type}column-title">#{compile_inline(caption)}</title>]
|
833
815
|
end
|
834
816
|
|
835
817
|
def common_column_end(type)
|
836
|
-
"</#{type}column>"
|
818
|
+
puts "</#{type}column>"
|
837
819
|
end
|
838
820
|
|
839
821
|
def column_begin(level, label, caption)
|
@@ -886,53 +868,42 @@ module ReVIEW
|
|
886
868
|
|
887
869
|
def ref_begin(level, label, caption)
|
888
870
|
if !label.nil?
|
889
|
-
"<reference id='#{label}'>"
|
871
|
+
puts "<reference id='#{label}'>"
|
890
872
|
else
|
891
|
-
"<reference>"
|
873
|
+
puts "<reference>"
|
892
874
|
end
|
893
875
|
end
|
894
876
|
|
895
877
|
def ref_end(level)
|
896
|
-
"</reference>"
|
878
|
+
puts "</reference>"
|
897
879
|
end
|
898
880
|
|
899
881
|
def sup_begin(level, label, caption)
|
900
882
|
if !label.nil?
|
901
|
-
"<supplement id='#{label}'>"
|
883
|
+
puts "<supplement id='#{label}'>"
|
902
884
|
else
|
903
|
-
"<supplement>"
|
885
|
+
puts "<supplement>"
|
904
886
|
end
|
905
887
|
end
|
906
888
|
|
907
889
|
def sup_end(level)
|
908
|
-
"</supplement>"
|
890
|
+
puts "</supplement>"
|
909
891
|
end
|
910
892
|
|
911
893
|
def flushright(lines)
|
912
|
-
|
913
|
-
lines.join("").gsub("<p>", "<p align='right'>") + @lf
|
914
|
-
else
|
915
|
-
str = lines.map{|l| l.sub(/^<p>/,"").sub(/<\/p>$/,"")}.join("\n")
|
916
|
-
"<p align='right'>#{str}</p>" + @lf
|
917
|
-
end
|
894
|
+
puts split_paragraph(lines).join.gsub("<p>", "<p align='right'>")
|
918
895
|
end
|
919
896
|
|
920
897
|
def centering(lines)
|
921
|
-
lines.join
|
898
|
+
puts split_paragraph(lines).join.gsub("<p>", "<p align='center'>")
|
922
899
|
end
|
923
900
|
|
924
901
|
def captionblock(type, lines, caption, specialstyle = nil)
|
925
|
-
|
926
|
-
buf << "<#{type}>"
|
902
|
+
print "<#{type}>"
|
927
903
|
style = specialstyle.nil? ? "#{type}-title" : specialstyle
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
else
|
932
|
-
str = lines.map{|l| l.sub(/^<p>/,"").sub(/<\/p>$/,"")}.join("\n")
|
933
|
-
buf << "#{str}</#{type}>" << @lf
|
934
|
-
end
|
935
|
-
buf
|
904
|
+
puts "<title aid:pstyle='#{style}'>#{compile_inline(caption)}</title>" unless caption.nil?
|
905
|
+
blocked_lines = split_paragraph(lines)
|
906
|
+
puts "#{blocked_lines.join}</#{type}>"
|
936
907
|
end
|
937
908
|
|
938
909
|
def note(lines, caption = nil)
|
@@ -971,6 +942,10 @@ module ReVIEW
|
|
971
942
|
captionblock("caution", lines, caption)
|
972
943
|
end
|
973
944
|
|
945
|
+
def warning(lines, caption = nil)
|
946
|
+
captionblock("warning", lines, caption)
|
947
|
+
end
|
948
|
+
|
974
949
|
def term(lines)
|
975
950
|
captionblock("term", lines, nil)
|
976
951
|
end
|
@@ -1016,9 +991,8 @@ module ReVIEW
|
|
1016
991
|
end
|
1017
992
|
|
1018
993
|
def syntaxblock(type, lines, caption)
|
1019
|
-
buf = ""
|
1020
994
|
if caption.nil?
|
1021
|
-
|
995
|
+
puts %Q[<#{type}>]
|
1022
996
|
else
|
1023
997
|
titleopentag = %Q[caption aid:pstyle="#{type}-title"]
|
1024
998
|
titleclosetag = "caption"
|
@@ -1026,24 +1000,22 @@ module ReVIEW
|
|
1026
1000
|
titleopentag = %Q[floattitle type="insn"]
|
1027
1001
|
titleclosetag = "floattitle"
|
1028
1002
|
end
|
1029
|
-
|
1003
|
+
puts %Q[<#{type}><#{titleopentag}>#{compile_inline(caption)}</#{titleclosetag}>]
|
1030
1004
|
end
|
1031
1005
|
no = 1
|
1032
1006
|
lines.each do |line|
|
1033
|
-
line.chomp!
|
1034
1007
|
unless @book.config["listinfo"].nil?
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1008
|
+
print %Q[<listinfo line="#{no}"]
|
1009
|
+
print %Q[ begin="1"] if no == 1
|
1010
|
+
print %Q[ end="#{no}"] if no == lines.size
|
1011
|
+
print %Q[>]
|
1039
1012
|
end
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1013
|
+
print detab(line)
|
1014
|
+
print "\n"
|
1015
|
+
print "</listinfo>" unless @book.config["listinfo"].nil?
|
1043
1016
|
no += 1
|
1044
1017
|
end
|
1045
|
-
|
1046
|
-
buf
|
1018
|
+
puts "</#{type}>"
|
1047
1019
|
end
|
1048
1020
|
|
1049
1021
|
def insn(lines, caption = nil)
|
@@ -1055,24 +1027,22 @@ module ReVIEW
|
|
1055
1027
|
end
|
1056
1028
|
|
1057
1029
|
def indepimage(id, caption=nil, metric=nil)
|
1058
|
-
buf = ""
|
1059
1030
|
metrics = parse_metric("idgxml", metric)
|
1060
|
-
|
1031
|
+
puts "<img>"
|
1061
1032
|
begin
|
1062
|
-
|
1033
|
+
puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}"#{metrics} />]
|
1063
1034
|
rescue
|
1064
1035
|
warn %Q[no such image: #{id}]
|
1065
1036
|
end
|
1066
|
-
|
1067
|
-
|
1068
|
-
buf
|
1037
|
+
puts %Q[<caption>#{compile_inline(caption)}</caption>] if caption.present?
|
1038
|
+
puts "</img>"
|
1069
1039
|
end
|
1070
1040
|
|
1071
1041
|
alias_method :numberlessimage, :indepimage
|
1072
1042
|
|
1073
1043
|
def label(id)
|
1074
1044
|
# FIXME
|
1075
|
-
"<label id='#{id}' />"
|
1045
|
+
print "<label id='#{id}' />"
|
1076
1046
|
end
|
1077
1047
|
|
1078
1048
|
def tsize(str)
|
@@ -1080,15 +1050,15 @@ module ReVIEW
|
|
1080
1050
|
end
|
1081
1051
|
|
1082
1052
|
def dtp(str)
|
1083
|
-
%Q(<?dtp #{str} ?>)
|
1053
|
+
print %Q(<?dtp #{str} ?>)
|
1084
1054
|
end
|
1085
1055
|
|
1086
1056
|
def hr
|
1087
|
-
"<hr />"
|
1057
|
+
print "<hr />"
|
1088
1058
|
end
|
1089
1059
|
|
1090
1060
|
def bpo(lines)
|
1091
|
-
%Q[<bpo>#{lines.join("\n")}</bpo>]
|
1061
|
+
puts %Q[<bpo>#{lines.join("\n")}</bpo>]
|
1092
1062
|
end
|
1093
1063
|
|
1094
1064
|
def inline_dtp(str)
|
@@ -1104,14 +1074,12 @@ module ReVIEW
|
|
1104
1074
|
end
|
1105
1075
|
|
1106
1076
|
def rawblock(lines)
|
1107
|
-
buf = ""
|
1108
1077
|
no = 1
|
1109
1078
|
lines.each do |l|
|
1110
|
-
|
1111
|
-
|
1112
|
-
no
|
1079
|
+
print l.gsub("<", "<").gsub(">", ">").gsub(""", "\"").gsub("&", "&")
|
1080
|
+
print "\n" unless lines.length == no
|
1081
|
+
no += 1
|
1113
1082
|
end
|
1114
|
-
buf
|
1115
1083
|
end
|
1116
1084
|
|
1117
1085
|
def text(str)
|
@@ -1121,8 +1089,7 @@ module ReVIEW
|
|
1121
1089
|
def inline_chapref(id)
|
1122
1090
|
chs = ["", "「", "」"]
|
1123
1091
|
unless @book.config["chapref"].nil?
|
1124
|
-
_chs =
|
1125
|
-
@book.config["inencoding"]).split(",")
|
1092
|
+
_chs = @book.config["chapref"].split(",")
|
1126
1093
|
if _chs.size != 3
|
1127
1094
|
error "--chapsplitter must have exactly 3 parameters with comma."
|
1128
1095
|
else
|
@@ -1165,39 +1132,31 @@ module ReVIEW
|
|
1165
1132
|
end
|
1166
1133
|
|
1167
1134
|
def source_header(caption)
|
1168
|
-
|
1169
|
-
|
1170
|
-
buf << %Q[<caption>#{caption}</caption>] << @lf
|
1171
|
-
buf
|
1135
|
+
puts %Q[<source>]
|
1136
|
+
puts %Q[<caption>#{compile_inline(caption)}</caption>]
|
1172
1137
|
end
|
1173
1138
|
|
1174
|
-
def source_body(lines)
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
buf << %Q[</pre></source>] << @lf
|
1179
|
-
buf
|
1139
|
+
def source_body(lines, lang)
|
1140
|
+
puts %Q[<pre>]
|
1141
|
+
codelines_body(lines)
|
1142
|
+
puts %Q[</pre></source>]
|
1180
1143
|
end
|
1181
1144
|
|
1182
1145
|
def bibpaper(lines, id, caption)
|
1183
|
-
|
1184
|
-
buf << bibpaper_header(id, caption)
|
1146
|
+
bibpaper_header id, caption
|
1185
1147
|
unless lines.empty?
|
1186
|
-
|
1148
|
+
bibpaper_bibpaper id, caption, lines
|
1187
1149
|
end
|
1188
|
-
|
1189
|
-
buf
|
1150
|
+
puts %Q(</bibitem>)
|
1190
1151
|
end
|
1191
1152
|
|
1192
1153
|
def bibpaper_header(id, caption)
|
1193
|
-
|
1194
|
-
|
1195
|
-
buf << "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{caption}</caption>" << @lf
|
1196
|
-
buf
|
1154
|
+
puts %Q(<bibitem id="bib-#{id}">)
|
1155
|
+
puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{compile_inline(caption)}</caption>"
|
1197
1156
|
end
|
1198
1157
|
|
1199
1158
|
def bibpaper_bibpaper(id, caption, lines)
|
1200
|
-
|
1159
|
+
print split_paragraph(lines).join("")
|
1201
1160
|
end
|
1202
1161
|
|
1203
1162
|
def inline_bib(id)
|
@@ -1208,10 +1167,10 @@ module ReVIEW
|
|
1208
1167
|
if chap.number
|
1209
1168
|
n = chap.headline_index.number(id)
|
1210
1169
|
if @book.config["secnolevel"] >= n.split('.').size
|
1211
|
-
return I18n.t("chapter_quote", "#{n} #{chap.headline(id).caption}")
|
1170
|
+
return I18n.t("chapter_quote", "#{n} #{compile_inline(chap.headline(id).caption)}")
|
1212
1171
|
end
|
1213
1172
|
end
|
1214
|
-
I18n.t("chapter_quote", chap.headline(id).caption)
|
1173
|
+
I18n.t("chapter_quote", compile_inline(chap.headline(id).caption))
|
1215
1174
|
end
|
1216
1175
|
|
1217
1176
|
def inline_recipe(id)
|
@@ -1229,4 +1188,4 @@ module ReVIEW
|
|
1229
1188
|
|
1230
1189
|
end
|
1231
1190
|
|
1232
|
-
end
|
1191
|
+
end # module ReVIEW
|