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/NEWS.md
CHANGED
|
@@ -1,3 +1,86 @@
|
|
|
1
|
+
# Version 2.4.0
|
|
2
|
+
|
|
3
|
+
## New Features
|
|
4
|
+
|
|
5
|
+
* use built-in Logger class for warns and errors ([#705])
|
|
6
|
+
* EPUBMaker: warn of large images because of rejecting ebook stores ([#819])
|
|
7
|
+
* LATEXBuilder: add new inline command `@<pageref>` ([#836])
|
|
8
|
+
* support inline notaion `| |` and `$ $` instead of `{}` to surpress escaping `}` ([#876])
|
|
9
|
+
|
|
10
|
+
## Breaking Changes
|
|
11
|
+
|
|
12
|
+
* LATEXBuilder: use Roman numerals as part numbers ([#837])
|
|
13
|
+
* EPUBMaker: TOC should be after frontmatter ([#840])
|
|
14
|
+
* `imgmath` uses folder `images/_review_math`, not `images` directly ([#856])
|
|
15
|
+
* EPUBMaker: default value of titlepage is `true`, not `null` ([#862])
|
|
16
|
+
* EPUBMaker: `params` in template files should be `config` ([#867])
|
|
17
|
+
* EWBBuilder is removed because nobody maintained it ([#828])
|
|
18
|
+
|
|
19
|
+
## Bug Fixes
|
|
20
|
+
|
|
21
|
+
* fix misrecognition of HeadlineIndex ([#121])
|
|
22
|
+
* TOPBuilder: fix metric parameter in `//image` and `//indepimage` ([#805])
|
|
23
|
+
* fix refering columns in other chapters ([#817])
|
|
24
|
+
* use execution date when `date` in config.yml is empty ([#824])
|
|
25
|
+
* fix I18N messages of `listref`, `imgref`, and `tableref` in frontmatters and backmatters ([#830])
|
|
26
|
+
* WebMaker: fix booktitle using Hash ([#831])
|
|
27
|
+
* LATEXBuilder: use lmodern package to avoid to use Type3 font in Western languages ([#843])
|
|
28
|
+
* fix broken title using `/` in config.yml ([#852])
|
|
29
|
+
* PDFMaker: fix toclevel ([#846])
|
|
30
|
+
|
|
31
|
+
## Enhancements
|
|
32
|
+
|
|
33
|
+
* allow block `{ 〜 //}` in `//indepimage`. ([#802])
|
|
34
|
+
* warn when images are not found in `//indepimage`([#803])
|
|
35
|
+
* LATEXBuilder: allow caption in `//source` ([#834])
|
|
36
|
+
|
|
37
|
+
## Docs
|
|
38
|
+
|
|
39
|
+
* add that installing LaTeX environments is needed to use `rake pdf` ([#800])
|
|
40
|
+
* fix links in README.md ([#815])
|
|
41
|
+
* add sample document to test commands of Re:VIEW ([#833])
|
|
42
|
+
* fix comment of `titlepage` in config.yml ([#847])
|
|
43
|
+
* fix description of `footnotetext` ([#872])
|
|
44
|
+
|
|
45
|
+
## Others
|
|
46
|
+
|
|
47
|
+
* fix coding rules to surpress rubocop v0.50.0 ([#823])
|
|
48
|
+
|
|
49
|
+
## Contributors
|
|
50
|
+
|
|
51
|
+
* [@ryota-murakami](https://github.com/ryota-murakami)
|
|
52
|
+
* [@nasum](https://github.com/nasum)
|
|
53
|
+
* [@kokuyouwind](https://github.com/kokuyouwind)
|
|
54
|
+
|
|
55
|
+
[#121]: https://github.com/kmuto/review/issues/121
|
|
56
|
+
[#705]: https://github.com/kmuto/review/issues/705
|
|
57
|
+
[#800]: https://github.com/kmuto/review/pull/800
|
|
58
|
+
[#802]: https://github.com/kmuto/review/issues/802
|
|
59
|
+
[#803]: https://github.com/kmuto/review/issues/803
|
|
60
|
+
[#805]: https://github.com/kmuto/review/pull/805
|
|
61
|
+
[#815]: https://github.com/kmuto/review/pull/815
|
|
62
|
+
[#817]: https://github.com/kmuto/review/pull/817
|
|
63
|
+
[#819]: https://github.com/kmuto/review/issues/819
|
|
64
|
+
[#823]: https://github.com/kmuto/review/issues/823
|
|
65
|
+
[#824]: https://github.com/kmuto/review/issues/824
|
|
66
|
+
[#828]: https://github.com/kmuto/review/pull/828
|
|
67
|
+
[#830]: https://github.com/kmuto/review/pull/830
|
|
68
|
+
[#831]: https://github.com/kmuto/review/pull/831
|
|
69
|
+
[#833]: https://github.com/kmuto/review/pull/833
|
|
70
|
+
[#834]: https://github.com/kmuto/review/issues/834
|
|
71
|
+
[#836]: https://github.com/kmuto/review/issues/836
|
|
72
|
+
[#840]: https://github.com/kmuto/review/pull/840
|
|
73
|
+
[#843]: https://github.com/kmuto/review/issues/843
|
|
74
|
+
[#837]: https://github.com/kmuto/review/issues/837
|
|
75
|
+
[#846]: https://github.com/kmuto/review/issues/846
|
|
76
|
+
[#847]: https://github.com/kmuto/review/pull/847
|
|
77
|
+
[#852]: https://github.com/kmuto/review/issues/852
|
|
78
|
+
[#856]: https://github.com/kmuto/review/issues/856
|
|
79
|
+
[#862]: https://github.com/kmuto/review/pull/862
|
|
80
|
+
[#867]: https://github.com/kmuto/review/issues/867
|
|
81
|
+
[#872]: https://github.com/kmuto/review/issues/872
|
|
82
|
+
[#876]: https://github.com/kmuto/review/issues/876
|
|
83
|
+
|
|
1
84
|
# Version 2.3.0
|
|
2
85
|
|
|
3
86
|
## New Features
|
data/README.md
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
Re:VIEW is an easy-to-use digital publishing system for paper books and ebooks.
|
|
8
8
|
|
|
9
|
-
## Supported
|
|
9
|
+
## Supported Formats
|
|
10
|
+
|
|
11
|
+

|
|
10
12
|
|
|
11
13
|
Output formats Re:VIEW supports are:
|
|
12
14
|
|
|
@@ -55,10 +57,10 @@ $ review-init hello
|
|
|
55
57
|
$ cd hello
|
|
56
58
|
$ (... add and edit *.re file, config.yml and catalog.yml ...)
|
|
57
59
|
$ rake epub ## generating EPUB
|
|
58
|
-
$ rake pdf ## generating PDF
|
|
60
|
+
$ rake pdf ## generating PDF(Requirement TeX)
|
|
59
61
|
```
|
|
60
62
|
|
|
61
|
-
For further information, see [doc/quickstart.md](https://github.com/kmuto/review/blob/
|
|
63
|
+
For further information, see [doc/quickstart.md](https://github.com/kmuto/review/blob/master/doc/quickstart.md)
|
|
62
64
|
|
|
63
65
|
## Resources
|
|
64
66
|
|
data/Rakefile
CHANGED
|
@@ -3,26 +3,26 @@ begin
|
|
|
3
3
|
Bundler::GemHelper.install_tasks
|
|
4
4
|
rescue LoadError
|
|
5
5
|
# ignore if bundler does not exist
|
|
6
|
-
warn
|
|
6
|
+
warn 'Bundler not found'
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
require 'rubygems'
|
|
10
10
|
require 'rake/clean'
|
|
11
11
|
|
|
12
|
-
task :
|
|
12
|
+
task default: %i[test rubocop]
|
|
13
13
|
|
|
14
|
-
desc
|
|
14
|
+
desc 'Check with rubocop'
|
|
15
15
|
task :rubocop do
|
|
16
16
|
begin
|
|
17
17
|
require 'rubocop/rake_task'
|
|
18
18
|
RuboCop::RakeTask.new
|
|
19
19
|
rescue LoadError
|
|
20
|
-
warn
|
|
20
|
+
warn 'rubocop not found'
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
task :test do
|
|
25
|
-
ruby(
|
|
25
|
+
ruby('test/run_test.rb')
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
begin
|
|
@@ -35,18 +35,18 @@ begin
|
|
|
35
35
|
t.verbose = true
|
|
36
36
|
end
|
|
37
37
|
rescue LoadError
|
|
38
|
-
warn
|
|
38
|
+
warn 'rcov not found'
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
begin
|
|
42
42
|
require 'rdoc/task'
|
|
43
43
|
Rake::RDocTask.new do |rdoc|
|
|
44
|
-
version = File.exist?('VERSION') ? File.read('VERSION') :
|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ''
|
|
45
45
|
rdoc.rdoc_dir = 'rdoc'
|
|
46
46
|
rdoc.title = "review #{version}"
|
|
47
47
|
rdoc.rdoc_files.include('README*')
|
|
48
48
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
49
49
|
end
|
|
50
50
|
rescue LoadError
|
|
51
|
-
warn
|
|
51
|
+
warn 'rdoc not found'
|
|
52
52
|
end
|
data/bin/review
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
2
|
#
|
|
4
3
|
# review: Wrapper command to call subcommand
|
|
5
4
|
#
|
|
@@ -35,12 +34,9 @@ command = "review-#{ARGV.shift}"
|
|
|
35
34
|
bindir = Pathname.new(__FILE__).realpath.dirname
|
|
36
35
|
command_path = File.join(bindir, command)
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
unless File.exist?(command_path)
|
|
39
38
|
print "cannot find command: #{command}\n\n"
|
|
40
39
|
usage
|
|
41
40
|
end
|
|
42
41
|
|
|
43
42
|
exec(command_path, *ARGV)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
2
|
#
|
|
4
|
-
# Copyright (c) 2014 Masanori Kado
|
|
3
|
+
# Copyright (c) 2014-2017 Masanori Kado, Kenshi Muto
|
|
5
4
|
#
|
|
6
5
|
# This program is free software.
|
|
7
6
|
# You can distribute or modify this program under the terms of
|
|
@@ -16,11 +15,13 @@ bindir = Pathname.new(__FILE__).realpath.dirname
|
|
|
16
15
|
$LOAD_PATH.unshift((bindir + '../lib').realpath)
|
|
17
16
|
require 'review/version'
|
|
18
17
|
require 'review/extentions'
|
|
18
|
+
require 'review/logger'
|
|
19
19
|
|
|
20
20
|
def main
|
|
21
|
+
@logger = ReVIEW.logger
|
|
21
22
|
opts = OptionParser.new
|
|
22
23
|
opts.version = ReVIEW::VERSION
|
|
23
|
-
opts.banner = "Usage: #{File.basename($
|
|
24
|
+
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} dirname"
|
|
24
25
|
opts.on('-h', '--help', 'print this message and quit.') do
|
|
25
26
|
puts opts.help
|
|
26
27
|
exit 0
|
|
@@ -29,7 +30,7 @@ def main
|
|
|
29
30
|
begin
|
|
30
31
|
opts.parse!
|
|
31
32
|
rescue OptionParser::ParseError => err
|
|
32
|
-
|
|
33
|
+
@logger.error err.message
|
|
33
34
|
$stderr.puts opts.help
|
|
34
35
|
exit 1
|
|
35
36
|
end
|
|
@@ -39,19 +40,19 @@ def main
|
|
|
39
40
|
# confirmation
|
|
40
41
|
if File.exist?("#{dir}/catalog.yml")
|
|
41
42
|
loop do
|
|
42
|
-
print
|
|
43
|
+
print 'The catalog.yml already exists. Do you want to overwrite it? [y/n]'
|
|
43
44
|
case gets
|
|
44
|
-
when
|
|
45
|
-
|
|
45
|
+
when /\A[yY]/
|
|
46
|
+
@logger.info 'Start writing...'
|
|
46
47
|
break
|
|
47
|
-
when
|
|
48
|
-
|
|
48
|
+
when /\A[nN]/, /\A\Z/
|
|
49
|
+
@logger.info 'bye.'
|
|
49
50
|
exit
|
|
50
51
|
end
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
File.open("#{dir}/catalog.yml",
|
|
55
|
+
File.open("#{dir}/catalog.yml", 'w') do |catalog|
|
|
55
56
|
# predef
|
|
56
57
|
if File.exist?("#{dir}/PREDEF")
|
|
57
58
|
catalog << parse_predef(File.open("#{dir}/PREDEF").read)
|
|
@@ -69,12 +70,12 @@ def main
|
|
|
69
70
|
if File.exist?("#{dir}/POSTDEF")
|
|
70
71
|
postdef = File.open("#{dir}/POSTDEF").read
|
|
71
72
|
loop do
|
|
72
|
-
print
|
|
73
|
+
print 'Do you want to convert POSTDEF into APPENDIX? [y/n]'
|
|
73
74
|
case gets
|
|
74
|
-
when
|
|
75
|
+
when /\A[yY]/
|
|
75
76
|
catalog << parse_postdef(postdef, true)
|
|
76
77
|
break
|
|
77
|
-
when
|
|
78
|
+
when /\A[nN]/, /\A\Z/
|
|
78
79
|
catalog << parse_postdef(postdef)
|
|
79
80
|
break
|
|
80
81
|
end
|
|
@@ -85,9 +86,9 @@ def main
|
|
|
85
86
|
puts File.open("#{dir}/catalog.yml").read
|
|
86
87
|
end
|
|
87
88
|
|
|
88
|
-
def
|
|
89
|
+
def parse_internal(str, header)
|
|
89
90
|
if str.present?
|
|
90
|
-
header + str.split("\n").map{|i| " - #{i}\n" }.join
|
|
91
|
+
header + str.split("\n").map { |i| " - #{i}\n" }.join
|
|
91
92
|
else
|
|
92
93
|
header
|
|
93
94
|
end
|
|
@@ -95,12 +96,12 @@ end
|
|
|
95
96
|
|
|
96
97
|
def parse_predef(str)
|
|
97
98
|
header = "PREDEF:\n"
|
|
98
|
-
|
|
99
|
+
parse_internal(str, header) + "\n"
|
|
99
100
|
end
|
|
100
101
|
|
|
101
102
|
def parse_chaps(str)
|
|
102
103
|
header = "CHAPS:\n"
|
|
103
|
-
|
|
104
|
+
parse_internal(str, header) + "\n"
|
|
104
105
|
end
|
|
105
106
|
|
|
106
107
|
def parse_postdef(str, to_appendix = false)
|
|
@@ -109,21 +110,15 @@ def parse_postdef(str, to_appendix = false)
|
|
|
109
110
|
else
|
|
110
111
|
header = "POSTDEF:\n"
|
|
111
112
|
end
|
|
112
|
-
|
|
113
|
+
parse_internal(str, header) + "\n"
|
|
113
114
|
end
|
|
114
115
|
|
|
115
116
|
def parse_parts(parts_str, chaps_str)
|
|
116
|
-
if parts_str.blank? or chaps_str.blank?
|
|
117
|
-
return "CHAPS:\n\n"
|
|
118
|
-
end
|
|
117
|
+
return "CHAPS:\n\n" if parts_str.blank? or chaps_str.blank?
|
|
119
118
|
|
|
120
119
|
parts = parts_str.split("\n")
|
|
121
120
|
chaps = chaps_str.split("\n\n")
|
|
122
|
-
"CHAPS:\n" + parts.zip(chaps).map{|k, vs|
|
|
123
|
-
" - #{k}:\n" + vs.split("\n").map{|i| " - #{i}\n"}.join
|
|
124
|
-
}.join + "\n"
|
|
121
|
+
"CHAPS:\n" + parts.zip(chaps).map { |k, vs| " - #{k}:\n" + vs.split("\n").map { |i| " - #{i}\n" }.join }.join + "\n"
|
|
125
122
|
end
|
|
126
123
|
|
|
127
|
-
if File.basename($
|
|
128
|
-
main()
|
|
129
|
-
end
|
|
124
|
+
main if File.basename($PROGRAM_NAME) == File.basename(__FILE__)
|
data/bin/review-check
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2010-2014 Kenshi Muto, Minero Aoki
|
|
3
|
+
# Copyright (c) 2010-2017 Kenshi Muto, Minero Aoki
|
|
4
|
+
# 1999-2007 Minero Aoki
|
|
6
5
|
#
|
|
7
6
|
# This program is free software.
|
|
8
7
|
# You can distribute or modify this program under the terms of
|
|
@@ -35,34 +34,32 @@ def main
|
|
|
35
34
|
@book = ReVIEW::Book::Base.load
|
|
36
35
|
@book.config = @config
|
|
37
36
|
|
|
37
|
+
@logger = ReVIEW.logger
|
|
38
|
+
|
|
38
39
|
modes = nil
|
|
39
40
|
files = ARGV unless ARGV.empty?
|
|
40
41
|
opts = OptionParser.new
|
|
41
42
|
opts.version = ReVIEW::VERSION
|
|
42
|
-
opts.on('-a', '--all-chapters', 'Check all chapters.') {
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
opts.on('-s', '--section N', 'Check section N. (deprecated)') {|n|
|
|
43
|
+
opts.on('-a', '--all-chapters', 'Check all chapters.') { files = @book.chapters.map(&:path) }
|
|
44
|
+
opts.on('-s', '--section N', 'Check section N. (deprecated)') do |n|
|
|
46
45
|
ents = @book.parts[Integer(n) - 1] or
|
|
47
|
-
|
|
48
|
-
files = ents.map
|
|
49
|
-
|
|
50
|
-
opts.on('--text', 'Check text.') {
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
opts.on('--help', 'print this message and quit.') {
|
|
46
|
+
raise ReVIEW::ApplicationError, "section #{n} not exist"
|
|
47
|
+
files = ents.map(&:path)
|
|
48
|
+
end
|
|
49
|
+
opts.on('--text', 'Check text.') { (modes ||= []).push :text }
|
|
50
|
+
opts.on('--help', 'print this message and quit.') do
|
|
54
51
|
puts opts.help
|
|
55
52
|
exit 0
|
|
56
|
-
|
|
53
|
+
end
|
|
57
54
|
begin
|
|
58
55
|
opts.parse!
|
|
59
56
|
rescue OptionParser::ParseError => err
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
@logger.error(err.message)
|
|
58
|
+
puts opts.help
|
|
62
59
|
exit 1
|
|
63
60
|
end
|
|
64
61
|
unless files
|
|
65
|
-
|
|
62
|
+
@logger.error('no input')
|
|
66
63
|
exit 1
|
|
67
64
|
end
|
|
68
65
|
modes ||= [:text]
|
|
@@ -80,31 +77,28 @@ end
|
|
|
80
77
|
def check_text(files)
|
|
81
78
|
re, neg = words_re("#{@book.basedir}/#{@book.reject_file}")
|
|
82
79
|
files.each do |path|
|
|
83
|
-
File.open(path)
|
|
80
|
+
File.open(path) do |f|
|
|
84
81
|
each_paragraph(f) do |para, lineno|
|
|
85
|
-
s = para.join
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
end
|
|
82
|
+
s = para.join
|
|
83
|
+
m = re.match(s)
|
|
84
|
+
next if m.nil? || m[0] == @review_utils_word_ok
|
|
85
|
+
next if neg and neg =~ s
|
|
86
|
+
str, offset = find_line(para, re)
|
|
87
|
+
out = sprintf("%s:%d: %s\n", path, lineno + offset, str)
|
|
88
|
+
print out
|
|
93
89
|
end
|
|
94
|
-
|
|
90
|
+
end
|
|
95
91
|
end
|
|
96
92
|
end
|
|
97
93
|
|
|
98
94
|
def find_line(lines, re)
|
|
99
95
|
# single line?
|
|
100
|
-
lines.each_with_index
|
|
101
|
-
return line.gsub(re, '<<<\&>>>'), idx if re =~ line
|
|
102
|
-
end
|
|
96
|
+
lines.each_with_index { |line, idx| return line.gsub(re, '<<<\&>>>'), idx if re =~ line }
|
|
103
97
|
|
|
104
98
|
# multiple lines?
|
|
105
99
|
i = 0
|
|
106
100
|
while i < lines.size - 1
|
|
107
|
-
str = lines[i] + lines[i+1]
|
|
101
|
+
str = lines[i] + lines[i + 1]
|
|
108
102
|
return str.gsub(re, '<<<\&>>>'), i if re =~ str
|
|
109
103
|
i += 1
|
|
110
104
|
end
|
|
@@ -116,15 +110,14 @@ def words_re(rc)
|
|
|
116
110
|
words = []
|
|
117
111
|
nega = []
|
|
118
112
|
File.foreach(rc) do |line|
|
|
119
|
-
next if line[0,1] == '#'
|
|
113
|
+
next if line[0, 1] == '#'
|
|
120
114
|
if / !/ =~ line
|
|
121
|
-
line, n = *line.split(
|
|
115
|
+
line, n = *line.split('!', 2)
|
|
122
116
|
nega.push n.strip
|
|
123
117
|
end
|
|
124
118
|
words.push line.strip
|
|
125
119
|
end
|
|
126
|
-
|
|
127
|
-
nega.empty?() ? nil : Regexp.compile(nega.join('|'))
|
|
120
|
+
[Regexp.compile(words.join('|')), nega.empty? ? nil : Regexp.compile(nega.join('|'))]
|
|
128
121
|
end
|
|
129
122
|
|
|
130
123
|
def each_paragraph(f)
|
|
@@ -135,23 +128,25 @@ def each_paragraph(f)
|
|
|
135
128
|
@review_utils_word_ok = $1
|
|
136
129
|
when /\A\#@/
|
|
137
130
|
# do nothing
|
|
138
|
-
|
|
131
|
+
next
|
|
132
|
+
when %r{\A//caption\{(.*?)//\}}
|
|
139
133
|
yield [$1], f.filename, f.lineno
|
|
140
134
|
when %r<\A//\w.*\{\s*\z>
|
|
141
135
|
while line = f.gets
|
|
142
|
-
break if %r
|
|
136
|
+
break if %r{//\}} === line
|
|
143
137
|
end
|
|
144
138
|
when /\A=/
|
|
145
139
|
yield [line.slice(/\A=+(?:\[.*?\])?\s+(.*)/, 1).strip], f.lineno
|
|
146
140
|
when /\A\s*\z/
|
|
147
141
|
# skip
|
|
142
|
+
next
|
|
148
143
|
else
|
|
149
144
|
buf = [line.strip]
|
|
150
145
|
lineno = f.lineno
|
|
151
146
|
while line = f.gets
|
|
152
147
|
break if line.strip.empty?
|
|
153
|
-
break if %r
|
|
154
|
-
next if
|
|
148
|
+
break if %r{\A(?:=|//[\w\}])} =~ line
|
|
149
|
+
next if /\A\#@/ =~ line
|
|
155
150
|
buf.push line.strip
|
|
156
151
|
end
|
|
157
152
|
yield buf, lineno
|
|
@@ -161,9 +156,7 @@ def each_paragraph(f)
|
|
|
161
156
|
end
|
|
162
157
|
|
|
163
158
|
def each_paragraph_line(f, &block)
|
|
164
|
-
each_paragraph(f)
|
|
165
|
-
para.each(&block)
|
|
166
|
-
end
|
|
159
|
+
each_paragraph(f) { |para, *| para.each(&block) }
|
|
167
160
|
end
|
|
168
161
|
|
|
169
162
|
sigmain
|