review 5.0.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-tex.yml +35 -0
- data/.github/workflows/ruby-win.yml +8 -4
- data/.github/workflows/ruby.yml +6 -2
- data/.rubocop.yml +24 -9
- data/NEWS.ja.md +215 -0
- data/NEWS.md +215 -1
- data/README.md +7 -6
- data/Rakefile +7 -2
- data/bin/review +2 -4
- data/bin/review-catalog-converter +3 -3
- data/bin/review-check +6 -8
- data/bin/review-checkdep +1 -4
- data/bin/review-compile +10 -20
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +1 -3
- data/bin/review-index +11 -5
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +30 -38
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +3 -3
- data/bin/review-vol +1 -4
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +23 -5
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +49 -12
- data/doc/format.md +52 -12
- data/doc/quickstart.ja.md +11 -1
- data/doc/quickstart.md +11 -2
- data/doc/writing_vertical.ja.md +6 -0
- data/lib/review/book/base.rb +4 -0
- data/lib/review/book/book_unit.rb +15 -2
- data/lib/review/book/chapter.rb +3 -0
- data/lib/review/book/index.rb +5 -1
- data/lib/review/book/volume.rb +1 -0
- data/lib/review/builder.rb +90 -54
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +2 -0
- data/lib/review/compiler.rb +88 -52
- data/lib/review/configure.rb +64 -7
- data/lib/review/epubmaker/content.rb +113 -0
- data/lib/review/epubmaker/epubcommon.rb +372 -0
- data/lib/review/epubmaker/epubv2.rb +178 -0
- data/lib/review/epubmaker/epubv3.rb +231 -0
- data/lib/review/epubmaker/producer.rb +167 -0
- data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
- data/lib/review/epubmaker/zip_exporter.rb +84 -0
- data/lib/review/epubmaker.rb +114 -129
- data/lib/review/exception.rb +13 -0
- data/lib/review/htmlbuilder.rb +109 -67
- data/lib/review/htmlutils.rb +1 -1
- data/lib/review/i18n.rb +1 -0
- data/lib/review/i18n.yml +6 -0
- data/lib/review/idgxmlbuilder.rb +72 -48
- data/lib/review/idgxmlmaker.rb +15 -14
- data/lib/review/img_math.rb +239 -0
- data/lib/review/index_builder.rb +90 -32
- data/lib/review/init.rb +4 -4
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +79 -58
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +112 -2
- data/lib/review/loggable.rb +27 -0
- data/lib/review/logger.rb +89 -2
- data/lib/review/makerhelper.rb +7 -206
- data/lib/review/markdownbuilder.rb +44 -4
- data/lib/review/pdfmaker.rb +70 -51
- data/lib/review/plaintextbuilder.rb +20 -11
- data/lib/review/preprocessor/directive.rb +35 -0
- data/lib/review/preprocessor/line.rb +34 -0
- data/lib/review/preprocessor/repository.rb +177 -0
- data/lib/review/preprocessor.rb +105 -301
- data/lib/review/rstbuilder.rb +13 -4
- data/lib/review/sec_counter.rb +1 -0
- data/lib/review/template.rb +11 -1
- data/lib/review/textmaker.rb +23 -20
- data/lib/review/textutils.rb +10 -17
- data/lib/review/tocprinter.rb +93 -71
- data/lib/review/topbuilder.rb +44 -19
- data/lib/review/update.rb +5 -6
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +11 -12
- data/lib/review/webmaker.rb +31 -27
- data/lib/review/webtocprinter.rb +10 -9
- data/lib/review/yamlloader.rb +2 -1
- data/lib/review.rb +1 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config.yml +1 -1
- data/samples/sample-book/src/lib/tasks/review.rake +19 -1
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
- data/samples/syntax-book/ch01.re +1 -1
- data/samples/syntax-book/ch02.re +30 -6
- data/samples/syntax-book/ch03.re +1 -1
- data/samples/syntax-book/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
- data/templates/html/_colophon.html.erb +23 -0
- data/templates/html/_colophon_history.html.erb +9 -0
- data/templates/html/_cover.html.erb +10 -0
- data/templates/html/_part_body.html.erb +6 -0
- data/templates/html/_titlepage.html.erb +20 -0
- data/templates/html/layout-html5.html.erb +6 -0
- data/templates/html/layout-xhtml1.html.erb +6 -0
- data/templates/latex/config.erb +11 -0
- data/templates/latex/review-jlreq/review-base.sty +7 -9
- data/templates/latex/review-jlreq/review-jlreq.cls +48 -6
- data/templates/latex/review-jlreq/review-style.sty +6 -1
- data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
- data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
- data/templates/latex/review-jsbook/review-base.sty +13 -9
- data/templates/latex/review-jsbook/review-jsbook.cls +41 -6
- data/templates/latex/review-jsbook/review-style.sty +6 -1
- data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
- data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
- data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
- data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
- data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
- data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
- data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
- data/templates/web/html/layout-html5.html.erb +6 -5
- data/templates/web/html/layout-xhtml1.html.erb +6 -0
- data/test/assets/header_listener.html +35 -0
- data/test/assets/img_math/img1.png +0 -0
- data/test/assets/img_math/img2.png +0 -0
- data/test/assets/img_math/img3.png +0 -0
- data/test/assets/syntax_book_index_detail.txt +60 -0
- data/test/assets/test_template.tex +7 -1
- data/test/assets/test_template_backmatter.tex +7 -1
- data/test/run_test.rb +1 -1
- data/test/test_book_chapter.rb +27 -4
- data/test/test_builder.rb +10 -8
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epub3maker.rb +168 -124
- data/test/test_epubmaker.rb +248 -131
- data/test/test_epubmaker_cmd.rb +15 -4
- data/test/test_helper.rb +5 -4
- data/test/test_htmlbuilder.rb +170 -31
- data/test/test_idgxmlbuilder.rb +44 -23
- data/test/test_idgxmlmaker_cmd.rb +7 -3
- data/test/test_img_math.rb +111 -0
- data/test/test_index.rb +30 -4
- data/test/test_indexbuilder.rb +5 -5
- data/test/test_latexbuilder.rb +151 -26
- data/test/test_latexbuilder_v2.rb +18 -10
- data/test/test_lineinput.rb +20 -93
- data/test/test_markdownbuilder.rb +42 -0
- data/test/test_pdfmaker.rb +90 -0
- data/test/test_pdfmaker_cmd.rb +2 -2
- data/test/test_plaintextbuilder.rb +56 -40
- data/test/test_preprocessor.rb +188 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +13 -0
- data/test/test_template.rb +12 -2
- data/test/test_textmaker_cmd.rb +5 -1
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +50 -19
- data/test/test_update.rb +34 -34
- data/test/test_zip_exporter.rb +5 -6
- metadata +95 -17
- data/lib/epubmaker/content.rb +0 -111
- data/lib/epubmaker/epubcommon.rb +0 -449
- data/lib/epubmaker/epubv2.rb +0 -142
- data/lib/epubmaker/epubv3.rb +0 -235
- data/lib/epubmaker/producer.rb +0 -375
- data/lib/epubmaker/zip_exporter.rb +0 -81
- data/lib/epubmaker.rb +0 -23
- data/lib/lineinput.rb +0 -155
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2018-
|
1
|
+
# Copyright (c) 2018-2021 Kenshi Muto
|
2
2
|
#
|
3
3
|
# This program is free software.
|
4
4
|
# You can distribute or modify this program under the terms of
|
@@ -42,12 +42,12 @@ module ReVIEW
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def builder_init_file
|
45
|
+
super
|
45
46
|
@section = 0
|
46
47
|
@subsection = 0
|
47
48
|
@subsubsection = 0
|
48
49
|
@subsubsubsection = 0
|
49
50
|
@blank_seen = true
|
50
|
-
@sec_counter = SecCounter.new(5, @chapter)
|
51
51
|
end
|
52
52
|
private :builder_init_file
|
53
53
|
|
@@ -74,6 +74,7 @@ module ReVIEW
|
|
74
74
|
private :blank
|
75
75
|
|
76
76
|
def result
|
77
|
+
check_printendnotes
|
77
78
|
solve_nest(@output.string)
|
78
79
|
end
|
79
80
|
|
@@ -89,7 +90,7 @@ module ReVIEW
|
|
89
90
|
clevel.pop
|
90
91
|
lines.push("\x01→END←\x01")
|
91
92
|
else
|
92
|
-
lines.push("\t" * clevel.size + l)
|
93
|
+
lines.push(("\t" * clevel.size) + l)
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
@@ -137,7 +138,7 @@ module ReVIEW
|
|
137
138
|
|
138
139
|
def dd(lines)
|
139
140
|
split_paragraph(lines).each do |paragraph|
|
140
|
-
puts paragraph.
|
141
|
+
puts paragraph.delete("\n")
|
141
142
|
end
|
142
143
|
end
|
143
144
|
|
@@ -169,7 +170,7 @@ module ReVIEW
|
|
169
170
|
list_header(id, caption, lang)
|
170
171
|
end
|
171
172
|
rescue KeyError
|
172
|
-
|
173
|
+
app_error "no such list: #{id}"
|
173
174
|
end
|
174
175
|
blank
|
175
176
|
end
|
@@ -238,7 +239,7 @@ module ReVIEW
|
|
238
239
|
list_header(id, caption, lang)
|
239
240
|
end
|
240
241
|
rescue KeyError
|
241
|
-
|
242
|
+
app_error "no such list: #{id}"
|
242
243
|
end
|
243
244
|
blank
|
244
245
|
end
|
@@ -337,7 +338,7 @@ module ReVIEW
|
|
337
338
|
def inline_fn(id)
|
338
339
|
" 注#{@chapter.footnote(id).number} "
|
339
340
|
rescue KeyError
|
340
|
-
|
341
|
+
app_error "unknown footnote: #{id}"
|
341
342
|
end
|
342
343
|
|
343
344
|
def compile_ruby(base, _ruby)
|
@@ -401,7 +402,7 @@ module ReVIEW
|
|
401
402
|
def inline_bib(id)
|
402
403
|
%Q(#{@chapter.bibpaper(id).number} )
|
403
404
|
rescue KeyError
|
404
|
-
|
405
|
+
app_error "unknown bib: #{id}"
|
405
406
|
end
|
406
407
|
|
407
408
|
def inline_hd_chap(chap, id)
|
@@ -412,7 +413,7 @@ module ReVIEW
|
|
412
413
|
I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption))
|
413
414
|
end
|
414
415
|
rescue KeyError
|
415
|
-
|
416
|
+
app_error "unknown headline: #{id}"
|
416
417
|
end
|
417
418
|
|
418
419
|
def noindent
|
@@ -647,10 +648,18 @@ module ReVIEW
|
|
647
648
|
''
|
648
649
|
end
|
649
650
|
|
651
|
+
def inline_ins(str)
|
652
|
+
str
|
653
|
+
end
|
654
|
+
|
650
655
|
def inline_del(_str)
|
651
656
|
''
|
652
657
|
end
|
653
658
|
|
659
|
+
def inline_tcy(str)
|
660
|
+
str
|
661
|
+
end
|
662
|
+
|
654
663
|
def inline_br(_str)
|
655
664
|
"\n"
|
656
665
|
end
|
@@ -672,7 +681,7 @@ module ReVIEW
|
|
672
681
|
if @book.config['chapref']
|
673
682
|
chs2 = @book.config['chapref'].split(',')
|
674
683
|
if chs2.size != 3
|
675
|
-
|
684
|
+
app_error '--chapsplitter must have exactly 3 parameters with comma.'
|
676
685
|
end
|
677
686
|
chs = chs2
|
678
687
|
end
|
@@ -686,7 +695,7 @@ module ReVIEW
|
|
686
695
|
end
|
687
696
|
end
|
688
697
|
rescue KeyError
|
689
|
-
|
698
|
+
app_error "unknown chapter: #{id}"
|
690
699
|
end
|
691
700
|
|
692
701
|
def source(lines, caption = nil, _lang = nil)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright (c) 2010-2021 Minero Aoki, Kenshi Muto
|
2
|
+
#
|
3
|
+
# This program is free software.
|
4
|
+
# You can distribute or modify this program under the terms of
|
5
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
6
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
7
|
+
#
|
8
|
+
|
9
|
+
module ReVIEW
|
10
|
+
class Preprocessor
|
11
|
+
class Directive
|
12
|
+
def initialize(op, args, opts)
|
13
|
+
@op = op
|
14
|
+
@args = args
|
15
|
+
@opts = opts
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :op
|
19
|
+
attr_reader :args
|
20
|
+
attr_reader :opts
|
21
|
+
|
22
|
+
def arg
|
23
|
+
@args.first
|
24
|
+
end
|
25
|
+
|
26
|
+
def opt
|
27
|
+
@opts.first
|
28
|
+
end
|
29
|
+
|
30
|
+
def [](key)
|
31
|
+
@opts[key]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Copyright (c) 2010-2021 Minero Aoki, Kenshi Muto
|
2
|
+
#
|
3
|
+
# This program is free software.
|
4
|
+
# You can distribute or modify this program under the terms of
|
5
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
6
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
7
|
+
#
|
8
|
+
|
9
|
+
module ReVIEW
|
10
|
+
class Preprocessor
|
11
|
+
class Line
|
12
|
+
def initialize(number, string)
|
13
|
+
@number = number
|
14
|
+
@string = string
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :number
|
18
|
+
attr_reader :string
|
19
|
+
alias_method :to_s, :string
|
20
|
+
|
21
|
+
def edit
|
22
|
+
self.class.new(@number, yield(@string))
|
23
|
+
end
|
24
|
+
|
25
|
+
def empty?
|
26
|
+
@string.strip.empty?
|
27
|
+
end
|
28
|
+
|
29
|
+
def num_indent
|
30
|
+
@string.slice(/\A\s*/).size
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
# Copyright (c) 2010-2021 Minero Aoki, Kenshi Muto
|
2
|
+
#
|
3
|
+
# This program is free software.
|
4
|
+
# You can distribute or modify this program under the terms of
|
5
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
6
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'review/textutils'
|
10
|
+
require 'review/loggable'
|
11
|
+
|
12
|
+
module ReVIEW
|
13
|
+
class Preprocessor
|
14
|
+
class Repository
|
15
|
+
include TextUtils
|
16
|
+
include Loggable
|
17
|
+
|
18
|
+
def initialize(param)
|
19
|
+
@repository = {}
|
20
|
+
@config = param
|
21
|
+
@leave_content = nil
|
22
|
+
@logger = ReVIEW.logger
|
23
|
+
end
|
24
|
+
|
25
|
+
def fetch_file(file)
|
26
|
+
file_descripter(file)['file']
|
27
|
+
end
|
28
|
+
|
29
|
+
def fetch_range(file, name)
|
30
|
+
fetch(file, 'range', name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def fetch(file, type, name)
|
34
|
+
table = file_descripter(file)[type] or return nil
|
35
|
+
table[name]
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def file_descripter(fname)
|
41
|
+
@leave_content = File.extname(fname) == '.re'
|
42
|
+
return @repository[fname] if @repository[fname]
|
43
|
+
|
44
|
+
@repository[fname] = git?(fname) ? parse_git_blob(fname) : parse_file(fname)
|
45
|
+
end
|
46
|
+
|
47
|
+
def git?(fname)
|
48
|
+
fname.start_with?('git|')
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_git_blob(g_obj)
|
52
|
+
IO.popen('git show ' + g_obj.sub(/\Agit\|/, ''), 'r') do |f|
|
53
|
+
@inf = f
|
54
|
+
return _parse_file(f)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def parse_file(fname)
|
59
|
+
File.open(fname, 'rt:BOM|utf-8') do |f|
|
60
|
+
@inf = f
|
61
|
+
return _parse_file(f)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def _parse_file(f)
|
66
|
+
whole = []
|
67
|
+
repo = { 'file' => whole }
|
68
|
+
curr = { 'WHOLE' => whole }
|
69
|
+
lineno = 1
|
70
|
+
yacchack = false # remove ';'-only lines.
|
71
|
+
opened = [['(not opened)', '(not opened)']] * 3
|
72
|
+
|
73
|
+
f.each do |line|
|
74
|
+
begin
|
75
|
+
case line
|
76
|
+
when /(?:\A\#@|\#@@)([a-z]+)_(begin|end)\((.*)\)/
|
77
|
+
type = check_type($1)
|
78
|
+
direction = $2
|
79
|
+
spec = check_spec($3)
|
80
|
+
case direction
|
81
|
+
when 'begin'
|
82
|
+
key = "#{type}/#{spec}"
|
83
|
+
if curr[key]
|
84
|
+
app_error "begin x2: #{key}"
|
85
|
+
end
|
86
|
+
(repo[type] ||= {})[spec] = curr[key] = []
|
87
|
+
when 'end'
|
88
|
+
curr.delete("#{type}/#{spec}") or
|
89
|
+
app_error "end before begin: #{type}/#{spec}"
|
90
|
+
else
|
91
|
+
app_error 'must not happen'
|
92
|
+
end
|
93
|
+
|
94
|
+
when %r{(?:\A\#@|\#@@)([a-z]+)/(\w+)\{}
|
95
|
+
type = check_type($1)
|
96
|
+
spec = check_spec($2)
|
97
|
+
key = "#{type}/#{spec}"
|
98
|
+
if curr[key]
|
99
|
+
app_error "begin x2: #{key}"
|
100
|
+
end
|
101
|
+
(repo[type] ||= {})[spec] = curr[key] = []
|
102
|
+
opened.push([type, spec])
|
103
|
+
|
104
|
+
when %r{(?:\A\#@|\#@@)([a-z]+)/(\w+)\}}
|
105
|
+
type = check_type($1)
|
106
|
+
spec = check_spec($2)
|
107
|
+
curr.delete("#{type}/#{spec}") or
|
108
|
+
app_error "end before begin: #{type}/#{spec}"
|
109
|
+
opened.delete("#{type}/#{spec}")
|
110
|
+
|
111
|
+
when /(?:\A\#@|\#@@)\}/
|
112
|
+
type, spec = opened.last
|
113
|
+
curr.delete("#{type}/#{spec}") or
|
114
|
+
app_error "closed before open: #{type}/#{spec}"
|
115
|
+
opened.pop
|
116
|
+
|
117
|
+
when /(?:\A\#@|\#@@)yacchack/
|
118
|
+
yacchack = true
|
119
|
+
|
120
|
+
when /\A\#@-/ # does not increment line number.
|
121
|
+
line = canonical($')
|
122
|
+
curr.each_value { |list| list.push(Line.new(nil, line)) }
|
123
|
+
|
124
|
+
else
|
125
|
+
next if yacchack && (line.strip == ';')
|
126
|
+
|
127
|
+
line = canonical(line)
|
128
|
+
curr.each_value { |list| list.push(Line.new(lineno, line)) }
|
129
|
+
lineno += 1
|
130
|
+
end
|
131
|
+
rescue ApplicationError => e
|
132
|
+
@has_errors = true
|
133
|
+
error e.message, location: location
|
134
|
+
end
|
135
|
+
end
|
136
|
+
if curr.size > 1
|
137
|
+
curr.delete('WHOLE')
|
138
|
+
curr.each { |range, lines| warn "#{@inf.path}: unclosed range: #{range} (begin @#{lines.first.number})" }
|
139
|
+
@has_errors = true
|
140
|
+
end
|
141
|
+
|
142
|
+
if @has_errors
|
143
|
+
error! 'repository failed.'
|
144
|
+
end
|
145
|
+
|
146
|
+
repo
|
147
|
+
end
|
148
|
+
|
149
|
+
def canonical(line)
|
150
|
+
if @leave_content
|
151
|
+
return line
|
152
|
+
end
|
153
|
+
|
154
|
+
tabwidth = @config['tabwidth'] || 8
|
155
|
+
if tabwidth > 0
|
156
|
+
detab(line, tabwidth).rstrip + "\n"
|
157
|
+
else
|
158
|
+
line
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def check_type(type)
|
163
|
+
app_error "wrong type: #{type.inspect}" unless Preprocessor::TYPES.index(type)
|
164
|
+
type
|
165
|
+
end
|
166
|
+
|
167
|
+
def check_spec(spec)
|
168
|
+
app_error "wrong spec: #{spec.inspect}" unless /\A\w+\z/ =~ spec
|
169
|
+
spec
|
170
|
+
end
|
171
|
+
|
172
|
+
def location
|
173
|
+
"#{@inf.path}:#{@inf.lineno}"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|