review 2.3.0 → 2.4.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 +4 -4
- data/.rubocop.yml +90 -66
- data/.travis.yml +1 -1
- data/Gemfile +0 -1
- data/NEWS.ja.md +82 -0
- data/NEWS.md +83 -0
- data/README.md +5 -3
- data/Rakefile +8 -8
- data/bin/review +1 -5
- data/bin/review-catalog-converter +22 -27
- data/bin/review-check +36 -43
- data/bin/review-checkdep +10 -15
- data/bin/review-compile +37 -55
- data/bin/review-epubmaker +4 -5
- data/bin/review-index +21 -29
- data/bin/review-init +26 -37
- data/bin/review-pdfmaker +0 -2
- data/bin/review-preproc +25 -45
- data/bin/review-validate +19 -18
- data/bin/review-vol +15 -27
- data/doc/config.yml.sample +5 -2
- data/doc/format.ja.md +20 -1
- data/doc/format.md +21 -5
- data/doc/images/review-generate.png +0 -0
- data/lib/epubmaker.rb +1 -3
- data/lib/epubmaker/content.rb +24 -27
- data/lib/epubmaker/epubcommon.rb +135 -148
- data/lib/epubmaker/epubv2.rb +39 -46
- data/lib/epubmaker/epubv3.rb +93 -103
- data/lib/epubmaker/producer.rb +138 -151
- data/lib/epubmaker/zip_exporter.rb +21 -26
- data/lib/review/book.rb +3 -6
- data/lib/review/book/base.rb +78 -103
- data/lib/review/book/chapter.rb +36 -40
- data/lib/review/book/compilable.rb +28 -31
- data/lib/review/book/image_finder.rb +6 -13
- data/lib/review/book/index.rb +100 -121
- data/lib/review/book/page_metric.rb +2 -7
- data/lib/review/book/part.rb +18 -20
- data/lib/review/book/volume.rb +9 -13
- data/lib/review/builder.rb +81 -116
- data/lib/review/catalog.rb +15 -19
- data/lib/review/compiler.rb +64 -83
- data/lib/review/configure.rb +87 -97
- data/lib/review/converter.rb +2 -7
- data/lib/review/epubbuilder.rb +1 -3
- data/lib/review/epubmaker.rb +213 -205
- data/lib/review/exception.rb +2 -4
- data/lib/review/extentions.rb +0 -1
- data/lib/review/extentions/hash.rb +2 -2
- data/lib/review/extentions/string.rb +5 -30
- data/lib/review/htmlbuilder.rb +320 -375
- data/lib/review/htmltoc.rb +4 -7
- data/lib/review/htmlutils.rb +29 -32
- data/lib/review/i18n.rb +33 -44
- data/lib/review/i18n.yml +3 -3
- data/lib/review/idgxmlbuilder.rb +309 -345
- data/lib/review/latexbuilder.rb +175 -212
- data/lib/review/latexindex.rb +2 -8
- data/lib/review/latexutils.rb +33 -43
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/logger.rb +21 -0
- data/lib/review/makerhelper.rb +1 -4
- data/lib/review/markdownbuilder.rb +44 -53
- data/lib/review/md2inaobuilder.rb +6 -12
- data/lib/review/pdfmaker.rb +143 -173
- data/lib/review/preprocessor.rb +64 -101
- data/lib/review/rstbuilder.rb +126 -158
- data/lib/review/sec_counter.rb +18 -34
- data/lib/review/template.rb +4 -5
- data/lib/review/textbuilder.rb +2 -3
- data/lib/review/textutils.rb +7 -13
- data/lib/review/tocparser.rb +31 -56
- data/lib/review/tocprinter.rb +26 -52
- data/lib/review/topbuilder.rb +219 -247
- data/lib/review/unfold.rb +15 -24
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +75 -99
- data/lib/review/webtocprinter.rb +15 -20
- data/lib/review/yamlloader.rb +13 -15
- data/review.gemspec +20 -22
- data/templates/latex/layout.tex.erb +2 -2
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/black.eps +280 -0
- data/test/assets/fit.png +0 -0
- data/test/assets/large.gif +0 -0
- data/test/assets/large.jpg +0 -0
- data/test/assets/large.png +0 -0
- data/test/assets/large.svg +65 -0
- data/test/assets/test_template.tex +1 -1
- data/test/book_test_helper.rb +2 -2
- data/test/run_test.rb +4 -4
- data/test/sample-book/src/Rakefile +21 -22
- data/test/syntax-book/Gemfile +4 -0
- data/test/syntax-book/Rakefile +72 -0
- data/test/syntax-book/appA.re +22 -0
- data/test/syntax-book/bib.re +6 -0
- data/test/syntax-book/catalog.yml +15 -0
- data/test/syntax-book/ch01.re +136 -0
- data/test/syntax-book/ch02.re +351 -0
- data/test/syntax-book/ch03.re +82 -0
- data/test/syntax-book/config.yml +35 -0
- data/test/syntax-book/images/ball.png +0 -0
- data/test/syntax-book/images/cover.jpg +0 -0
- data/test/syntax-book/images/fractal.png +0 -0
- data/test/syntax-book/images/img3-1.png +0 -0
- data/test/syntax-book/images/inlineicon.jpg +0 -0
- data/test/syntax-book/images/logic.png +0 -0
- data/test/syntax-book/images/logic2.png +0 -0
- data/test/syntax-book/images/puzzle.jpg +0 -0
- data/test/syntax-book/images/table.jpg +0 -0
- data/test/syntax-book/part2.re +6 -0
- data/test/syntax-book/pre01.re +26 -0
- data/test/syntax-book/review-ext.rb +14 -0
- data/test/syntax-book/sty/jumoline.sty +310 -0
- data/test/syntax-book/sty/reviewmacro.sty +39 -0
- data/test/syntax-book/style.css +494 -0
- data/test/syntax-book/syntax.dic +2 -0
- data/test/test_book.rb +106 -111
- data/test/test_book_chapter.rb +21 -22
- data/test/test_book_part.rb +3 -5
- data/test/test_builder.rb +11 -22
- data/test/test_catalog.rb +17 -18
- data/test/test_catalog_converter_cmd.rb +5 -5
- data/test/test_compiler.rb +18 -16
- data/test/test_configure.rb +35 -38
- data/test/test_converter.rb +3 -4
- data/test/test_epub3maker.rb +136 -117
- data/test/test_epubmaker.rb +107 -114
- data/test/test_epubmaker_cmd.rb +2 -4
- data/test/test_extentions_hash.rb +32 -33
- data/test/test_helper.rb +9 -11
- data/test/test_htmlbuilder.rb +454 -420
- data/test/test_htmltoc.rb +8 -12
- data/test/test_htmlutils.rb +0 -2
- data/test/test_i18n.rb +159 -150
- data/test/test_idgxmlbuilder.rb +190 -197
- data/test/test_image_finder.rb +21 -22
- data/test/test_index.rb +24 -29
- data/test/test_latexbuilder.rb +274 -264
- data/test/test_lineinput.rb +7 -10
- data/test/test_location.rb +7 -7
- data/test/test_makerhelper.rb +13 -25
- data/test/test_markdownbuilder.rb +23 -26
- data/test/test_md2inaobuilder.rb +8 -11
- data/test/test_pdfmaker.rb +114 -123
- data/test/test_pdfmaker_cmd.rb +1 -3
- data/test/test_review_ext.rb +3 -5
- data/test/test_rstbuilder.rb +92 -97
- data/test/test_template.rb +3 -7
- data/test/test_textutils.rb +27 -27
- data/test/test_tocparser.rb +2 -2
- data/test/test_topbuilder.rb +98 -103
- data/test/test_webtocprinter.rb +5 -6
- data/test/test_yamlloader.rb +42 -42
- data/test/test_zip_exporter.rb +12 -18
- metadata +86 -9
- data/lib/review/ewbbuilder.rb +0 -382
data/lib/review/exception.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Copyright (c) 2002-2007 Minero Aoki
|
|
2
|
+
# Copyright (c) 2007-2017 Minero Aoki, Kenshi Muto
|
|
3
|
+
# 2002-2007 Minero Aoki
|
|
5
4
|
#
|
|
6
5
|
# This program is free software.
|
|
7
6
|
# You can distribute or modify this program under the terms of
|
|
@@ -10,7 +9,6 @@
|
|
|
10
9
|
#
|
|
11
10
|
|
|
12
11
|
module ReVIEW
|
|
13
|
-
|
|
14
12
|
class Error < ::StandardError; end
|
|
15
13
|
class ApplicationError < Error; end
|
|
16
14
|
class ConfigError < ApplicationError; end
|
data/lib/review/extentions.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class Hash
|
|
2
2
|
def deep_merge!(other)
|
|
3
|
-
self.merge!(other) do |
|
|
4
|
-
if v_self.
|
|
3
|
+
self.merge!(other) do |_key, v_self, v_other|
|
|
4
|
+
if v_self.is_a?(Hash) && v_other.is_a?(Hash)
|
|
5
5
|
v_self.deep_merge(v_other)
|
|
6
6
|
else
|
|
7
7
|
v_other
|
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
if defined?(Encoding) && Encoding.respond_to?(
|
|
1
|
+
if defined?(Encoding) && Encoding.respond_to?('default_external') &&
|
|
2
2
|
Encoding.default_external != Encoding::UTF_8
|
|
3
|
-
Encoding.default_external =
|
|
3
|
+
Encoding.default_external = 'UTF-8'
|
|
4
4
|
end
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
alias_method :lines, :to_a
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
if String.method_defined?(:bytesize)
|
|
14
|
-
# Ruby 1.9
|
|
15
|
-
class String
|
|
16
|
-
alias_method :charsize, :size
|
|
17
|
-
end
|
|
18
|
-
else
|
|
19
|
-
# Ruby 1.8
|
|
20
|
-
class String
|
|
21
|
-
alias_method :bytesize, :size
|
|
22
|
-
|
|
23
|
-
def charsize
|
|
24
|
-
split(//).size
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
unless String.method_defined?(:each)
|
|
30
|
-
# Ruby 1.9
|
|
31
|
-
class String
|
|
32
|
-
alias_method :each, :each_line
|
|
33
|
-
end
|
|
6
|
+
class String
|
|
7
|
+
alias_method :charsize, :size
|
|
8
|
+
alias_method :each, :each_line
|
|
34
9
|
end
|
data/lib/review/htmlbuilder.rb
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2002-2007 Minero Aoki
|
|
4
|
-
# 2008-2017 Minero Aoki, Kenshi Muto, Masayoshi Takahashi,
|
|
1
|
+
# Copyright (c) 2008-2017 Minero Aoki, Kenshi Muto, Masayoshi Takahashi,
|
|
5
2
|
# KADO Masanori
|
|
3
|
+
# 2002-2007 Minero Aoki
|
|
6
4
|
#
|
|
7
5
|
# This program is free software.
|
|
8
6
|
# You can distribute or modify this program under the terms of
|
|
@@ -18,13 +16,11 @@ require 'digest'
|
|
|
18
16
|
require 'tmpdir'
|
|
19
17
|
|
|
20
18
|
module ReVIEW
|
|
21
|
-
|
|
22
19
|
class HTMLBuilder < Builder
|
|
23
|
-
|
|
24
20
|
include TextUtils
|
|
25
21
|
include HTMLUtils
|
|
26
22
|
|
|
27
|
-
[:ref].each {|e| Compiler.definline(e) }
|
|
23
|
+
[:ref].each { |e| Compiler.definline(e) }
|
|
28
24
|
Compiler.defblock(:planning, 0..1)
|
|
29
25
|
Compiler.defblock(:best, 0..1)
|
|
30
26
|
Compiler.defblock(:security, 0..1)
|
|
@@ -40,7 +36,7 @@ module ReVIEW
|
|
|
40
36
|
end
|
|
41
37
|
|
|
42
38
|
def extname
|
|
43
|
-
".#{@book.config[
|
|
39
|
+
".#{@book.config['htmlext']}"
|
|
44
40
|
end
|
|
45
41
|
|
|
46
42
|
def builder_init(no_error = false)
|
|
@@ -55,7 +51,7 @@ module ReVIEW
|
|
|
55
51
|
def builder_init_file
|
|
56
52
|
@warns = []
|
|
57
53
|
@errors = []
|
|
58
|
-
@chapter.book.image_types = %w
|
|
54
|
+
@chapter.book.image_types = %w[.png .jpg .jpeg .gif .svg]
|
|
59
55
|
@column = 0
|
|
60
56
|
@sec_counter = SecCounter.new(5, @chapter)
|
|
61
57
|
@nonum_counter = 0
|
|
@@ -66,26 +62,26 @@ module ReVIEW
|
|
|
66
62
|
private :builder_init_file
|
|
67
63
|
|
|
68
64
|
def layoutfile
|
|
69
|
-
if @book.config.maker ==
|
|
70
|
-
htmldir =
|
|
71
|
-
localfilename =
|
|
65
|
+
if @book.config.maker == 'webmaker'
|
|
66
|
+
htmldir = 'web/html'
|
|
67
|
+
localfilename = 'layout-web.html.erb'
|
|
72
68
|
else
|
|
73
|
-
htmldir =
|
|
74
|
-
localfilename =
|
|
69
|
+
htmldir = 'html'
|
|
70
|
+
localfilename = 'layout.html.erb'
|
|
75
71
|
end
|
|
76
72
|
if @book.htmlversion == 5
|
|
77
|
-
htmlfilename = File.join(htmldir,
|
|
73
|
+
htmlfilename = File.join(htmldir, 'layout-html5.html.erb')
|
|
78
74
|
else
|
|
79
|
-
htmlfilename = File.join(htmldir,
|
|
75
|
+
htmlfilename = File.join(htmldir, 'layout-xhtml1.html.erb')
|
|
80
76
|
end
|
|
81
77
|
|
|
82
|
-
layout_file = File.join(@book.basedir,
|
|
83
|
-
if !File.exist?(layout_file) && File.exist?(File.join(@book.basedir,
|
|
84
|
-
raise ReVIEW::ConfigError,
|
|
78
|
+
layout_file = File.join(@book.basedir, 'layouts', localfilename)
|
|
79
|
+
if !File.exist?(layout_file) && File.exist?(File.join(@book.basedir, 'layouts', 'layout.erb'))
|
|
80
|
+
raise ReVIEW::ConfigError, 'layout.erb is obsoleted. Please use layout.html.erb.'
|
|
85
81
|
end
|
|
86
82
|
if File.exist?(layout_file)
|
|
87
|
-
if ENV[
|
|
88
|
-
warn
|
|
83
|
+
if ENV['REVIEW_SAFE_MODE'].to_i & 4 > 0
|
|
84
|
+
warn %Q(user's layout is prohibited in safe mode. ignored.)
|
|
89
85
|
layout_file = File.expand_path(htmlfilename, ReVIEW::Template::TEMPLATE_DIR)
|
|
90
86
|
end
|
|
91
87
|
else
|
|
@@ -99,77 +95,50 @@ module ReVIEW
|
|
|
99
95
|
@title = strip_html(compile_inline(@chapter.title))
|
|
100
96
|
@body = @output.string
|
|
101
97
|
@language = @book.config['language']
|
|
102
|
-
@stylesheets = @book.config[
|
|
98
|
+
@stylesheets = @book.config['stylesheet']
|
|
103
99
|
@next = @chapter.next_chapter
|
|
104
100
|
@prev = @chapter.prev_chapter
|
|
105
|
-
@next_title = @next ? compile_inline(@next.title) :
|
|
106
|
-
@prev_title = @prev ? compile_inline(@prev.title) :
|
|
101
|
+
@next_title = @next ? compile_inline(@next.title) : ''
|
|
102
|
+
@prev_title = @prev ? compile_inline(@prev.title) : ''
|
|
107
103
|
|
|
108
|
-
if @book.config.maker ==
|
|
109
|
-
@toc = ReVIEW::WEBTOCPrinter.book_to_string(@book)
|
|
110
|
-
end
|
|
104
|
+
@toc = ReVIEW::WEBTOCPrinter.book_to_string(@book) if @book.config.maker == 'webmaker'
|
|
111
105
|
|
|
112
|
-
|
|
113
|
-
tmpl.result(binding)
|
|
106
|
+
ReVIEW::Template.load(layoutfile).result(binding)
|
|
114
107
|
end
|
|
115
108
|
|
|
116
109
|
def xmlns_ops_prefix
|
|
117
|
-
if @book.config[
|
|
118
|
-
|
|
119
|
-
else
|
|
120
|
-
"ops"
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def warn(msg)
|
|
125
|
-
if @no_error
|
|
126
|
-
@warns.push [@location.filename, @location.lineno, msg]
|
|
127
|
-
puts "----WARNING: #{escape_html(msg)}----"
|
|
128
|
-
else
|
|
129
|
-
$stderr.puts "#{@location}: warning: #{msg}"
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def error(msg)
|
|
134
|
-
if @no_error
|
|
135
|
-
@errors.push [@location.filename, @location.lineno, msg]
|
|
136
|
-
puts "----ERROR: #{escape_html(msg)}----"
|
|
110
|
+
if @book.config['epubversion'].to_i == 3
|
|
111
|
+
'epub'
|
|
137
112
|
else
|
|
138
|
-
|
|
113
|
+
'ops'
|
|
139
114
|
end
|
|
140
115
|
end
|
|
141
116
|
|
|
142
117
|
def headline(level, label, caption)
|
|
143
118
|
prefix, anchor = headline_prefix(level)
|
|
144
|
-
|
|
145
|
-
prefix = %Q[<span class="secno">#{prefix}</span>]
|
|
146
|
-
end
|
|
119
|
+
prefix = %Q(<span class="secno">#{prefix}</span>) if prefix
|
|
147
120
|
puts '' if level > 1
|
|
148
|
-
a_id =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
end
|
|
121
|
+
a_id = ''
|
|
122
|
+
a_id = %Q(<a id="h#{anchor}"></a>) if anchor
|
|
123
|
+
|
|
152
124
|
if caption.empty?
|
|
153
|
-
puts a_id
|
|
125
|
+
puts a_id if label
|
|
126
|
+
elsif label
|
|
127
|
+
puts %Q(<h#{level} id="#{normalize_id(label)}">#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>)
|
|
154
128
|
else
|
|
155
|
-
|
|
156
|
-
puts %Q[<h#{level}>#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>]
|
|
157
|
-
else
|
|
158
|
-
puts %Q[<h#{level} id="#{normalize_id(label)}">#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>]
|
|
159
|
-
end
|
|
129
|
+
puts %Q(<h#{level}>#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>)
|
|
160
130
|
end
|
|
161
131
|
end
|
|
162
132
|
|
|
163
133
|
def nonum_begin(level, label, caption)
|
|
164
134
|
@nonum_counter += 1
|
|
165
|
-
puts
|
|
166
|
-
unless caption.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
end
|
|
135
|
+
puts if level > 1
|
|
136
|
+
return unless caption.present?
|
|
137
|
+
if label
|
|
138
|
+
puts %Q(<h#{level} id="#{normalize_id(label)}">#{compile_inline(caption)}</h#{level}>)
|
|
139
|
+
else
|
|
140
|
+
id = normalize_id("#{@chapter.name}_nonum#{@nonum_counter}")
|
|
141
|
+
puts %Q(<h#{level} id="#{id}">#{compile_inline(caption)}</h#{level}>)
|
|
173
142
|
end
|
|
174
143
|
end
|
|
175
144
|
|
|
@@ -178,14 +147,13 @@ module ReVIEW
|
|
|
178
147
|
|
|
179
148
|
def notoc_begin(level, label, caption)
|
|
180
149
|
@nonum_counter += 1
|
|
181
|
-
puts
|
|
182
|
-
unless caption.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
end
|
|
150
|
+
puts if level > 1
|
|
151
|
+
return unless caption.present?
|
|
152
|
+
if label
|
|
153
|
+
puts %Q(<h#{level} id="#{normalize_id(label)}" notoc="true">#{compile_inline(caption)}</h#{level}>)
|
|
154
|
+
else
|
|
155
|
+
id = normalize_id("#{@chapter.name}_nonum#{@nonum_counter}")
|
|
156
|
+
puts %Q(<h#{level} id="#{id}" notoc="true">#{compile_inline(caption)}</h#{level}>)
|
|
189
157
|
end
|
|
190
158
|
end
|
|
191
159
|
|
|
@@ -195,13 +163,12 @@ module ReVIEW
|
|
|
195
163
|
def nodisp_begin(level, label, caption)
|
|
196
164
|
@nonum_counter += 1
|
|
197
165
|
puts '' if level > 1
|
|
198
|
-
unless caption.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
end
|
|
166
|
+
return unless caption.present?
|
|
167
|
+
if label
|
|
168
|
+
puts %Q(<a id="#{normalize_id(label)}" /><h#{level} id="#{normalize_id(label)}" hidden="true">#{compile_inline(caption)}</h#{level}>)
|
|
169
|
+
else
|
|
170
|
+
id = normalize_id("#{@chapter.name}_nonum#{@nonum_counter}")
|
|
171
|
+
puts %Q(<a id="#{id}" /><h#{level} id="#{id}" hidden="true">#{compile_inline(caption)}</h#{level}>)
|
|
205
172
|
end
|
|
206
173
|
end
|
|
207
174
|
|
|
@@ -209,124 +176,119 @@ module ReVIEW
|
|
|
209
176
|
end
|
|
210
177
|
|
|
211
178
|
def column_begin(level, label, caption)
|
|
212
|
-
puts %Q
|
|
179
|
+
puts %Q(<div class="column">)
|
|
213
180
|
|
|
214
181
|
@column += 1
|
|
215
|
-
puts
|
|
216
|
-
a_id = %Q
|
|
182
|
+
puts if level > 1
|
|
183
|
+
a_id = %Q(<a id="column-#{@column}"></a>)
|
|
217
184
|
|
|
218
185
|
if caption.empty?
|
|
219
|
-
puts a_id
|
|
186
|
+
puts a_id if label
|
|
187
|
+
elsif label
|
|
188
|
+
puts %Q(<h#{level} id="#{normalize_id(label)}">#{a_id}#{compile_inline(caption)}</h#{level}>)
|
|
220
189
|
else
|
|
221
|
-
|
|
222
|
-
puts %Q[<h#{level}>#{a_id}#{compile_inline(caption)}</h#{level}>]
|
|
223
|
-
else
|
|
224
|
-
puts %Q[<h#{level} id="#{normalize_id(label)}">#{a_id}#{compile_inline(caption)}</h#{level}>]
|
|
225
|
-
end
|
|
190
|
+
puts %Q(<h#{level}>#{a_id}#{compile_inline(caption)}</h#{level}>)
|
|
226
191
|
end
|
|
227
|
-
# headline(level, label, caption)
|
|
228
192
|
end
|
|
229
193
|
|
|
230
|
-
def column_end(
|
|
194
|
+
def column_end(_level)
|
|
231
195
|
puts '</div>'
|
|
232
196
|
end
|
|
233
197
|
|
|
234
198
|
def xcolumn_begin(level, label, caption)
|
|
235
|
-
puts %Q
|
|
199
|
+
puts %Q(<div class="xcolumn">)
|
|
236
200
|
headline(level, label, caption)
|
|
237
201
|
end
|
|
238
202
|
|
|
239
|
-
def xcolumn_end(
|
|
203
|
+
def xcolumn_end(_level)
|
|
240
204
|
puts '</div>'
|
|
241
205
|
end
|
|
242
206
|
|
|
243
207
|
def ref_begin(level, label, caption)
|
|
244
|
-
print %Q
|
|
208
|
+
print %Q(<div class="reference">)
|
|
245
209
|
headline(level, label, caption)
|
|
246
210
|
end
|
|
247
211
|
|
|
248
|
-
def ref_end(
|
|
212
|
+
def ref_end(_level)
|
|
249
213
|
puts '</div>'
|
|
250
214
|
end
|
|
251
215
|
|
|
252
216
|
def sup_begin(level, label, caption)
|
|
253
|
-
print %Q
|
|
217
|
+
print %Q(<div class="supplement">)
|
|
254
218
|
headline(level, label, caption)
|
|
255
219
|
end
|
|
256
220
|
|
|
257
|
-
def sup_end(
|
|
221
|
+
def sup_end(_level)
|
|
258
222
|
puts '</div>'
|
|
259
223
|
end
|
|
260
224
|
|
|
261
225
|
def captionblock(type, lines, caption)
|
|
262
|
-
puts %Q
|
|
263
|
-
|
|
264
|
-
puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
|
|
265
|
-
end
|
|
226
|
+
puts %Q(<div class="#{type}">)
|
|
227
|
+
puts %Q(<p class="caption">#{compile_inline(caption)}</p>) if caption.present?
|
|
266
228
|
blocked_lines = split_paragraph(lines)
|
|
267
229
|
puts blocked_lines.join("\n")
|
|
268
230
|
puts '</div>'
|
|
269
231
|
end
|
|
270
232
|
|
|
271
233
|
def memo(lines, caption = nil)
|
|
272
|
-
captionblock(
|
|
234
|
+
captionblock('memo', lines, caption)
|
|
273
235
|
end
|
|
274
236
|
|
|
275
237
|
def tip(lines, caption = nil)
|
|
276
|
-
captionblock(
|
|
238
|
+
captionblock('tip', lines, caption)
|
|
277
239
|
end
|
|
278
240
|
|
|
279
241
|
def info(lines, caption = nil)
|
|
280
|
-
captionblock(
|
|
242
|
+
captionblock('info', lines, caption)
|
|
281
243
|
end
|
|
282
244
|
|
|
283
245
|
def planning(lines, caption = nil)
|
|
284
|
-
captionblock(
|
|
246
|
+
captionblock('planning', lines, caption)
|
|
285
247
|
end
|
|
286
248
|
|
|
287
249
|
def best(lines, caption = nil)
|
|
288
|
-
captionblock(
|
|
250
|
+
captionblock('best', lines, caption)
|
|
289
251
|
end
|
|
290
252
|
|
|
291
253
|
def important(lines, caption = nil)
|
|
292
|
-
captionblock(
|
|
254
|
+
captionblock('important', lines, caption)
|
|
293
255
|
end
|
|
294
256
|
|
|
295
257
|
def security(lines, caption = nil)
|
|
296
|
-
captionblock(
|
|
258
|
+
captionblock('security', lines, caption)
|
|
297
259
|
end
|
|
298
260
|
|
|
299
261
|
def caution(lines, caption = nil)
|
|
300
|
-
captionblock(
|
|
262
|
+
captionblock('caution', lines, caption)
|
|
301
263
|
end
|
|
302
264
|
|
|
303
265
|
def notice(lines, caption = nil)
|
|
304
|
-
captionblock(
|
|
266
|
+
captionblock('notice', lines, caption)
|
|
305
267
|
end
|
|
306
268
|
|
|
307
269
|
def warning(lines, caption = nil)
|
|
308
|
-
captionblock(
|
|
270
|
+
captionblock('warning', lines, caption)
|
|
309
271
|
end
|
|
310
272
|
|
|
311
273
|
def point(lines, caption = nil)
|
|
312
|
-
captionblock(
|
|
274
|
+
captionblock('point', lines, caption)
|
|
313
275
|
end
|
|
314
276
|
|
|
315
277
|
def shoot(lines, caption = nil)
|
|
316
|
-
captionblock(
|
|
278
|
+
captionblock('shoot', lines, caption)
|
|
317
279
|
end
|
|
318
280
|
|
|
319
281
|
def box(lines, caption = nil)
|
|
320
|
-
puts %Q
|
|
321
|
-
puts %Q
|
|
322
|
-
print %Q
|
|
323
|
-
lines.each {|line| puts detab(line) }
|
|
282
|
+
puts %Q(<div class="syntax">)
|
|
283
|
+
puts %Q(<p class="caption">#{compile_inline(caption)}</p>) if caption.present?
|
|
284
|
+
print %Q(<pre class="syntax">)
|
|
285
|
+
lines.each { |line| puts detab(line) }
|
|
324
286
|
puts '</pre>'
|
|
325
287
|
puts '</div>'
|
|
326
288
|
end
|
|
327
289
|
|
|
328
290
|
def note(lines, caption = nil)
|
|
329
|
-
captionblock(
|
|
291
|
+
captionblock('note', lines, caption)
|
|
330
292
|
end
|
|
331
293
|
|
|
332
294
|
def ul_begin
|
|
@@ -338,7 +300,7 @@ module ReVIEW
|
|
|
338
300
|
end
|
|
339
301
|
|
|
340
302
|
def ul_item_end
|
|
341
|
-
puts
|
|
303
|
+
puts '</li>'
|
|
342
304
|
end
|
|
343
305
|
|
|
344
306
|
def ul_end
|
|
@@ -347,14 +309,14 @@ module ReVIEW
|
|
|
347
309
|
|
|
348
310
|
def ol_begin
|
|
349
311
|
if @ol_num
|
|
350
|
-
puts
|
|
312
|
+
puts %Q(<ol start="#{@ol_num}">) # it's OK in HTML5, but not OK in XHTML1.1
|
|
351
313
|
@ol_num = nil
|
|
352
314
|
else
|
|
353
315
|
puts '<ol>'
|
|
354
316
|
end
|
|
355
317
|
end
|
|
356
318
|
|
|
357
|
-
def ol_item(lines,
|
|
319
|
+
def ol_item(lines, _num)
|
|
358
320
|
puts "<li>#{lines.join}</li>"
|
|
359
321
|
end
|
|
360
322
|
|
|
@@ -379,11 +341,11 @@ module ReVIEW
|
|
|
379
341
|
end
|
|
380
342
|
|
|
381
343
|
def paragraph(lines)
|
|
382
|
-
if @noindent
|
|
383
|
-
puts
|
|
384
|
-
else
|
|
385
|
-
puts %Q[<p class="noindent">#{lines.join}</p>]
|
|
344
|
+
if @noindent
|
|
345
|
+
puts %Q(<p class="noindent">#{lines.join}</p>)
|
|
386
346
|
@noindent = nil
|
|
347
|
+
else
|
|
348
|
+
puts "<p>#{lines.join}</p>"
|
|
387
349
|
end
|
|
388
350
|
end
|
|
389
351
|
|
|
@@ -393,13 +355,13 @@ module ReVIEW
|
|
|
393
355
|
|
|
394
356
|
def read(lines)
|
|
395
357
|
blocked_lines = split_paragraph(lines)
|
|
396
|
-
puts %Q
|
|
358
|
+
puts %Q(<div class="lead">\n#{blocked_lines.join("\n")}\n</div>)
|
|
397
359
|
end
|
|
398
360
|
|
|
399
361
|
alias_method :lead, :read
|
|
400
362
|
|
|
401
363
|
def list(lines, id, caption, lang = nil)
|
|
402
|
-
puts %Q
|
|
364
|
+
puts %Q(<div id="#{normalize_id(id)}" class="caption-code">)
|
|
403
365
|
begin
|
|
404
366
|
list_header id, caption, lang
|
|
405
367
|
rescue KeyError
|
|
@@ -409,50 +371,48 @@ module ReVIEW
|
|
|
409
371
|
puts '</div>'
|
|
410
372
|
end
|
|
411
373
|
|
|
412
|
-
def list_header(id, caption,
|
|
413
|
-
if get_chap
|
|
414
|
-
puts %Q
|
|
374
|
+
def list_header(id, caption, _lang)
|
|
375
|
+
if get_chap
|
|
376
|
+
puts %Q(<p class="caption">#{I18n.t('list')}#{I18n.t('format_number_header', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}</p>)
|
|
415
377
|
else
|
|
416
|
-
puts %Q
|
|
378
|
+
puts %Q(<p class="caption">#{I18n.t('list')}#{I18n.t('format_number_header_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}</p>)
|
|
417
379
|
end
|
|
418
380
|
end
|
|
419
381
|
|
|
420
382
|
def list_body(id, lines, lang)
|
|
421
383
|
id ||= ''
|
|
422
|
-
class_names = [
|
|
423
|
-
lexer = lang || File.extname(id).gsub(
|
|
384
|
+
class_names = ['list']
|
|
385
|
+
lexer = lang || File.extname(id).gsub('.', '')
|
|
424
386
|
class_names.push("language-#{lexer}") unless lexer.blank?
|
|
425
|
-
class_names.push(
|
|
426
|
-
print %Q
|
|
427
|
-
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
|
|
428
|
-
puts highlight(:
|
|
387
|
+
class_names.push('highlight') if highlight?
|
|
388
|
+
print %Q(<pre class="#{class_names.join(' ')}">)
|
|
389
|
+
body = lines.inject('') { |i, j| i + detab(j) + "\n" }
|
|
390
|
+
puts highlight(body: body, lexer: lexer, format: 'html')
|
|
429
391
|
puts '</pre>'
|
|
430
392
|
end
|
|
431
393
|
|
|
432
394
|
def source(lines, caption = nil, lang = nil)
|
|
433
|
-
puts %Q
|
|
395
|
+
puts %Q(<div class="source-code">)
|
|
434
396
|
source_header caption
|
|
435
397
|
source_body caption, lines, lang
|
|
436
398
|
puts '</div>'
|
|
437
399
|
end
|
|
438
400
|
|
|
439
401
|
def source_header(caption)
|
|
440
|
-
if caption.present?
|
|
441
|
-
puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
|
|
442
|
-
end
|
|
402
|
+
puts %Q(<p class="caption">#{compile_inline(caption)}</p>) if caption.present?
|
|
443
403
|
end
|
|
444
404
|
|
|
445
405
|
def source_body(id, lines, lang)
|
|
446
406
|
id ||= ''
|
|
447
|
-
print %Q
|
|
448
|
-
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
|
|
449
|
-
lexer = lang || File.extname(id).gsub(
|
|
450
|
-
puts highlight(:
|
|
407
|
+
print %Q(<pre class="source">)
|
|
408
|
+
body = lines.inject('') { |i, j| i + detab(j) + "\n" }
|
|
409
|
+
lexer = lang || File.extname(id).gsub('.', '')
|
|
410
|
+
puts highlight(body: body, lexer: lexer, format: 'html')
|
|
451
411
|
puts '</pre>'
|
|
452
412
|
end
|
|
453
413
|
|
|
454
414
|
def listnum(lines, id, caption, lang = nil)
|
|
455
|
-
puts %Q
|
|
415
|
+
puts %Q(<div id="#{normalize_id(id)}" class="code">)
|
|
456
416
|
begin
|
|
457
417
|
list_header id, caption, lang
|
|
458
418
|
rescue KeyError
|
|
@@ -464,61 +424,53 @@ module ReVIEW
|
|
|
464
424
|
|
|
465
425
|
def listnum_body(lines, lang)
|
|
466
426
|
if highlight?
|
|
467
|
-
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
|
|
427
|
+
body = lines.inject('') { |i, j| i + detab(j) + "\n" }
|
|
468
428
|
lexer = lang
|
|
469
|
-
first_line_number =
|
|
470
|
-
puts highlight(:
|
|
471
|
-
:
|
|
429
|
+
first_line_number = line_num
|
|
430
|
+
puts highlight(body: body, lexer: lexer, format: 'html', linenum: true,
|
|
431
|
+
options: { linenostart: first_line_number })
|
|
472
432
|
else
|
|
473
|
-
class_names = [
|
|
433
|
+
class_names = ['list']
|
|
474
434
|
class_names.push("language-#{lang}") unless lang.blank?
|
|
475
|
-
class_names.push(
|
|
476
|
-
print %Q
|
|
477
|
-
first_line_num =
|
|
478
|
-
lines.each_with_index
|
|
479
|
-
puts detab((i+first_line_num).to_s.rjust(2) + ": " + line)
|
|
480
|
-
end
|
|
435
|
+
class_names.push('highlight') if highlight?
|
|
436
|
+
print %Q(<pre class="#{class_names.join(' ')}">)
|
|
437
|
+
first_line_num = line_num
|
|
438
|
+
lines.each_with_index { |line, i| puts detab((i + first_line_num).to_s.rjust(2) + ': ' + line) }
|
|
481
439
|
puts '</pre>'
|
|
482
440
|
end
|
|
483
441
|
end
|
|
484
442
|
|
|
485
443
|
def emlist(lines, caption = nil, lang = nil)
|
|
486
|
-
puts %Q
|
|
487
|
-
if caption.present?
|
|
488
|
-
|
|
489
|
-
end
|
|
490
|
-
class_names = ["emlist"]
|
|
444
|
+
puts %Q(<div class="emlist-code">)
|
|
445
|
+
puts %Q(<p class="caption">#{compile_inline(caption)}</p>) if caption.present?
|
|
446
|
+
class_names = ['emlist']
|
|
491
447
|
class_names.push("language-#{lang}") unless lang.blank?
|
|
492
|
-
class_names.push(
|
|
493
|
-
print %Q
|
|
494
|
-
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
|
|
448
|
+
class_names.push('highlight') if highlight?
|
|
449
|
+
print %Q(<pre class="#{class_names.join(' ')}">)
|
|
450
|
+
body = lines.inject('') { |i, j| i + detab(j) + "\n" }
|
|
495
451
|
lexer = lang
|
|
496
|
-
puts highlight(:
|
|
452
|
+
puts highlight(body: body, lexer: lexer, format: 'html')
|
|
497
453
|
puts '</pre>'
|
|
498
454
|
puts '</div>'
|
|
499
455
|
end
|
|
500
456
|
|
|
501
457
|
def emlistnum(lines, caption = nil, lang = nil)
|
|
502
|
-
puts %Q
|
|
503
|
-
if caption.present?
|
|
504
|
-
puts %Q(<p class="caption">#{compile_inline(caption)}</p>)
|
|
505
|
-
end
|
|
458
|
+
puts %Q(<div class="emlistnum-code">)
|
|
459
|
+
puts %Q(<p class="caption">#{compile_inline(caption)}</p>) if caption.present?
|
|
506
460
|
|
|
507
461
|
if highlight?
|
|
508
|
-
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
|
|
462
|
+
body = lines.inject('') { |i, j| i + detab(j) + "\n" }
|
|
509
463
|
lexer = lang
|
|
510
|
-
first_line_number =
|
|
511
|
-
puts highlight(:
|
|
512
|
-
:
|
|
464
|
+
first_line_number = line_num
|
|
465
|
+
puts highlight(body: body, lexer: lexer, format: 'html', linenum: true,
|
|
466
|
+
options: { linenostart: first_line_number })
|
|
513
467
|
else
|
|
514
|
-
class_names = [
|
|
468
|
+
class_names = ['emlist']
|
|
515
469
|
class_names.push("language-#{lang}") unless lang.blank?
|
|
516
|
-
class_names.push(
|
|
517
|
-
print %Q
|
|
518
|
-
first_line_num =
|
|
519
|
-
lines.each_with_index
|
|
520
|
-
puts detab((i+first_line_num).to_s.rjust(2) + ": " + line)
|
|
521
|
-
end
|
|
470
|
+
class_names.push('highlight') if highlight?
|
|
471
|
+
print %Q(<pre class="#{class_names.join(' ')}">)
|
|
472
|
+
first_line_num = line_num
|
|
473
|
+
lines.each_with_index { |line, i| puts detab((i + first_line_num).to_s.rjust(2) + ': ' + line) }
|
|
522
474
|
puts '</pre>'
|
|
523
475
|
end
|
|
524
476
|
|
|
@@ -526,77 +478,73 @@ module ReVIEW
|
|
|
526
478
|
end
|
|
527
479
|
|
|
528
480
|
def cmd(lines, caption = nil)
|
|
529
|
-
puts %Q
|
|
530
|
-
if caption.present?
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
print %Q[<pre class="cmd">]
|
|
534
|
-
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
|
|
481
|
+
puts %Q(<div class="cmd-code">)
|
|
482
|
+
puts %Q(<p class="caption">#{compile_inline(caption)}</p>) if caption.present?
|
|
483
|
+
print %Q(<pre class="cmd">)
|
|
484
|
+
body = lines.inject('') { |i, j| i + detab(j) + "\n" }
|
|
535
485
|
lexer = 'shell-session'
|
|
536
|
-
puts highlight(:
|
|
486
|
+
puts highlight(body: body, lexer: lexer, format: 'html')
|
|
537
487
|
puts '</pre>'
|
|
538
488
|
puts '</div>'
|
|
539
489
|
end
|
|
540
490
|
|
|
541
491
|
def quotedlist(lines, css_class)
|
|
542
|
-
print %Q
|
|
543
|
-
lines.each
|
|
544
|
-
puts detab(line)
|
|
545
|
-
end
|
|
492
|
+
print %Q(<blockquote><pre class="#{css_class}">)
|
|
493
|
+
lines.each { |line| puts detab(line) }
|
|
546
494
|
puts '</pre></blockquote>'
|
|
547
495
|
end
|
|
548
496
|
private :quotedlist
|
|
549
497
|
|
|
550
498
|
def quote(lines)
|
|
551
499
|
blocked_lines = split_paragraph(lines)
|
|
552
|
-
puts
|
|
500
|
+
puts %Q(<blockquote>#{blocked_lines.join("\n")}</blockquote>)
|
|
553
501
|
end
|
|
554
502
|
|
|
555
503
|
def doorquote(lines, ref)
|
|
556
504
|
blocked_lines = split_paragraph(lines)
|
|
557
|
-
puts %Q
|
|
558
|
-
puts
|
|
559
|
-
puts %Q
|
|
560
|
-
puts
|
|
505
|
+
puts %Q(<blockquote style="text-align:right;">)
|
|
506
|
+
puts blocked_lines.join("\n")
|
|
507
|
+
puts %Q(<p>#{ref}より</p>)
|
|
508
|
+
puts '</blockquote>'
|
|
561
509
|
end
|
|
562
510
|
|
|
563
511
|
def talk(lines)
|
|
564
|
-
puts %Q
|
|
512
|
+
puts %Q(<div class="talk">)
|
|
565
513
|
blocked_lines = split_paragraph(lines)
|
|
566
|
-
puts
|
|
514
|
+
puts blocked_lines.join("\n")
|
|
567
515
|
puts '</div>'
|
|
568
516
|
end
|
|
569
517
|
|
|
570
518
|
def texequation(lines)
|
|
571
|
-
puts %Q
|
|
572
|
-
if @book.config[
|
|
519
|
+
puts %Q(<div class="equation">)
|
|
520
|
+
if @book.config['mathml']
|
|
573
521
|
require 'math_ml'
|
|
574
522
|
require 'math_ml/symbol/character_reference'
|
|
575
|
-
p = MathML::LaTeX::Parser.new(:
|
|
523
|
+
p = MathML::LaTeX::Parser.new(symbol: MathML::Symbol::CharacterReference)
|
|
576
524
|
puts p.parse(unescape_html(lines.join("\n")), true)
|
|
577
|
-
elsif @book.config[
|
|
578
|
-
puts %Q
|
|
525
|
+
elsif @book.config['imgmath']
|
|
526
|
+
puts %Q(<div class="equation">)
|
|
579
527
|
math_str = "\\begin{equation*}\n" + unescape_html(lines.join("\n")) + "\n\\end{equation*}\n"
|
|
580
528
|
key = Digest::SHA256.hexdigest(math_str)
|
|
581
|
-
|
|
529
|
+
math_dir = "./#{@book.config['imagedir']}/_review_math"
|
|
530
|
+
Dir.mkdir(math_dir) unless Dir.exist?(math_dir)
|
|
531
|
+
img_path = "./#{math_dir}/_gen_#{key}.png"
|
|
582
532
|
make_math_image(math_str, img_path)
|
|
583
|
-
puts %Q
|
|
533
|
+
puts %Q(<img src="#{img_path}" />)
|
|
584
534
|
puts '</div>'
|
|
585
535
|
else
|
|
586
536
|
print '<pre>'
|
|
587
|
-
puts
|
|
537
|
+
puts lines.join("\n")
|
|
588
538
|
puts '</pre>'
|
|
589
539
|
end
|
|
590
540
|
puts '</div>'
|
|
591
541
|
end
|
|
592
542
|
|
|
593
543
|
def handle_metric(str)
|
|
594
|
-
if str =~ /\Ascale=([\d.]+)\Z/
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
return {k => v.sub(/\A["']/, '').sub(/["']\Z/, '')}
|
|
599
|
-
end
|
|
544
|
+
return { 'class' => sprintf('width-%03dper', ($1.to_f * 100).round) } if str =~ /\Ascale=([\d.]+)\Z/
|
|
545
|
+
|
|
546
|
+
k, v = str.split('=', 2)
|
|
547
|
+
{ k => v.sub(/\A["']/, '').sub(/["']\Z/, '') }
|
|
600
548
|
end
|
|
601
549
|
|
|
602
550
|
def result_metric(array)
|
|
@@ -609,37 +557,35 @@ module ReVIEW
|
|
|
609
557
|
attrs[k] = [item[k]]
|
|
610
558
|
end
|
|
611
559
|
end
|
|
612
|
-
|
|
560
|
+
' ' + attrs.map { |k, v| %Q(#{k}="#{v.join(' ')}") }.join(' ')
|
|
613
561
|
end
|
|
614
562
|
|
|
615
563
|
def image_image(id, caption, metric)
|
|
616
|
-
metrics = parse_metric(
|
|
617
|
-
puts %Q
|
|
618
|
-
puts %Q
|
|
564
|
+
metrics = parse_metric('html', metric)
|
|
565
|
+
puts %Q(<div id="#{normalize_id(id)}" class="image">)
|
|
566
|
+
puts %Q(<img src="#{@chapter.image(id).path.sub(%r{\A\./}, '')}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />)
|
|
619
567
|
image_header id, caption
|
|
620
|
-
puts
|
|
568
|
+
puts '</div>'
|
|
621
569
|
end
|
|
622
570
|
|
|
623
571
|
def image_dummy(id, caption, lines)
|
|
624
|
-
|
|
625
|
-
puts %Q
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
puts %Q[</pre>]
|
|
572
|
+
warn "image not bound: #{id}"
|
|
573
|
+
puts %Q(<div id="#{normalize_id(id)}" class="image">)
|
|
574
|
+
puts %Q(<pre class="dummyimage">)
|
|
575
|
+
lines.each { |line| puts detab(line) }
|
|
576
|
+
puts '</pre>'
|
|
630
577
|
image_header id, caption
|
|
631
|
-
puts
|
|
632
|
-
warn "no such image: #{id}"
|
|
578
|
+
puts '</div>'
|
|
633
579
|
end
|
|
634
580
|
|
|
635
581
|
def image_header(id, caption)
|
|
636
|
-
puts %Q
|
|
637
|
-
if get_chap
|
|
638
|
-
puts %Q
|
|
582
|
+
puts %Q(<p class="caption">)
|
|
583
|
+
if get_chap
|
|
584
|
+
puts %Q(#{I18n.t('image')}#{I18n.t('format_number_header', [get_chap, @chapter.image(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)})
|
|
639
585
|
else
|
|
640
|
-
puts %Q
|
|
586
|
+
puts %Q(#{I18n.t('image')}#{I18n.t('format_number_header_without_chapter', [@chapter.image(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)})
|
|
641
587
|
end
|
|
642
|
-
puts
|
|
588
|
+
puts '</p>'
|
|
643
589
|
end
|
|
644
590
|
|
|
645
591
|
def table(lines, id = nil, caption = nil)
|
|
@@ -648,56 +594,50 @@ module ReVIEW
|
|
|
648
594
|
lines.each_with_index do |line, idx|
|
|
649
595
|
if /\A[\=\-]{12}/ =~ line
|
|
650
596
|
# just ignore
|
|
651
|
-
#error "too many table separator" if sepidx
|
|
597
|
+
# error "too many table separator" if sepidx
|
|
652
598
|
sepidx ||= idx
|
|
653
599
|
next
|
|
654
600
|
end
|
|
655
|
-
rows.push(line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') })
|
|
601
|
+
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
|
656
602
|
end
|
|
657
603
|
rows = adjust_n_cols(rows)
|
|
658
604
|
|
|
659
605
|
if id
|
|
660
|
-
puts %Q
|
|
606
|
+
puts %Q(<div id="#{normalize_id(id)}" class="table">)
|
|
661
607
|
else
|
|
662
|
-
puts %Q
|
|
608
|
+
puts %Q(<div class="table">)
|
|
663
609
|
end
|
|
664
610
|
begin
|
|
665
|
-
table_header id, caption
|
|
611
|
+
table_header id, caption if caption.present?
|
|
666
612
|
rescue KeyError
|
|
667
613
|
error "no such table: #{id}"
|
|
668
614
|
end
|
|
669
615
|
table_begin rows.first.size
|
|
670
616
|
return if rows.empty?
|
|
671
617
|
if sepidx
|
|
672
|
-
sepidx.times
|
|
673
|
-
|
|
674
|
-
end
|
|
675
|
-
rows.each do |cols|
|
|
676
|
-
tr (cols.map {|s| td(s) })
|
|
677
|
-
end
|
|
618
|
+
sepidx.times { tr(rows.shift.map { |s| th(s) }) }
|
|
619
|
+
rows.each { |cols| tr(cols.map { |s| td(s) }) }
|
|
678
620
|
else
|
|
679
621
|
rows.each do |cols|
|
|
680
622
|
h, *cs = *cols
|
|
681
|
-
tr
|
|
623
|
+
tr([th(h)] + cs.map { |s| td(s) })
|
|
682
624
|
end
|
|
683
625
|
end
|
|
684
626
|
table_end
|
|
685
|
-
puts
|
|
627
|
+
puts '</div>'
|
|
686
628
|
end
|
|
687
629
|
|
|
688
630
|
def table_header(id, caption)
|
|
689
631
|
if id.nil?
|
|
690
|
-
puts %Q
|
|
632
|
+
puts %Q(<p class="caption">#{compile_inline(caption)}</p>)
|
|
633
|
+
elsif get_chap
|
|
634
|
+
puts %Q(<p class="caption">#{I18n.t('table')}#{I18n.t('format_number_header', [get_chap, @chapter.table(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}</p>)
|
|
691
635
|
else
|
|
692
|
-
|
|
693
|
-
puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
|
|
694
|
-
else
|
|
695
|
-
puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
|
|
696
|
-
end
|
|
636
|
+
puts %Q(<p class="caption">#{I18n.t('table')}#{I18n.t('format_number_header_without_chapter', [@chapter.table(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}</p>)
|
|
697
637
|
end
|
|
698
638
|
end
|
|
699
639
|
|
|
700
|
-
def table_begin(
|
|
640
|
+
def table_begin(_ncols)
|
|
701
641
|
puts '<table>'
|
|
702
642
|
end
|
|
703
643
|
|
|
@@ -718,27 +658,27 @@ module ReVIEW
|
|
|
718
658
|
end
|
|
719
659
|
|
|
720
660
|
def imgtable(lines, id, caption = nil, metric = nil)
|
|
721
|
-
|
|
661
|
+
unless @chapter.image(id).bound?
|
|
722
662
|
warn "image not bound: #{id}"
|
|
723
663
|
image_dummy id, caption, lines
|
|
724
664
|
return
|
|
725
665
|
end
|
|
726
666
|
|
|
727
|
-
puts %Q
|
|
667
|
+
puts %Q(<div id="#{normalize_id(id)}" class="imgtable image">)
|
|
728
668
|
begin
|
|
729
|
-
table_header id, caption
|
|
669
|
+
table_header id, caption if caption.present?
|
|
730
670
|
rescue KeyError
|
|
731
671
|
error "no such table: #{id}"
|
|
732
672
|
end
|
|
733
673
|
|
|
734
674
|
imgtable_image(id, caption, metric)
|
|
735
675
|
|
|
736
|
-
puts
|
|
676
|
+
puts '</div>'
|
|
737
677
|
end
|
|
738
678
|
|
|
739
679
|
def imgtable_image(id, caption, metric)
|
|
740
|
-
metrics = parse_metric(
|
|
741
|
-
puts %Q
|
|
680
|
+
metrics = parse_metric('html', metric)
|
|
681
|
+
puts %Q(<img src="#{@chapter.image(id).path.sub(%r{\A\./}, '')}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />)
|
|
742
682
|
end
|
|
743
683
|
|
|
744
684
|
def emtable(lines, caption = nil)
|
|
@@ -748,42 +688,46 @@ module ReVIEW
|
|
|
748
688
|
def comment(lines, comment = nil)
|
|
749
689
|
lines ||= []
|
|
750
690
|
lines.unshift comment unless comment.blank?
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
end
|
|
691
|
+
return unless @book.config['draft']
|
|
692
|
+
str = lines.join('<br />')
|
|
693
|
+
puts %Q(<div class="draft-comment">#{escape_html(str)}</div>)
|
|
755
694
|
end
|
|
756
695
|
|
|
757
696
|
def footnote(id, str)
|
|
758
|
-
if @book.config[
|
|
697
|
+
if @book.config['epubversion'].to_i == 3
|
|
759
698
|
puts %Q(<div class="footnote" epub:type="footnote" id="fn-#{normalize_id(id)}"><p class="footnote">[*#{@chapter.footnote(id).number}] #{compile_inline(str)}</p></div>)
|
|
760
699
|
else
|
|
761
700
|
puts %Q(<div class="footnote" id="fn-#{normalize_id(id)}"><p class="footnote">[<a href="#fnb-#{normalize_id(id)}">*#{@chapter.footnote(id).number}</a>] #{compile_inline(str)}</p></div>)
|
|
762
701
|
end
|
|
763
702
|
end
|
|
764
703
|
|
|
765
|
-
def indepimage(id, caption=
|
|
766
|
-
metrics = parse_metric(
|
|
767
|
-
caption =
|
|
768
|
-
puts %Q
|
|
704
|
+
def indepimage(lines, id, caption = '', metric = nil)
|
|
705
|
+
metrics = parse_metric('html', metric)
|
|
706
|
+
caption = '' unless caption.present?
|
|
707
|
+
puts %Q(<div id="#{normalize_id(id)}" class="image">)
|
|
769
708
|
begin
|
|
770
|
-
puts %Q
|
|
709
|
+
puts %Q(<img src="#{@chapter.image(id).path.sub(%r{\A\./}, '')}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />)
|
|
771
710
|
rescue
|
|
772
|
-
|
|
711
|
+
warn "image not bound: #{id}"
|
|
712
|
+
if lines
|
|
713
|
+
puts %Q(<pre class="dummyimage">)
|
|
714
|
+
lines.each { |line| puts detab(line) }
|
|
715
|
+
puts '</pre>'
|
|
716
|
+
end
|
|
773
717
|
end
|
|
774
718
|
|
|
775
|
-
|
|
776
|
-
puts %Q
|
|
777
|
-
puts %Q
|
|
778
|
-
puts
|
|
719
|
+
if caption.present?
|
|
720
|
+
puts %Q(<p class="caption">)
|
|
721
|
+
puts %Q(#{I18n.t('numberless_image')}#{I18n.t('caption_prefix')}#{compile_inline(caption)})
|
|
722
|
+
puts '</p>'
|
|
779
723
|
end
|
|
780
|
-
puts
|
|
724
|
+
puts '</div>'
|
|
781
725
|
end
|
|
782
726
|
|
|
783
727
|
alias_method :numberlessimage, :indepimage
|
|
784
728
|
|
|
785
729
|
def hr
|
|
786
|
-
puts
|
|
730
|
+
puts '<hr />'
|
|
787
731
|
end
|
|
788
732
|
|
|
789
733
|
def label(id)
|
|
@@ -791,7 +735,7 @@ module ReVIEW
|
|
|
791
735
|
end
|
|
792
736
|
|
|
793
737
|
def linebreak
|
|
794
|
-
puts
|
|
738
|
+
puts '<br />'
|
|
795
739
|
end
|
|
796
740
|
|
|
797
741
|
def pagebreak
|
|
@@ -799,11 +743,9 @@ module ReVIEW
|
|
|
799
743
|
end
|
|
800
744
|
|
|
801
745
|
def bpo(lines)
|
|
802
|
-
puts
|
|
803
|
-
lines.each
|
|
804
|
-
|
|
805
|
-
end
|
|
806
|
-
puts "</bpo>"
|
|
746
|
+
puts '<bpo>'
|
|
747
|
+
lines.each { |line| puts detab(line) }
|
|
748
|
+
puts '</bpo>'
|
|
807
749
|
end
|
|
808
750
|
|
|
809
751
|
def noindent
|
|
@@ -811,14 +753,18 @@ module ReVIEW
|
|
|
811
753
|
end
|
|
812
754
|
|
|
813
755
|
def inline_labelref(idref)
|
|
814
|
-
%Q
|
|
756
|
+
%Q(<a target='#{escape_html(idref)}'>「#{I18n.t('label_marker')}#{escape_html(idref)}」</a>)
|
|
815
757
|
end
|
|
816
758
|
|
|
817
759
|
alias_method :inline_ref, :inline_labelref
|
|
818
760
|
|
|
761
|
+
def inline_pageref(id)
|
|
762
|
+
error "pageref op is unsupported on this builder: #{id}"
|
|
763
|
+
end
|
|
764
|
+
|
|
819
765
|
def inline_chapref(id)
|
|
820
766
|
title = super
|
|
821
|
-
if @book.config[
|
|
767
|
+
if @book.config['chapterlink']
|
|
822
768
|
%Q(<a href="./#{id}#{extname}">#{title}</a>)
|
|
823
769
|
else
|
|
824
770
|
title
|
|
@@ -829,7 +775,7 @@ module ReVIEW
|
|
|
829
775
|
end
|
|
830
776
|
|
|
831
777
|
def inline_chap(id)
|
|
832
|
-
if @book.config[
|
|
778
|
+
if @book.config['chapterlink']
|
|
833
779
|
%Q(<a href="./#{id}#{extname}">#{@book.chapter_index.number(id)}</a>)
|
|
834
780
|
else
|
|
835
781
|
@book.chapter_index.number(id)
|
|
@@ -841,7 +787,7 @@ module ReVIEW
|
|
|
841
787
|
|
|
842
788
|
def inline_title(id)
|
|
843
789
|
title = super
|
|
844
|
-
if @book.config[
|
|
790
|
+
if @book.config['chapterlink']
|
|
845
791
|
%Q(<a href="./#{id}#{extname}">#{title}</a>)
|
|
846
792
|
else
|
|
847
793
|
title
|
|
@@ -852,7 +798,7 @@ module ReVIEW
|
|
|
852
798
|
end
|
|
853
799
|
|
|
854
800
|
def inline_fn(id)
|
|
855
|
-
if @book.config[
|
|
801
|
+
if @book.config['epubversion'].to_i == 3
|
|
856
802
|
%Q(<a id="fnb-#{normalize_id(id)}" href="#fn-#{normalize_id(id)}" class="noteref" epub:type="noteref">*#{@chapter.footnote(id).number}</a>)
|
|
857
803
|
else
|
|
858
804
|
%Q(<a id="fnb-#{normalize_id(id)}" href="#fn-#{normalize_id(id)}" class="noteref">*#{@chapter.footnote(id).number}</a>)
|
|
@@ -861,14 +807,14 @@ module ReVIEW
|
|
|
861
807
|
|
|
862
808
|
def compile_ruby(base, ruby)
|
|
863
809
|
if @book.htmlversion == 5
|
|
864
|
-
%Q
|
|
810
|
+
%Q(<ruby>#{escape_html(base)}<rp>#{I18n.t('ruby_prefix')}</rp><rt>#{escape_html(ruby)}</rt><rp>#{I18n.t('ruby_postfix')}</rp></ruby>)
|
|
865
811
|
else
|
|
866
|
-
%Q
|
|
812
|
+
%Q(<ruby><rb>#{escape_html(base)}</rb><rp>#{I18n.t('ruby_prefix')}</rp><rt>#{ruby}</rt><rp>#{I18n.t('ruby_postfix')}</rp></ruby>)
|
|
867
813
|
end
|
|
868
814
|
end
|
|
869
815
|
|
|
870
816
|
def compile_kw(word, alt)
|
|
871
|
-
%Q
|
|
817
|
+
%Q(<b class="kw">) +
|
|
872
818
|
if alt
|
|
873
819
|
then escape_html(word + " (#{alt.strip})")
|
|
874
820
|
else escape_html(word)
|
|
@@ -928,24 +874,26 @@ module ReVIEW
|
|
|
928
874
|
%Q(<!-- IDX:#{escape_comment(escape_html(str))} -->)
|
|
929
875
|
end
|
|
930
876
|
|
|
931
|
-
def inline_br(
|
|
932
|
-
|
|
877
|
+
def inline_br(_str)
|
|
878
|
+
'<br />'
|
|
933
879
|
end
|
|
934
880
|
|
|
935
881
|
def inline_m(str)
|
|
936
|
-
if @book.config[
|
|
882
|
+
if @book.config['mathml']
|
|
937
883
|
require 'math_ml'
|
|
938
884
|
require 'math_ml/symbol/character_reference'
|
|
939
|
-
parser = MathML::LaTeX::Parser.new(:
|
|
940
|
-
%Q
|
|
941
|
-
elsif @book.config[
|
|
942
|
-
math_str =
|
|
885
|
+
parser = MathML::LaTeX::Parser.new(symbol: MathML::Symbol::CharacterReference)
|
|
886
|
+
%Q(<span class="equation">#{parser.parse(str, nil)}</span>)
|
|
887
|
+
elsif @book.config['imgmath']
|
|
888
|
+
math_str = '$' + str + '$'
|
|
943
889
|
key = Digest::SHA256.hexdigest(str)
|
|
944
|
-
|
|
890
|
+
math_dir = "./#{@book.config['imagedir']}/_review_math"
|
|
891
|
+
Dir.mkdir(math_dir) unless Dir.exist?(math_dir)
|
|
892
|
+
img_path = "./#{math_dir}/_gen_#{key}.png"
|
|
945
893
|
make_math_image(math_str, img_path)
|
|
946
|
-
%Q
|
|
894
|
+
%Q(<span class="equation"><img src="#{img_path}" /></span>)
|
|
947
895
|
else
|
|
948
|
-
%Q
|
|
896
|
+
%Q(<span class="equation">#{escape_html(str)}</span>)
|
|
949
897
|
end
|
|
950
898
|
end
|
|
951
899
|
|
|
@@ -954,23 +902,21 @@ module ReVIEW
|
|
|
954
902
|
end
|
|
955
903
|
|
|
956
904
|
def bibpaper(lines, id, caption)
|
|
957
|
-
puts %Q
|
|
905
|
+
puts %Q(<div class="bibpaper">)
|
|
958
906
|
bibpaper_header id, caption
|
|
959
|
-
unless lines.empty?
|
|
960
|
-
|
|
961
|
-
end
|
|
962
|
-
puts "</div>"
|
|
907
|
+
bibpaper_bibpaper id, caption, lines unless lines.empty?
|
|
908
|
+
puts '</div>'
|
|
963
909
|
end
|
|
964
910
|
|
|
965
911
|
def bibpaper_header(id, caption)
|
|
966
912
|
print %Q(<a id="bib-#{normalize_id(id)}">)
|
|
967
913
|
print "[#{@chapter.bibpaper(id).number}]"
|
|
968
|
-
print
|
|
914
|
+
print '</a>'
|
|
969
915
|
puts " #{compile_inline(caption)}"
|
|
970
916
|
end
|
|
971
917
|
|
|
972
|
-
def bibpaper_bibpaper(
|
|
973
|
-
print split_paragraph(lines).join
|
|
918
|
+
def bibpaper_bibpaper(_id, _caption, lines)
|
|
919
|
+
print split_paragraph(lines).join
|
|
974
920
|
end
|
|
975
921
|
|
|
976
922
|
def inline_bib(id)
|
|
@@ -979,42 +925,42 @@ module ReVIEW
|
|
|
979
925
|
|
|
980
926
|
def inline_hd_chap(chap, id)
|
|
981
927
|
n = chap.headline_index.number(id)
|
|
982
|
-
if chap.number and @book.config[
|
|
983
|
-
str = I18n.t(
|
|
928
|
+
if chap.number and @book.config['secnolevel'] >= n.split('.').size
|
|
929
|
+
str = I18n.t('chapter_quote', "#{n} #{compile_inline(chap.headline(id).caption)}")
|
|
984
930
|
else
|
|
985
|
-
str = I18n.t(
|
|
931
|
+
str = I18n.t('chapter_quote', compile_inline(chap.headline(id).caption))
|
|
986
932
|
end
|
|
987
|
-
if @book.config[
|
|
988
|
-
anchor =
|
|
933
|
+
if @book.config['chapterlink']
|
|
934
|
+
anchor = 'h' + n.gsub('.', '-')
|
|
989
935
|
%Q(<a href="#{chap.id}#{extname}##{anchor}">#{str}</a>)
|
|
990
936
|
else
|
|
991
937
|
str
|
|
992
938
|
end
|
|
993
939
|
end
|
|
994
940
|
|
|
995
|
-
def column_label(id)
|
|
996
|
-
num =
|
|
941
|
+
def column_label(id, chapter = @chapter)
|
|
942
|
+
num = chapter.column(id).number
|
|
997
943
|
"column-#{num}"
|
|
998
944
|
end
|
|
999
945
|
private :column_label
|
|
1000
946
|
|
|
1001
947
|
def inline_column_chap(chapter, id)
|
|
1002
|
-
if @book.config[
|
|
1003
|
-
%Q(<a href="\##{column_label(id)}" class="columnref">#{I18n.t(
|
|
948
|
+
if @book.config['chapterlink']
|
|
949
|
+
%Q(<a href="\##{column_label(id, chapter)}" class="columnref">#{I18n.t('column', compile_inline(chapter.column(id).caption))}</a>)
|
|
1004
950
|
else
|
|
1005
|
-
I18n.t(
|
|
951
|
+
I18n.t('column', compile_inline(chapter.column(id).caption))
|
|
1006
952
|
end
|
|
1007
953
|
end
|
|
1008
954
|
|
|
1009
955
|
def inline_list(id)
|
|
1010
956
|
chapter, id = extract_chapter_id(id)
|
|
1011
|
-
str =
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
if @book.config[
|
|
957
|
+
str =
|
|
958
|
+
if get_chap(chapter)
|
|
959
|
+
"#{I18n.t('list')}#{I18n.t('format_number', [get_chap(chapter), chapter.list(id).number])}"
|
|
960
|
+
else
|
|
961
|
+
"#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [chapter.list(id).number])}"
|
|
962
|
+
end
|
|
963
|
+
if @book.config['chapterlink']
|
|
1018
964
|
%Q(<span class="listref"><a href="./#{chapter.id}#{extname}##{id}">#{str}</a></span>)
|
|
1019
965
|
else
|
|
1020
966
|
%Q(<span class="listref">#{str}</span>)
|
|
@@ -1026,13 +972,13 @@ module ReVIEW
|
|
|
1026
972
|
|
|
1027
973
|
def inline_table(id)
|
|
1028
974
|
chapter, id = extract_chapter_id(id)
|
|
1029
|
-
str =
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
if @book.config[
|
|
975
|
+
str =
|
|
976
|
+
if get_chap(chapter)
|
|
977
|
+
"#{I18n.t('table')}#{I18n.t('format_number', [get_chap(chapter), chapter.table(id).number])}"
|
|
978
|
+
else
|
|
979
|
+
"#{I18n.t('table')}#{I18n.t('format_number_without_chapter', [chapter.table(id).number])}"
|
|
980
|
+
end
|
|
981
|
+
if @book.config['chapterlink']
|
|
1036
982
|
%Q(<span class="tableref"><a href="./#{chapter.id}#{extname}##{id}">#{str}</a></span>)
|
|
1037
983
|
else
|
|
1038
984
|
%Q(<span class="tableref">#{str}</span>)
|
|
@@ -1044,13 +990,13 @@ module ReVIEW
|
|
|
1044
990
|
|
|
1045
991
|
def inline_img(id)
|
|
1046
992
|
chapter, id = extract_chapter_id(id)
|
|
1047
|
-
str =
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
if @book.config[
|
|
993
|
+
str =
|
|
994
|
+
if get_chap(chapter)
|
|
995
|
+
"#{I18n.t('image')}#{I18n.t('format_number', [get_chap(chapter), chapter.image(id).number])}"
|
|
996
|
+
else
|
|
997
|
+
"#{I18n.t('image')}#{I18n.t('format_number_without_chapter', [chapter.image(id).number])}"
|
|
998
|
+
end
|
|
999
|
+
if @book.config['chapterlink']
|
|
1054
1000
|
%Q(<span class="imgref"><a href="./#{chapter.id}#{extname}##{normalize_id(id)}">#{str}</a></span>)
|
|
1055
1001
|
else
|
|
1056
1002
|
%Q(<span class="imgref">#{str}</span>)
|
|
@@ -1065,55 +1011,55 @@ module ReVIEW
|
|
|
1065
1011
|
end
|
|
1066
1012
|
|
|
1067
1013
|
def inline_abbr(str)
|
|
1068
|
-
inline_asis(str,
|
|
1014
|
+
inline_asis(str, 'abbr')
|
|
1069
1015
|
end
|
|
1070
1016
|
|
|
1071
1017
|
def inline_acronym(str)
|
|
1072
|
-
inline_asis(str,
|
|
1018
|
+
inline_asis(str, 'acronym')
|
|
1073
1019
|
end
|
|
1074
1020
|
|
|
1075
1021
|
def inline_cite(str)
|
|
1076
|
-
inline_asis(str,
|
|
1022
|
+
inline_asis(str, 'cite')
|
|
1077
1023
|
end
|
|
1078
1024
|
|
|
1079
1025
|
def inline_dfn(str)
|
|
1080
|
-
inline_asis(str,
|
|
1026
|
+
inline_asis(str, 'dfn')
|
|
1081
1027
|
end
|
|
1082
1028
|
|
|
1083
1029
|
def inline_em(str)
|
|
1084
|
-
inline_asis(str,
|
|
1030
|
+
inline_asis(str, 'em')
|
|
1085
1031
|
end
|
|
1086
1032
|
|
|
1087
1033
|
def inline_kbd(str)
|
|
1088
|
-
inline_asis(str,
|
|
1034
|
+
inline_asis(str, 'kbd')
|
|
1089
1035
|
end
|
|
1090
1036
|
|
|
1091
1037
|
def inline_samp(str)
|
|
1092
|
-
inline_asis(str,
|
|
1038
|
+
inline_asis(str, 'samp')
|
|
1093
1039
|
end
|
|
1094
1040
|
|
|
1095
1041
|
def inline_strong(str)
|
|
1096
|
-
inline_asis(str,
|
|
1042
|
+
inline_asis(str, 'strong')
|
|
1097
1043
|
end
|
|
1098
1044
|
|
|
1099
1045
|
def inline_var(str)
|
|
1100
|
-
inline_asis(str,
|
|
1046
|
+
inline_asis(str, 'var')
|
|
1101
1047
|
end
|
|
1102
1048
|
|
|
1103
1049
|
def inline_big(str)
|
|
1104
|
-
inline_asis(str,
|
|
1050
|
+
inline_asis(str, 'big')
|
|
1105
1051
|
end
|
|
1106
1052
|
|
|
1107
1053
|
def inline_small(str)
|
|
1108
|
-
inline_asis(str,
|
|
1054
|
+
inline_asis(str, 'small')
|
|
1109
1055
|
end
|
|
1110
1056
|
|
|
1111
1057
|
def inline_sub(str)
|
|
1112
|
-
inline_asis(str,
|
|
1058
|
+
inline_asis(str, 'sub')
|
|
1113
1059
|
end
|
|
1114
1060
|
|
|
1115
1061
|
def inline_sup(str)
|
|
1116
|
-
inline_asis(str,
|
|
1062
|
+
inline_asis(str, 'sup')
|
|
1117
1063
|
end
|
|
1118
1064
|
|
|
1119
1065
|
def inline_tt(str)
|
|
@@ -1125,11 +1071,11 @@ module ReVIEW
|
|
|
1125
1071
|
end
|
|
1126
1072
|
|
|
1127
1073
|
def inline_del(str)
|
|
1128
|
-
inline_asis(str,
|
|
1074
|
+
inline_asis(str, 'del')
|
|
1129
1075
|
end
|
|
1130
1076
|
|
|
1131
1077
|
def inline_ins(str)
|
|
1132
|
-
inline_asis(str,
|
|
1078
|
+
inline_asis(str, 'ins')
|
|
1133
1079
|
end
|
|
1134
1080
|
|
|
1135
1081
|
def inline_u(str)
|
|
@@ -1142,9 +1088,10 @@ module ReVIEW
|
|
|
1142
1088
|
|
|
1143
1089
|
def inline_icon(id)
|
|
1144
1090
|
begin
|
|
1145
|
-
%Q
|
|
1091
|
+
%Q(<img src="#{@chapter.image(id).path.sub(%r{\A\./}, '')}" alt="[#{id}]" />)
|
|
1146
1092
|
rescue
|
|
1147
|
-
|
|
1093
|
+
warn "image not bound: #{id}"
|
|
1094
|
+
%Q(<pre>missing image: #{id}</pre>)
|
|
1148
1095
|
end
|
|
1149
1096
|
end
|
|
1150
1097
|
|
|
@@ -1153,18 +1100,18 @@ module ReVIEW
|
|
|
1153
1100
|
end
|
|
1154
1101
|
|
|
1155
1102
|
def inline_comment(str)
|
|
1156
|
-
if @book.config[
|
|
1103
|
+
if @book.config['draft']
|
|
1157
1104
|
%Q(<span class="draft-comment">#{escape_html(str)}</span>)
|
|
1158
1105
|
else
|
|
1159
|
-
|
|
1106
|
+
''
|
|
1160
1107
|
end
|
|
1161
1108
|
end
|
|
1162
1109
|
|
|
1163
1110
|
def inline_tcy(str)
|
|
1164
1111
|
# 縦中横用のtcy、uprightのCSSスタイルについては電書協ガイドラインを参照
|
|
1165
|
-
style =
|
|
1166
|
-
style =
|
|
1167
|
-
%Q
|
|
1112
|
+
style = 'tcy'
|
|
1113
|
+
style = 'upright' if str.size == 1 && str.match(/[[:ascii:]]/)
|
|
1114
|
+
%Q(<span class="#{style}">#{escape_html(str)}</span>)
|
|
1168
1115
|
end
|
|
1169
1116
|
|
|
1170
1117
|
def inline_raw(str)
|
|
@@ -1176,7 +1123,7 @@ module ReVIEW
|
|
|
1176
1123
|
end
|
|
1177
1124
|
|
|
1178
1125
|
def compile_href(url, label)
|
|
1179
|
-
if @book.config[
|
|
1126
|
+
if @book.config['externallink']
|
|
1180
1127
|
%Q(<a href="#{escape_html(url)}" class="link">#{label.nil? ? escape_html(url) : escape_html(label)}</a>)
|
|
1181
1128
|
else
|
|
1182
1129
|
label.nil? ? escape_html(url) : I18n.t('external_link', [escape_html(label), escape_html(url)])
|
|
@@ -1184,23 +1131,23 @@ module ReVIEW
|
|
|
1184
1131
|
end
|
|
1185
1132
|
|
|
1186
1133
|
def flushright(lines)
|
|
1187
|
-
puts split_paragraph(lines).join("\n").gsub(
|
|
1134
|
+
puts split_paragraph(lines).join("\n").gsub('<p>', %Q(<p class="flushright">))
|
|
1188
1135
|
end
|
|
1189
1136
|
|
|
1190
1137
|
def centering(lines)
|
|
1191
|
-
puts split_paragraph(lines).join("\n").gsub(
|
|
1138
|
+
puts split_paragraph(lines).join("\n").gsub('<p>', %Q(<p class="center">))
|
|
1192
1139
|
end
|
|
1193
1140
|
|
|
1194
1141
|
def image_ext
|
|
1195
|
-
|
|
1142
|
+
'png'
|
|
1196
1143
|
end
|
|
1197
1144
|
|
|
1198
1145
|
def olnum(num)
|
|
1199
1146
|
@ol_num = num.to_i
|
|
1200
1147
|
end
|
|
1201
1148
|
|
|
1202
|
-
def make_math_image(str, path, fontsize=12)
|
|
1203
|
-
fontsize2 = (fontsize*1.2).round.to_i
|
|
1149
|
+
def make_math_image(str, path, fontsize = 12)
|
|
1150
|
+
fontsize2 = (fontsize * 1.2).round.to_i
|
|
1204
1151
|
texsrc = <<-EOB
|
|
1205
1152
|
\\documentclass[12pt]{article}
|
|
1206
1153
|
\\usepackage[utf8]{inputenc}
|
|
@@ -1217,13 +1164,11 @@ module ReVIEW
|
|
|
1217
1164
|
\\end{document}
|
|
1218
1165
|
EOB
|
|
1219
1166
|
Dir.mktmpdir do |tmpdir|
|
|
1220
|
-
tex_path = File.join(tmpdir,
|
|
1221
|
-
dvi_path = File.join(tmpdir,
|
|
1167
|
+
tex_path = File.join(tmpdir, 'tmpmath.tex')
|
|
1168
|
+
dvi_path = File.join(tmpdir, 'tmpmath.dvi')
|
|
1222
1169
|
File.write(tex_path, texsrc)
|
|
1223
1170
|
system("latex --interaction=nonstopmode --output-directory=#{tmpdir} #{tex_path} && dvipng -T tight -z9 -o #{path} #{dvi_path}")
|
|
1224
1171
|
end
|
|
1225
1172
|
end
|
|
1226
|
-
|
|
1227
1173
|
end
|
|
1228
|
-
|
|
1229
1174
|
end # module ReVIEW
|