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
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Copyright (c) 2002-2008 Minero Aoki
|
|
5
|
-
# 2009 Minero Aoki, Kenshi Muto
|
|
1
|
+
# Copyright (c) 2009-2017 Minero Aoki, Kenshi Muto
|
|
2
|
+
# 2002-2008 Minero Aoki
|
|
6
3
|
#
|
|
7
4
|
# This program is free software.
|
|
8
5
|
# You can distribute or modify this program under the terms of
|
|
@@ -12,7 +9,6 @@
|
|
|
12
9
|
module ReVIEW
|
|
13
10
|
module Book
|
|
14
11
|
class PageMetric
|
|
15
|
-
|
|
16
12
|
MetricData = Struct.new(:n_lines, :n_columns)
|
|
17
13
|
|
|
18
14
|
def initialize(list_lines, list_columns, text_lines, text_columns, page_per_kbyte)
|
|
@@ -31,7 +27,6 @@ module ReVIEW
|
|
|
31
27
|
def ==(other)
|
|
32
28
|
self.list == other.list && self.text == other.text && self.page_per_kbyte == other.page_per_kbyte
|
|
33
29
|
end
|
|
34
|
-
|
|
35
30
|
end
|
|
36
31
|
end
|
|
37
32
|
end
|
data/lib/review/book/part.rb
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Copyright (c) 2002-2008 Minero Aoki
|
|
5
|
-
# 2009-2016 Minero Aoki, Kenshi Muto
|
|
1
|
+
# Copyright (c) 2009-2017 Minero Aoki, Kenshi Muto
|
|
2
|
+
# 2002-2008 Minero Aoki
|
|
6
3
|
#
|
|
7
4
|
# This program is free software.
|
|
8
5
|
# You can distribute or modify this program under the terms of
|
|
@@ -10,6 +7,7 @@
|
|
|
10
7
|
# For details of the GNU LGPL, see the file "COPYING".
|
|
11
8
|
#
|
|
12
9
|
require 'review/book/compilable'
|
|
10
|
+
|
|
13
11
|
module ReVIEW
|
|
14
12
|
module Book
|
|
15
13
|
class Part
|
|
@@ -17,24 +15,21 @@ module ReVIEW
|
|
|
17
15
|
|
|
18
16
|
# if Part is dummy, `number` is nil.
|
|
19
17
|
#
|
|
20
|
-
def initialize(book, number, chapters, name =
|
|
18
|
+
def initialize(book, number, chapters, name = '', io = nil)
|
|
21
19
|
@book = book
|
|
22
20
|
@number = number
|
|
23
21
|
@chapters = chapters
|
|
24
|
-
@name = name
|
|
22
|
+
@name = name
|
|
25
23
|
@path = name
|
|
24
|
+
@content = nil
|
|
26
25
|
if io
|
|
27
26
|
@content = io.read
|
|
28
27
|
elsif @path && File.exist?(@path)
|
|
29
|
-
@content = File.read(@path, :
|
|
30
|
-
|
|
31
|
-
@content = nil
|
|
32
|
-
end
|
|
33
|
-
if file?
|
|
34
|
-
@title = nil
|
|
35
|
-
else
|
|
36
|
-
@title = name
|
|
28
|
+
@content = File.read(@path, mode: 'r:BOM|utf-8')
|
|
29
|
+
@name = File.basename(@name, '.re')
|
|
37
30
|
end
|
|
31
|
+
@title = name
|
|
32
|
+
@title = nil if file?
|
|
38
33
|
@volume = nil
|
|
39
34
|
end
|
|
40
35
|
|
|
@@ -47,26 +42,29 @@ module ReVIEW
|
|
|
47
42
|
end
|
|
48
43
|
|
|
49
44
|
def volume
|
|
50
|
-
vol = Volume.sum(@chapters.map
|
|
45
|
+
vol = Volume.sum(@chapters.map(&:volume))
|
|
51
46
|
vol.page_per_kbyte = @book.page_metric.page_per_kbyte
|
|
52
47
|
vol
|
|
53
48
|
end
|
|
54
49
|
|
|
55
50
|
def file?
|
|
56
|
-
|
|
51
|
+
name.present? and path.end_with?('.re') ? true : false
|
|
57
52
|
end
|
|
58
53
|
|
|
59
54
|
def format_number(heading = true)
|
|
60
55
|
if heading
|
|
61
|
-
|
|
56
|
+
I18n.t('part', @number)
|
|
62
57
|
else
|
|
63
|
-
|
|
58
|
+
@number.to_s
|
|
64
59
|
end
|
|
65
60
|
end
|
|
66
61
|
|
|
67
|
-
def
|
|
62
|
+
def on_appendix?
|
|
68
63
|
false
|
|
69
64
|
end
|
|
65
|
+
|
|
66
|
+
# backward compatibility
|
|
67
|
+
alias_method :on_APPENDIX?, :on_appendix?
|
|
70
68
|
end
|
|
71
69
|
end
|
|
72
70
|
end
|
data/lib/review/book/volume.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Copyright (c) 2002-2007 Minero Aoki
|
|
1
|
+
# Copyright (c) 2007-2017 Minero Aoki, Kenshi Muto
|
|
2
|
+
# 2002-2007 Minero Aoki
|
|
5
3
|
#
|
|
6
4
|
# This program is free software.
|
|
7
5
|
# You can distribute or modify this program under the terms of
|
|
@@ -11,11 +9,10 @@
|
|
|
11
9
|
module ReVIEW
|
|
12
10
|
module Book
|
|
13
11
|
class Volume
|
|
14
|
-
|
|
15
|
-
def Volume.count_file(path)
|
|
12
|
+
def self.count_file(path)
|
|
16
13
|
b = c = l = 0
|
|
17
14
|
File.foreach(path) do |line|
|
|
18
|
-
next if
|
|
15
|
+
next if /\A\#@/ =~ line
|
|
19
16
|
text = line.gsub(/\s+/, '')
|
|
20
17
|
b += text.bytesize
|
|
21
18
|
c += text.charsize
|
|
@@ -24,11 +21,11 @@ module ReVIEW
|
|
|
24
21
|
new(b, c, l)
|
|
25
22
|
end
|
|
26
23
|
|
|
27
|
-
def
|
|
28
|
-
vols.inject(new
|
|
24
|
+
def self.sum(vols)
|
|
25
|
+
vols.inject(new) { |sum, i| sum + i }
|
|
29
26
|
end
|
|
30
27
|
|
|
31
|
-
def
|
|
28
|
+
def self.dummy
|
|
32
29
|
new(-1, -1, -1)
|
|
33
30
|
end
|
|
34
31
|
|
|
@@ -49,11 +46,11 @@ module ReVIEW
|
|
|
49
46
|
end
|
|
50
47
|
|
|
51
48
|
def page
|
|
52
|
-
(kbytes.to_f
|
|
49
|
+
(kbytes.to_f / @page_per_kbyte).ceil
|
|
53
50
|
end
|
|
54
51
|
|
|
55
52
|
def to_s
|
|
56
|
-
"#{kbytes
|
|
53
|
+
"#{kbytes}KB #{@chars}C #{@lines}L #{page}P"
|
|
57
54
|
end
|
|
58
55
|
|
|
59
56
|
def +(other)
|
|
@@ -61,7 +58,6 @@ module ReVIEW
|
|
|
61
58
|
@chars + other.chars,
|
|
62
59
|
@lines + other.lines)
|
|
63
60
|
end
|
|
64
|
-
|
|
65
61
|
end
|
|
66
62
|
end
|
|
67
63
|
end
|
data/lib/review/builder.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
1
|
# Copyright (c) 2002-2017 Minero Aoki, Kenshi Muto
|
|
4
2
|
#
|
|
5
3
|
# This program is free software.
|
|
@@ -16,11 +14,10 @@ require 'stringio'
|
|
|
16
14
|
require 'cgi'
|
|
17
15
|
|
|
18
16
|
module ReVIEW
|
|
19
|
-
|
|
20
17
|
class Builder
|
|
21
18
|
include TextUtils
|
|
22
19
|
|
|
23
|
-
CAPTION_TITLES = %w
|
|
20
|
+
CAPTION_TITLES = %w[note memo tip info warning important caution notice].freeze
|
|
24
21
|
|
|
25
22
|
def pre_paragraph
|
|
26
23
|
nil
|
|
@@ -33,6 +30,7 @@ module ReVIEW
|
|
|
33
30
|
def initialize(strict = false, *args)
|
|
34
31
|
@strict = strict
|
|
35
32
|
@output = nil
|
|
33
|
+
@logger = ReVIEW.logger
|
|
36
34
|
builder_init(*args)
|
|
37
35
|
end
|
|
38
36
|
|
|
@@ -48,9 +46,7 @@ module ReVIEW
|
|
|
48
46
|
@book = @chapter.book if @chapter.present?
|
|
49
47
|
@tabwidth = nil
|
|
50
48
|
@tsize = nil
|
|
51
|
-
if @book && @book.config && @book.config[
|
|
52
|
-
@tabwidth = @book.config["tabwidth"]
|
|
53
|
-
end
|
|
49
|
+
@tabwidth = @book.config['tabwidth'] if @book && @book.config && @book.config['tabwidth']
|
|
54
50
|
builder_init_file
|
|
55
51
|
end
|
|
56
52
|
|
|
@@ -80,7 +76,7 @@ module ReVIEW
|
|
|
80
76
|
def headline_prefix(level)
|
|
81
77
|
@sec_counter.inc(level)
|
|
82
78
|
anchor = @sec_counter.anchor(level)
|
|
83
|
-
prefix = @sec_counter.prefix(level, @book.config[
|
|
79
|
+
prefix = @sec_counter.prefix(level, @book.config['secnolevel'])
|
|
84
80
|
[prefix, anchor]
|
|
85
81
|
end
|
|
86
82
|
private :headline_prefix
|
|
@@ -90,14 +86,12 @@ module ReVIEW
|
|
|
90
86
|
@first_line_num = num.to_i
|
|
91
87
|
end
|
|
92
88
|
|
|
93
|
-
def
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
end
|
|
97
|
-
line_num = @first_line_num
|
|
89
|
+
def line_num
|
|
90
|
+
return 1 unless @first_line_num
|
|
91
|
+
line_n = @first_line_num
|
|
98
92
|
@first_line_num = nil
|
|
99
93
|
|
|
100
|
-
|
|
94
|
+
line_n
|
|
101
95
|
end
|
|
102
96
|
|
|
103
97
|
def list(lines, id, caption, lang = nil)
|
|
@@ -138,47 +132,37 @@ module ReVIEW
|
|
|
138
132
|
lines.each_with_index do |line, idx|
|
|
139
133
|
if /\A[\=\-]{12}/ =~ line
|
|
140
134
|
# just ignore
|
|
141
|
-
#error "too many table separator" if sepidx
|
|
135
|
+
# error "too many table separator" if sepidx
|
|
142
136
|
sepidx ||= idx
|
|
143
137
|
next
|
|
144
138
|
end
|
|
145
|
-
rows.push(line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') })
|
|
139
|
+
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
|
146
140
|
end
|
|
147
141
|
rows = adjust_n_cols(rows)
|
|
148
142
|
|
|
149
143
|
begin
|
|
150
|
-
table_header id, caption
|
|
144
|
+
table_header id, caption if caption.present?
|
|
151
145
|
rescue KeyError
|
|
152
146
|
error "no such table: #{id}"
|
|
153
147
|
end
|
|
154
148
|
return if rows.empty?
|
|
155
149
|
table_begin rows.first.size
|
|
156
150
|
if sepidx
|
|
157
|
-
sepidx.times
|
|
158
|
-
|
|
159
|
-
end
|
|
160
|
-
rows.each do |cols|
|
|
161
|
-
tr(cols.map {|s| td(s) })
|
|
162
|
-
end
|
|
151
|
+
sepidx.times { tr(rows.shift.map { |s| th(s) }) }
|
|
152
|
+
rows.each { |cols| tr(cols.map { |s| td(s) }) }
|
|
163
153
|
else
|
|
164
154
|
rows.each do |cols|
|
|
165
155
|
h, *cs = *cols
|
|
166
|
-
tr([th(h)] + cs.map {|s| td(s) })
|
|
156
|
+
tr([th(h)] + cs.map { |s| td(s) })
|
|
167
157
|
end
|
|
168
158
|
end
|
|
169
159
|
table_end
|
|
170
160
|
end
|
|
171
161
|
|
|
172
162
|
def adjust_n_cols(rows)
|
|
173
|
-
rows.each
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
n_maxcols = rows.map {|cols| cols.size }.max
|
|
179
|
-
rows.each do |cols|
|
|
180
|
-
cols.concat [''] * (n_maxcols - cols.size)
|
|
181
|
-
end
|
|
163
|
+
rows.each { |cols| cols.pop while cols.last and cols.last.strip.empty? }
|
|
164
|
+
n_maxcols = rows.map(&:size).max
|
|
165
|
+
rows.each { |cols| cols.concat [''] * (n_maxcols - cols.size) }
|
|
182
166
|
rows
|
|
183
167
|
end
|
|
184
168
|
private :adjust_n_cols
|
|
@@ -187,17 +171,17 @@ module ReVIEW
|
|
|
187
171
|
table(lines, nil, caption)
|
|
188
172
|
end
|
|
189
173
|
|
|
190
|
-
#def footnote(id, str)
|
|
191
|
-
#
|
|
192
|
-
#end
|
|
174
|
+
# def footnote(id, str)
|
|
175
|
+
# @footnotes.push [id, str]
|
|
176
|
+
# end
|
|
193
177
|
#
|
|
194
|
-
#def flush_footnote
|
|
195
|
-
#
|
|
196
|
-
#
|
|
197
|
-
#
|
|
198
|
-
#
|
|
199
|
-
#
|
|
200
|
-
#end
|
|
178
|
+
# def flush_footnote
|
|
179
|
+
# footnote_begin
|
|
180
|
+
# @footnotes.each do |id, str|
|
|
181
|
+
# footnote_item(id, str)
|
|
182
|
+
# end
|
|
183
|
+
# footnote_end
|
|
184
|
+
# end
|
|
201
185
|
|
|
202
186
|
def compile_inline(s)
|
|
203
187
|
@compiler.text(s)
|
|
@@ -225,14 +209,14 @@ module ReVIEW
|
|
|
225
209
|
end
|
|
226
210
|
|
|
227
211
|
def inline_list(id)
|
|
228
|
-
"#{I18n.t(
|
|
212
|
+
"#{I18n.t('list')}#{@chapter.list(id).number}"
|
|
229
213
|
rescue KeyError
|
|
230
214
|
error "unknown list: #{id}"
|
|
231
215
|
nofunc_text("[UnknownList:#{id}]")
|
|
232
216
|
end
|
|
233
217
|
|
|
234
218
|
def inline_img(id)
|
|
235
|
-
"#{I18n.t(
|
|
219
|
+
"#{I18n.t('image')}#{@chapter.image(id).number}"
|
|
236
220
|
rescue KeyError
|
|
237
221
|
error "unknown image: #{id}"
|
|
238
222
|
nofunc_text("[UnknownImage:#{id}]")
|
|
@@ -249,7 +233,7 @@ module ReVIEW
|
|
|
249
233
|
end
|
|
250
234
|
|
|
251
235
|
def inline_table(id)
|
|
252
|
-
"#{I18n.t(
|
|
236
|
+
"#{I18n.t('table')}#{@chapter.table(id).number}"
|
|
253
237
|
rescue KeyError
|
|
254
238
|
error "unknown table: #{id}"
|
|
255
239
|
nofunc_text("[UnknownTable:#{id}]")
|
|
@@ -268,8 +252,8 @@ module ReVIEW
|
|
|
268
252
|
|
|
269
253
|
def inline_ruby(arg)
|
|
270
254
|
base, *ruby = *arg.scan(/(?:(?:(?:\\\\)*\\,)|[^,\\]+)+/)
|
|
271
|
-
base = base.gsub(/\\,/,
|
|
272
|
-
ruby = ruby.join(
|
|
255
|
+
base = base.gsub(/\\,/, ',') if base
|
|
256
|
+
ruby = ruby.join(',').gsub(/\\,/, ',') if ruby
|
|
273
257
|
compile_ruby(base, ruby)
|
|
274
258
|
end
|
|
275
259
|
|
|
@@ -280,8 +264,8 @@ module ReVIEW
|
|
|
280
264
|
|
|
281
265
|
def inline_href(arg)
|
|
282
266
|
url, label = *arg.scan(/(?:(?:(?:\\\\)*\\,)|[^,\\]+)+/).map(&:lstrip)
|
|
283
|
-
url = url.gsub(/\\,/,
|
|
284
|
-
label = label.gsub(/\\,/,
|
|
267
|
+
url = url.gsub(/\\,/, ',').strip
|
|
268
|
+
label = label.gsub(/\\,/, ',').strip if label
|
|
285
269
|
compile_href(url, label)
|
|
286
270
|
end
|
|
287
271
|
|
|
@@ -292,17 +276,15 @@ module ReVIEW
|
|
|
292
276
|
def bibpaper(lines, id, caption)
|
|
293
277
|
bibpaper_header id, caption
|
|
294
278
|
unless lines.empty?
|
|
295
|
-
puts
|
|
279
|
+
puts
|
|
296
280
|
bibpaper_bibpaper id, caption, lines
|
|
297
281
|
end
|
|
298
|
-
puts
|
|
282
|
+
puts
|
|
299
283
|
end
|
|
300
284
|
|
|
301
285
|
def inline_hd(id)
|
|
302
286
|
m = /\A([^|]+)\|(.+)/.match(id)
|
|
303
|
-
if m && m[1]
|
|
304
|
-
chapter = @book.contents.detect{|chap| chap.id == m[1]}
|
|
305
|
-
end
|
|
287
|
+
chapter = @book.contents.detect { |chap| chap.id == m[1] } if m && m[1]
|
|
306
288
|
if chapter
|
|
307
289
|
inline_hd_chap(chapter, m[2])
|
|
308
290
|
else
|
|
@@ -315,7 +297,7 @@ module ReVIEW
|
|
|
315
297
|
|
|
316
298
|
def inline_column(id)
|
|
317
299
|
m = /\A([^|]+)\|(.+)/.match(id)
|
|
318
|
-
chapter = @book.chapters.detect{|chap| chap.id == m[1]} if m && m[1]
|
|
300
|
+
chapter = @book.chapters.detect { |chap| chap.id == m[1] } if m && m[1]
|
|
319
301
|
if chapter
|
|
320
302
|
inline_column_chap(chapter, m[2])
|
|
321
303
|
else
|
|
@@ -330,43 +312,40 @@ module ReVIEW
|
|
|
330
312
|
chapter.column(id).caption
|
|
331
313
|
end
|
|
332
314
|
|
|
315
|
+
def inline_pageref(id)
|
|
316
|
+
"[link:#{id}]"
|
|
317
|
+
end
|
|
318
|
+
|
|
333
319
|
def inline_tcy(arg)
|
|
334
320
|
"#{arg}[rotate 90 degree]"
|
|
335
321
|
end
|
|
336
322
|
|
|
337
323
|
def raw(str)
|
|
338
324
|
if matched = str.match(/\|(.*?)\|(.*)/)
|
|
339
|
-
builders = matched[1].split(
|
|
325
|
+
builders = matched[1].split(',').map { |i| i.gsub(/\s/, '') }
|
|
340
326
|
c = target_name
|
|
341
|
-
if builders.include?(c)
|
|
342
|
-
print matched[2].gsub("\\n", "\n")
|
|
343
|
-
else
|
|
344
|
-
""
|
|
345
|
-
end
|
|
327
|
+
print matched[2].gsub('\\n', "\n") if builders.include?(c)
|
|
346
328
|
else
|
|
347
|
-
print str.gsub(
|
|
329
|
+
print str.gsub('\\n', "\n")
|
|
348
330
|
end
|
|
349
331
|
end
|
|
350
332
|
|
|
351
333
|
def embed(lines, arg = nil)
|
|
352
334
|
if arg
|
|
353
|
-
builders = arg.gsub(/^\s*\|/,
|
|
335
|
+
builders = arg.gsub(/^\s*\|/, '').gsub(/\|\s*$/, '').gsub(/\s/, '').split(',')
|
|
354
336
|
c = target_name
|
|
355
|
-
if builders.include?(c)
|
|
356
|
-
print lines.join()
|
|
357
|
-
else
|
|
358
|
-
""
|
|
359
|
-
end
|
|
337
|
+
print lines.join if builders.include?(c)
|
|
360
338
|
else
|
|
361
|
-
print lines.join
|
|
339
|
+
print lines.join
|
|
362
340
|
end
|
|
363
341
|
end
|
|
364
342
|
|
|
365
343
|
def warn(msg)
|
|
366
|
-
|
|
344
|
+
@logger.warn "#{@location}: #{msg}"
|
|
367
345
|
end
|
|
368
346
|
|
|
369
347
|
def error(msg)
|
|
348
|
+
raise ApplicationError, msg if msg =~ /:\d+: error: /
|
|
370
349
|
raise ApplicationError, "#{@location}: error: #{msg}"
|
|
371
350
|
end
|
|
372
351
|
|
|
@@ -379,53 +358,44 @@ module ReVIEW
|
|
|
379
358
|
end
|
|
380
359
|
|
|
381
360
|
def parse_metric(type, metric)
|
|
382
|
-
return
|
|
361
|
+
return '' if metric.blank?
|
|
383
362
|
params = metric.split(/,\s*/)
|
|
384
363
|
results = []
|
|
385
364
|
params.each do |param|
|
|
386
365
|
if param =~ /\A.+?::/
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
else
|
|
390
|
-
next
|
|
391
|
-
end
|
|
366
|
+
next unless param =~ /\A#{type}::/
|
|
367
|
+
param.sub!(/\A#{type}::/, '')
|
|
392
368
|
end
|
|
393
369
|
param2 = handle_metric(param)
|
|
394
370
|
results.push(param2)
|
|
395
371
|
end
|
|
396
|
-
|
|
372
|
+
result_metric(results)
|
|
397
373
|
end
|
|
398
374
|
|
|
399
375
|
def get_chap(chapter = @chapter)
|
|
400
|
-
if @book.config[
|
|
401
|
-
if chapter.is_a?
|
|
402
|
-
|
|
403
|
-
else
|
|
404
|
-
return chapter.format_number(nil)
|
|
405
|
-
end
|
|
376
|
+
if @book.config['secnolevel'] > 0 && !chapter.number.nil? && !chapter.number.to_s.empty?
|
|
377
|
+
return I18n.t('part_short', chapter.number) if chapter.is_a?(ReVIEW::Book::Part)
|
|
378
|
+
return chapter.format_number(nil)
|
|
406
379
|
end
|
|
407
|
-
|
|
380
|
+
nil
|
|
408
381
|
end
|
|
409
382
|
|
|
410
383
|
def extract_chapter_id(chap_ref)
|
|
411
384
|
m = /\A([\w+-]+)\|(.+)/.match(chap_ref)
|
|
412
|
-
if m
|
|
413
|
-
|
|
414
|
-
else
|
|
415
|
-
return [@chapter, chap_ref]
|
|
416
|
-
end
|
|
385
|
+
return [@book.contents.detect { |chap| chap.id == m[1] }, m[2]] if m
|
|
386
|
+
[@chapter, chap_ref]
|
|
417
387
|
end
|
|
418
388
|
|
|
419
|
-
def captionblock(
|
|
389
|
+
def captionblock(_type, _lines, _caption, _specialstyle = nil)
|
|
420
390
|
raise NotImplementedError
|
|
421
391
|
end
|
|
422
392
|
|
|
423
393
|
CAPTION_TITLES.each do |name|
|
|
424
|
-
class_eval %Q
|
|
394
|
+
class_eval %Q(
|
|
425
395
|
def #{name}(lines, caption = nil)
|
|
426
396
|
captionblock("#{name}", lines, caption)
|
|
427
397
|
end
|
|
428
|
-
|
|
398
|
+
)
|
|
429
399
|
end
|
|
430
400
|
|
|
431
401
|
def graph(lines, id, command, caption = nil)
|
|
@@ -437,20 +407,20 @@ module ReVIEW
|
|
|
437
407
|
|
|
438
408
|
line = self.unescape(lines.join("\n"))
|
|
439
409
|
cmds = {
|
|
440
|
-
:
|
|
441
|
-
:
|
|
442
|
-
"#{
|
|
443
|
-
" set output
|
|
444
|
-
:
|
|
410
|
+
graphviz: "echo '#{line}' | dot -T#{image_ext} -o#{file_path}",
|
|
411
|
+
gnuplot: %Q(echo 'set terminal ) +
|
|
412
|
+
"#{image_ext == 'eps' ? 'postscript eps' : image_ext}\n" +
|
|
413
|
+
%Q(" set output "#{file_path}"\n#{line}' | gnuplot),
|
|
414
|
+
blockdiag: "echo '#{line}' " +
|
|
445
415
|
"| blockdiag -a -T #{image_ext} -o #{file_path} /dev/stdin",
|
|
446
|
-
:
|
|
416
|
+
aafigure: "echo '#{line}' | aafigure -t#{image_ext} -o#{file_path}"
|
|
447
417
|
}
|
|
448
418
|
cmd = cmds[command.to_sym]
|
|
449
419
|
warn cmd
|
|
450
420
|
system cmd
|
|
451
421
|
@chapter.image_index.image_finder.add_entry(file_path)
|
|
452
422
|
|
|
453
|
-
image(lines, id, caption
|
|
423
|
+
image(lines, id, caption)
|
|
454
424
|
end
|
|
455
425
|
|
|
456
426
|
def image_ext
|
|
@@ -462,9 +432,7 @@ module ReVIEW
|
|
|
462
432
|
end
|
|
463
433
|
|
|
464
434
|
def include(file_name)
|
|
465
|
-
File.foreach(file_name)
|
|
466
|
-
paragraph([line])
|
|
467
|
-
end
|
|
435
|
+
File.foreach(file_name) { |line| paragraph([line]) }
|
|
468
436
|
end
|
|
469
437
|
|
|
470
438
|
def ul_item_begin(lines)
|
|
@@ -476,11 +444,9 @@ module ReVIEW
|
|
|
476
444
|
|
|
477
445
|
def tsize(str)
|
|
478
446
|
if matched = str.match(/\A\|(.*?)\|(.*)/)
|
|
479
|
-
builders = matched[1].split(
|
|
480
|
-
c = self.class.to_s.gsub(
|
|
481
|
-
if builders.include?(c)
|
|
482
|
-
@tsize = matched[2]
|
|
483
|
-
end
|
|
447
|
+
builders = matched[1].split(',').map { |i| i.gsub(/\s/, '') }
|
|
448
|
+
c = self.class.to_s.gsub('ReVIEW::', '').gsub('Builder', '').downcase
|
|
449
|
+
@tsize = matched[2] if builders.include?(c)
|
|
484
450
|
else
|
|
485
451
|
@tsize = str
|
|
486
452
|
end
|
|
@@ -488,25 +454,25 @@ module ReVIEW
|
|
|
488
454
|
|
|
489
455
|
def inline_raw(args)
|
|
490
456
|
if matched = args.match(/\|(.*?)\|(.*)/)
|
|
491
|
-
builders = matched[1].split(
|
|
492
|
-
c = self.class.to_s.gsub(
|
|
457
|
+
builders = matched[1].split(',').map { |i| i.gsub(/\s/, '') }
|
|
458
|
+
c = self.class.to_s.gsub('ReVIEW::', '').gsub('Builder', '').downcase
|
|
493
459
|
if builders.include?(c)
|
|
494
|
-
matched[2].gsub(
|
|
460
|
+
matched[2].gsub('\\n', "\n")
|
|
495
461
|
else
|
|
496
|
-
|
|
462
|
+
''
|
|
497
463
|
end
|
|
498
464
|
else
|
|
499
|
-
args.gsub(
|
|
465
|
+
args.gsub('\\n', "\n")
|
|
500
466
|
end
|
|
501
467
|
end
|
|
502
468
|
|
|
503
469
|
def inline_embed(args)
|
|
504
470
|
if matched = args.match(/\|(.*?)\|(.*)/)
|
|
505
|
-
builders = matched[1].split(
|
|
471
|
+
builders = matched[1].split(',').map { |i| i.gsub(/\s/, '') }
|
|
506
472
|
if builders.include?(target_name)
|
|
507
473
|
matched[2]
|
|
508
474
|
else
|
|
509
|
-
|
|
475
|
+
''
|
|
510
476
|
end
|
|
511
477
|
else
|
|
512
478
|
args
|
|
@@ -524,5 +490,4 @@ module ReVIEW
|
|
|
524
490
|
end
|
|
525
491
|
end
|
|
526
492
|
end
|
|
527
|
-
|
|
528
493
|
end # module ReVIEW
|