review 5.1.1 → 5.2.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/.github/workflows/ruby-tex.yml +5 -1
- data/.github/workflows/ruby-win.yml +5 -1
- data/.github/workflows/ruby.yml +5 -1
- data/.rubocop.yml +6 -2
- data/NEWS.ja.md +48 -0
- data/NEWS.md +48 -1
- data/bin/review-compile +8 -15
- data/bin/review-preproc +28 -34
- data/doc/config.yml.sample +2 -0
- data/doc/writing_vertical.ja.md +6 -0
- data/lib/review/builder.rb +34 -40
- data/lib/review/compiler.rb +59 -43
- data/lib/review/epubmaker.rb +24 -38
- data/lib/review/epubmaker/producer.rb +3 -4
- data/lib/review/exception.rb +7 -0
- data/lib/review/htmlbuilder.rb +51 -20
- data/lib/review/idgxmlbuilder.rb +19 -18
- data/lib/review/idgxmlmaker.rb +12 -13
- data/lib/review/img_math.rb +11 -18
- data/lib/review/index_builder.rb +6 -15
- data/lib/review/latexbuilder.rb +38 -43
- data/lib/review/loggable.rb +27 -0
- data/lib/review/logger.rb +48 -0
- data/lib/review/makerhelper.rb +5 -1
- data/lib/review/markdownbuilder.rb +5 -4
- data/lib/review/pdfmaker.rb +23 -21
- data/lib/review/plaintextbuilder.rb +8 -8
- data/lib/review/preprocessor.rb +94 -296
- 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/rstbuilder.rb +1 -1
- data/lib/review/template.rb +5 -1
- data/lib/review/textmaker.rb +12 -13
- data/lib/review/tocprinter.rb +1 -1
- data/lib/review/topbuilder.rb +7 -7
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +13 -14
- data/review.gemspec +1 -1
- data/samples/sample-book/src/lib/tasks/review.rake +3 -1
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
- data/templates/latex/review-jlreq/review-base.sty +3 -5
- data/templates/latex/review-jlreq/review-jlreq.cls +4 -3
- data/templates/latex/review-jsbook/review-base.sty +3 -3
- data/templates/latex/review-jsbook/review-jsbook.cls +1 -1
- data/test/test_builder.rb +8 -8
- data/test/test_epubmaker.rb +13 -8
- data/test/test_epubmaker_cmd.rb +13 -2
- data/test/test_htmlbuilder.rb +68 -26
- data/test/test_idgxmlbuilder.rb +31 -23
- data/test/test_latexbuilder.rb +30 -22
- data/test/test_latexbuilder_v2.rb +18 -10
- data/test/test_plaintextbuilder.rb +30 -22
- data/test/test_preprocessor.rb +188 -1
- data/test/test_topbuilder.rb +26 -18
- metadata +12 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 413c947f61e128331f01df2d83a039d519145016ce5757d603be616867acf594
|
|
4
|
+
data.tar.gz: 3ba0c7cb9bb87e2b8668391d60865a9ff0d1b3f1481cffa0e1670cab540fd99e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2131556e6cb7c916684b8fcdb6f1deea8a84b14dbbb5a2e62d4ad31caac832a2136d4afda25ee7c93670c56f24fd98f79090c90617e15db1cfb7ab331999b6b6
|
|
7
|
+
data.tar.gz: b929c23fa373de5780aeae97332103e19b444a57aa098ccf3f03c31716e7a46972d1213cc539d0785b76f94e2cdf5143521c3f9d446bbdb087030e357edacd7d
|
data/.github/workflows/ruby.yml
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -5,9 +5,11 @@ AllCops:
|
|
|
5
5
|
- tmp/*
|
|
6
6
|
DisplayCopNames: true
|
|
7
7
|
NewCops: enable
|
|
8
|
+
TargetRubyVersion: 2.5
|
|
8
9
|
|
|
9
10
|
require:
|
|
10
11
|
- rubocop-performance
|
|
12
|
+
- rubocop-rake
|
|
11
13
|
|
|
12
14
|
#### Lint
|
|
13
15
|
|
|
@@ -178,7 +180,7 @@ Style/GuardClause:
|
|
|
178
180
|
Enabled: false
|
|
179
181
|
|
|
180
182
|
Style/IfInsideElse:
|
|
181
|
-
Enabled:
|
|
183
|
+
Enabled: true
|
|
182
184
|
|
|
183
185
|
Style/IfUnlessModifier:
|
|
184
186
|
Enabled: false
|
|
@@ -253,6 +255,8 @@ Style/MethodCallWithArgsParentheses:
|
|
|
253
255
|
- 'write'
|
|
254
256
|
- 'warn'
|
|
255
257
|
- 'error'
|
|
258
|
+
- 'error!'
|
|
259
|
+
- 'app_error'
|
|
256
260
|
- 'raise'
|
|
257
261
|
- 'yield'
|
|
258
262
|
- 'source'
|
|
@@ -583,7 +587,7 @@ Naming/HeredocDelimiterNaming:
|
|
|
583
587
|
Enabled: false
|
|
584
588
|
|
|
585
589
|
Naming/MemoizedInstanceVariableName:
|
|
586
|
-
Enabled:
|
|
590
|
+
Enabled: true
|
|
587
591
|
|
|
588
592
|
Naming/MethodName:
|
|
589
593
|
Enabled: true
|
data/NEWS.ja.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
+
# Version 5.2.0
|
|
2
|
+
## 新機能
|
|
3
|
+
* EPUBMaker: CSS 組版向けに、見出しの存在に応じて `<section>` で階層化する機能を追加しました。config.yml で `epubmaker` セクションの `use_section` パラメータを `true` にすると有効化されます ([#1685])
|
|
4
|
+
|
|
5
|
+
## バグ修正
|
|
6
|
+
* PDFMaker: Ruby 2.6 以上でテンプレートの引数についての警告が出る問題を修正しました ([#1683])
|
|
7
|
+
* EPUBMaker: Docker 環境においてファイルがコピーされず空になる問題を修正しました ([#1686])
|
|
8
|
+
* 縦中横を正しく表示する CSS 設定を追加しました ([#1688])
|
|
9
|
+
* PDFMaker: 新しい TeXLive との組み合わせで pxjahyper のオプション競合エラーが発生するのを修正しました ([#1690])
|
|
10
|
+
* PDFMaker: 画像が見つからないときにコンパイルエラーになるのを修正しました ([#1706])
|
|
11
|
+
|
|
12
|
+
## 機能強化
|
|
13
|
+
* 警告とエラーを出力する際の処理を改善しました。`error!` (すぐに終了) および `app_error` (`ApplicationError` 例外を上げる) メソッドを導入しました ([#1674])
|
|
14
|
+
* PDFMaker: ビルドのために画像ファイルをコピーする際、実コピーではなくシンボリックリンクを利用して処理を高速化するオプションを追加しました。`pdfmaker` セクションの `use_symlink` パラメータを `true` にすると、デフォルト挙動の実コピーの代わりにシンボリックリンクが使われます。Windows など一部の OS ではこれは動作しない可能性があります ([#1696])
|
|
15
|
+
* PDFMaker: review-jlreq で `serial_pagination=true, openany` を指定したときには前付の後の空ページが入らないようにしました ([#1711])
|
|
16
|
+
|
|
17
|
+
## その他
|
|
18
|
+
* GitHub Actions まわりを修正しました ([#1684], [#1691])
|
|
19
|
+
* review-preproc: リファクタリングを行いました ([#1697])
|
|
20
|
+
* 入れ子の箇条書きの処理をリファクタリングしました ([#1698])
|
|
21
|
+
* Rubocop 1.12 に対応しました ([#1689], [#1692], [#1699], [#1700])
|
|
22
|
+
* 各ビルダの `builder_init_file` メソッドで最初に `super` で基底 builder の `builder_init_file` を実行するようにしました ([#1702])
|
|
23
|
+
* PDFMaker: FileUtils ライブラリを内部で使う際に、明示記法の `FIleUtils.foobar` を使うようにしました ([#1704])
|
|
24
|
+
|
|
25
|
+
## コントリビューターのみなさん
|
|
26
|
+
* [@odaki](https://github.com/odaki)
|
|
27
|
+
* [@imamurayusuke](https://github.com/imamurayusuke)
|
|
28
|
+
|
|
29
|
+
[#1674]: https://github.com/kmuto/review/issues/1674
|
|
30
|
+
[#1683]: https://github.com/kmuto/review/pulls/1683
|
|
31
|
+
[#1684]: https://github.com/kmuto/review/pulls/1684
|
|
32
|
+
[#1685]: https://github.com/kmuto/review/pulls/1685
|
|
33
|
+
[#1686]: https://github.com/kmuto/review/issues/1686
|
|
34
|
+
[#1688]: https://github.com/kmuto/review/pulls/1688
|
|
35
|
+
[#1689]: https://github.com/kmuto/review/pulls/1689
|
|
36
|
+
[#1690]: https://github.com/kmuto/review/pulls/1690
|
|
37
|
+
[#1691]: https://github.com/kmuto/review/pulls/1691
|
|
38
|
+
[#1692]: https://github.com/kmuto/review/pulls/1692
|
|
39
|
+
[#1696]: https://github.com/kmuto/review/issues/1696
|
|
40
|
+
[#1697]: https://github.com/kmuto/review/pulls/1697
|
|
41
|
+
[#1698]: https://github.com/kmuto/review/pulls/1698
|
|
42
|
+
[#1699]: https://github.com/kmuto/review/pulls/1699
|
|
43
|
+
[#1700]: https://github.com/kmuto/review/pulls/1700
|
|
44
|
+
[#1702]: https://github.com/kmuto/review/pulls/1702
|
|
45
|
+
[#1704]: https://github.com/kmuto/review/pulls/1704
|
|
46
|
+
[#1706]: https://github.com/kmuto/review/issues/1706
|
|
47
|
+
[#1711]: https://github.com/kmuto/review/issues/1711
|
|
48
|
+
|
|
1
49
|
# Version 5.1.1
|
|
2
50
|
## バグ修正
|
|
3
51
|
* `review-preproc` がエラーになるのを修正しました ([#1679])
|
data/NEWS.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
+
# Version 5.2.0
|
|
2
|
+
## New Features
|
|
3
|
+
* EPUBMaker: added `<section>` based on heading level for CSS formatting, when the `epubmaker/use_section` parameter is set to `true` ([#1685])
|
|
4
|
+
|
|
5
|
+
## Bug Fixes
|
|
6
|
+
* PDFMaker: fixed a problem that caused a warning in templates for Ruby 2.6 and above ([#1683])
|
|
7
|
+
* EPUBMaker: fixed an issue that caused copied files to be empty in Docker environments ([#1686])
|
|
8
|
+
* added CSS style for correct displaying horizontal characters in vertical typesetting ([#1688])
|
|
9
|
+
* PDFMaker: fixed the pxjahyper option conflict error on latest TeXLive ([#1690])
|
|
10
|
+
* PDFMaker: fixed compile error when image is not found ([#1706])
|
|
11
|
+
|
|
12
|
+
## Enhancements
|
|
13
|
+
* improve around warn and error handling ([#1674])
|
|
14
|
+
* PDFMaker: introduced `pdfmaker/use_symlink` parameter to speed up the process by using symbolic links instead of actual copies. This may not work on some operating systems such as Windows ([#1696])
|
|
15
|
+
* PDFMaker: don't insert empty page after frontmatter when using review-jlreq with `serial_pagination=true, openany` ([#1711])
|
|
16
|
+
|
|
17
|
+
## Others
|
|
18
|
+
* fixed related to GitHub Actions ([#1684], [#1691])
|
|
19
|
+
* review-preproc: refactored ([#1697])
|
|
20
|
+
* refactored nested lists handling ([#1698])
|
|
21
|
+
* refactor code with Rubocop 1.12 ([#1689], [#1692], [#1699], [#1700])
|
|
22
|
+
* The `builder_init_file` method of each builder now executes `super` first to use base builder's `builder_init_file` ([#1702])
|
|
23
|
+
* PDFMaker: Stopped implicitly including FileUtils library ([#1704])
|
|
24
|
+
|
|
25
|
+
## Contributors
|
|
26
|
+
* [@odaki](https://github.com/odaki)
|
|
27
|
+
* [@imamurayusuke](https://github.com/imamurayusuke)
|
|
28
|
+
|
|
29
|
+
[#1674]: https://github.com/kmuto/review/issues/1674
|
|
30
|
+
[#1683]: https://github.com/kmuto/review/pulls/1683
|
|
31
|
+
[#1684]: https://github.com/kmuto/review/pulls/1684
|
|
32
|
+
[#1685]: https://github.com/kmuto/review/pulls/1685
|
|
33
|
+
[#1686]: https://github.com/kmuto/review/issues/1686
|
|
34
|
+
[#1688]: https://github.com/kmuto/review/pulls/1688
|
|
35
|
+
[#1689]: https://github.com/kmuto/review/pulls/1689
|
|
36
|
+
[#1690]: https://github.com/kmuto/review/pulls/1690
|
|
37
|
+
[#1691]: https://github.com/kmuto/review/pulls/1691
|
|
38
|
+
[#1692]: https://github.com/kmuto/review/pulls/1692
|
|
39
|
+
[#1696]: https://github.com/kmuto/review/issues/1696
|
|
40
|
+
[#1697]: https://github.com/kmuto/review/pulls/1697
|
|
41
|
+
[#1698]: https://github.com/kmuto/review/pulls/1698
|
|
42
|
+
[#1699]: https://github.com/kmuto/review/pulls/1699
|
|
43
|
+
[#1700]: https://github.com/kmuto/review/pulls/1700
|
|
44
|
+
[#1702]: https://github.com/kmuto/review/pulls/1702
|
|
45
|
+
[#1704]: https://github.com/kmuto/review/pulls/1704
|
|
46
|
+
[#1706]: https://github.com/kmuto/review/issues/1706
|
|
47
|
+
[#1711]: https://github.com/kmuto/review/issues/1711
|
|
48
|
+
|
|
1
49
|
# Version 5.1.1
|
|
2
50
|
## Bug Fixes
|
|
3
51
|
* Fix the runtime error of `review-preproc` ([#1679])
|
|
@@ -1808,4 +1856,3 @@ To support language parameter for syntax highlighting, if you use review-ext.rb
|
|
|
1808
1856
|
* add headline level 5 and 6 (paragraph, subparagraph)
|
|
1809
1857
|
* escape all dash
|
|
1810
1858
|
* add ``begin{alltt}..\end{alltt}`` into ``\reviewemlist``, ``\reviewlist`` and ``\reviewcmd``
|
|
1811
|
-
|
data/bin/review-compile
CHANGED
|
@@ -16,6 +16,8 @@ require 'fileutils'
|
|
|
16
16
|
require 'optparse'
|
|
17
17
|
require 'yaml'
|
|
18
18
|
|
|
19
|
+
include ReVIEW::Loggable
|
|
20
|
+
|
|
19
21
|
DEFAULT_CONFIG_FILENAME = 'config.yml'.freeze
|
|
20
22
|
|
|
21
23
|
def main
|
|
@@ -47,17 +49,17 @@ def _main
|
|
|
47
49
|
begin
|
|
48
50
|
loader = ReVIEW::YAMLLoader.new
|
|
49
51
|
if @config['yaml']
|
|
50
|
-
error "#{@config['yaml']} not found." unless File.exist?(@config['yaml'])
|
|
52
|
+
error! "#{@config['yaml']} not found." unless File.exist?(@config['yaml'])
|
|
51
53
|
begin
|
|
52
54
|
@config.deep_merge!(loader.load_file(@config['yaml']))
|
|
53
55
|
rescue => e
|
|
54
|
-
error "yaml error #{e.message}"
|
|
56
|
+
error! "yaml error #{e.message}"
|
|
55
57
|
end
|
|
56
58
|
elsif File.exist?(DEFAULT_CONFIG_FILENAME)
|
|
57
59
|
begin
|
|
58
60
|
@config.deep_merge!(loader.load_file(DEFAULT_CONFIG_FILENAME))
|
|
59
61
|
rescue => e
|
|
60
|
-
error "yaml error #{e.message}"
|
|
62
|
+
error! "yaml error #{e.message}"
|
|
61
63
|
end
|
|
62
64
|
end
|
|
63
65
|
|
|
@@ -73,12 +75,12 @@ def _main
|
|
|
73
75
|
|
|
74
76
|
case @mode
|
|
75
77
|
when :files
|
|
76
|
-
error('no input') if ARGV.empty?
|
|
78
|
+
error!('no input') if ARGV.empty?
|
|
77
79
|
|
|
78
80
|
@basedir = File.dirname(ARGV[0])
|
|
79
81
|
book = ReVIEW::Book::Base.new(@basedir, config: @config)
|
|
80
82
|
ARGV.each do |item|
|
|
81
|
-
error("file not found: #{item}") unless File.exist?(File.join(book.config['contentdir'], item))
|
|
83
|
+
error!("file not found: #{item}") unless File.exist?(File.join(book.config['contentdir'], item))
|
|
82
84
|
chap_name = File.basename(item, '.*')
|
|
83
85
|
chap = book.chapter(chap_name)
|
|
84
86
|
compiler = ReVIEW::Compiler.new(load_builder_class(@target, @check_only))
|
|
@@ -105,7 +107,7 @@ def _main
|
|
|
105
107
|
raise "must not happen: #{@mode}"
|
|
106
108
|
end
|
|
107
109
|
rescue ReVIEW::ApplicationError => e
|
|
108
|
-
error
|
|
110
|
+
error! e.message
|
|
109
111
|
end
|
|
110
112
|
end
|
|
111
113
|
|
|
@@ -164,15 +166,6 @@ def parse_opts
|
|
|
164
166
|
end
|
|
165
167
|
end
|
|
166
168
|
|
|
167
|
-
def error(msg)
|
|
168
|
-
@logger.error msg
|
|
169
|
-
exit 1
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def warn(msg)
|
|
173
|
-
@logger.warn msg
|
|
174
|
-
end
|
|
175
|
-
|
|
176
169
|
def load_builder_class(target, strict)
|
|
177
170
|
require "review/#{target}builder"
|
|
178
171
|
ReVIEW.const_get("#{target.upcase}Builder").new(strict)
|
data/bin/review-preproc
CHANGED
|
@@ -16,9 +16,13 @@ require 'review/version'
|
|
|
16
16
|
require 'review/extentions'
|
|
17
17
|
require 'review/logger'
|
|
18
18
|
require 'review/lineinput'
|
|
19
|
+
require 'review/loggable'
|
|
19
20
|
require 'stringio'
|
|
20
21
|
require 'fileutils'
|
|
21
22
|
require 'optparse'
|
|
23
|
+
require 'tempfile'
|
|
24
|
+
|
|
25
|
+
include ReVIEW::Loggable
|
|
22
26
|
|
|
23
27
|
def sigmain
|
|
24
28
|
Signal.trap(:INT) { exit 1 }
|
|
@@ -30,16 +34,7 @@ rescue Errno::EPIPE
|
|
|
30
34
|
exit 0
|
|
31
35
|
end
|
|
32
36
|
|
|
33
|
-
def
|
|
34
|
-
@logger = ReVIEW.logger
|
|
35
|
-
if File.file?('review-preproc-ext.rb')
|
|
36
|
-
if ENV['REVIEW_SAFE_MODE'].to_i & 2 > 0
|
|
37
|
-
@logger.warn 'review-preproc-ext.rb is prohibited in safe mode. ignored.'
|
|
38
|
-
else
|
|
39
|
-
Kernel.load(File.expand_path('review-preproc-ext.rb'))
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
37
|
+
def parse_options
|
|
43
38
|
param = {}
|
|
44
39
|
|
|
45
40
|
mode = :output
|
|
@@ -57,32 +52,42 @@ def main
|
|
|
57
52
|
begin
|
|
58
53
|
opts.parse!
|
|
59
54
|
rescue OptionParser::ParseError => e
|
|
60
|
-
|
|
55
|
+
error e.message
|
|
61
56
|
$stderr.puts opts.help
|
|
62
57
|
exit 1
|
|
63
58
|
end
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
[param, mode]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def main
|
|
64
|
+
@logger = ReVIEW.logger
|
|
65
|
+
if File.file?('review-preproc-ext.rb')
|
|
66
|
+
if ENV['REVIEW_SAFE_MODE'].to_i & 2 > 0
|
|
67
|
+
warn 'review-preproc-ext.rb is prohibited in safe mode. ignored.'
|
|
68
|
+
else
|
|
69
|
+
Kernel.load(File.expand_path('review-preproc-ext.rb'))
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
param, mode = parse_options
|
|
74
|
+
pp = ReVIEW::Preprocessor.new(param)
|
|
67
75
|
ARGV.each do |path|
|
|
68
|
-
current_file = path
|
|
69
76
|
case mode
|
|
70
77
|
when :output
|
|
71
|
-
|
|
78
|
+
$stdout.write(pp.process(path))
|
|
72
79
|
when :replace
|
|
73
|
-
|
|
74
|
-
File.
|
|
80
|
+
output = pp.process(path)
|
|
81
|
+
File.write(path, output)
|
|
75
82
|
when :diff, :check
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
Tempfile.create('review.pptmp') do |tmp_io|
|
|
84
|
+
tmp = tmp_io.path
|
|
85
|
+
tmp_io.write(pp.process(path))
|
|
79
86
|
if mode == :check
|
|
80
87
|
system("diff -qu #{path} #{tmp} >/dev/null || echo #{path}")
|
|
81
88
|
else
|
|
82
89
|
system("diff -u #{path} #{tmp}")
|
|
83
90
|
end
|
|
84
|
-
ensure
|
|
85
|
-
FileUtils.rm_f(tmp)
|
|
86
91
|
end
|
|
87
92
|
else
|
|
88
93
|
raise "must not happen: #{mode}"
|
|
@@ -91,18 +96,7 @@ def main
|
|
|
91
96
|
rescue ReVIEW::Error => e
|
|
92
97
|
raise if $DEBUG
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
exit 1
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def preproc(pp, path)
|
|
99
|
-
buf = StringIO.new
|
|
100
|
-
File.open(path) { |f| pp.process(f, buf) }
|
|
101
|
-
buf.string
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def File.write(path, str)
|
|
105
|
-
File.open(path, 'w') { |f| f.write str }
|
|
99
|
+
error! e.message
|
|
106
100
|
end
|
|
107
101
|
|
|
108
102
|
sigmain
|
data/doc/config.yml.sample
CHANGED
|
@@ -341,6 +341,8 @@ epubmaker:
|
|
|
341
341
|
#
|
|
342
342
|
# 脚注に「戻る」リンクを追加する(trueで追加)。脚注の記号および戻るリンクの記号はlocale.ymlで変更可能
|
|
343
343
|
# back_footnote: null
|
|
344
|
+
# 見出しに応じて<section>で囲むようにする(trueで<section>を利用)
|
|
345
|
+
# use_section: null
|
|
344
346
|
# epubmaker:階層を使うものはここまで
|
|
345
347
|
|
|
346
348
|
# LaTeX用のスタイルファイル(styディレクトリ以下に置くこと)
|
data/doc/writing_vertical.ja.md
CHANGED
|
@@ -35,6 +35,12 @@ body {
|
|
|
35
35
|
-epub-writing-mode: vertical-rl;
|
|
36
36
|
writing-mode: tb-rl;
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
span.tcy {
|
|
40
|
+
-webkit-text-combine: horizontal;
|
|
41
|
+
-ms-text-combine-horizontal: all;
|
|
42
|
+
text-combine-upright: all;
|
|
43
|
+
}
|
|
38
44
|
```
|
|
39
45
|
|
|
40
46
|
また、縦書きの書籍は通常、「左開き」(右ページから左ページへ進む)となるので、config.yml の direction パラメータを設定します。
|
data/lib/review/builder.rb
CHANGED
|
@@ -11,6 +11,7 @@ require 'review/textutils'
|
|
|
11
11
|
require 'review/compiler'
|
|
12
12
|
require 'review/sec_counter'
|
|
13
13
|
require 'review/img_math'
|
|
14
|
+
require 'review/loggable'
|
|
14
15
|
require 'stringio'
|
|
15
16
|
require 'fileutils'
|
|
16
17
|
require 'tempfile'
|
|
@@ -19,6 +20,7 @@ require 'csv'
|
|
|
19
20
|
module ReVIEW
|
|
20
21
|
class Builder
|
|
21
22
|
include TextUtils
|
|
23
|
+
include Loggable
|
|
22
24
|
|
|
23
25
|
CAPTION_TITLES = Compiler.minicolumn_names
|
|
24
26
|
|
|
@@ -30,7 +32,8 @@ module ReVIEW
|
|
|
30
32
|
nil
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
attr_accessor :doc_status
|
|
35
|
+
attr_accessor :doc_status
|
|
36
|
+
attr_reader :location
|
|
34
37
|
|
|
35
38
|
def initialize(strict = false, *_args, img_math: nil)
|
|
36
39
|
@strict = strict
|
|
@@ -38,7 +41,6 @@ module ReVIEW
|
|
|
38
41
|
@logger = ReVIEW.logger
|
|
39
42
|
@doc_status = {}
|
|
40
43
|
@dictionary = {}
|
|
41
|
-
@previous_list_type = nil
|
|
42
44
|
@img_math = img_math
|
|
43
45
|
end
|
|
44
46
|
|
|
@@ -76,7 +78,7 @@ module ReVIEW
|
|
|
76
78
|
begin
|
|
77
79
|
require 'unicode/eaw'
|
|
78
80
|
rescue LoadError
|
|
79
|
-
warn 'not found unicode/eaw. disabled join_lines_by_lang feature.'
|
|
81
|
+
warn 'not found unicode/eaw. disabled join_lines_by_lang feature.', location: @location
|
|
80
82
|
@book.config['join_lines_by_lang'] = nil
|
|
81
83
|
end
|
|
82
84
|
end
|
|
@@ -101,7 +103,7 @@ module ReVIEW
|
|
|
101
103
|
|
|
102
104
|
def check_nest
|
|
103
105
|
if @children && !@children.empty?
|
|
104
|
-
|
|
106
|
+
app_error "//beginchild of #{@children.reverse.join(',')} misses //endchild"
|
|
105
107
|
end
|
|
106
108
|
end
|
|
107
109
|
|
|
@@ -161,7 +163,7 @@ module ReVIEW
|
|
|
161
163
|
list_body(id, lines, lang)
|
|
162
164
|
list_header(id, caption, lang) unless caption_top?('list')
|
|
163
165
|
rescue KeyError
|
|
164
|
-
|
|
166
|
+
app_error "no such list: #{id}"
|
|
165
167
|
end
|
|
166
168
|
end
|
|
167
169
|
|
|
@@ -171,7 +173,7 @@ module ReVIEW
|
|
|
171
173
|
listnum_body(lines, lang)
|
|
172
174
|
list_header(id, caption, lang) unless caption_top?('list')
|
|
173
175
|
rescue KeyError
|
|
174
|
-
|
|
176
|
+
app_error "no such list: #{id}"
|
|
175
177
|
end
|
|
176
178
|
end
|
|
177
179
|
|
|
@@ -185,7 +187,7 @@ module ReVIEW
|
|
|
185
187
|
if @chapter.image_bound?(id)
|
|
186
188
|
image_image(id, caption, metric)
|
|
187
189
|
else
|
|
188
|
-
warn "image not bound: #{id}" if @strict
|
|
190
|
+
warn "image not bound: #{id}", location: @location if @strict
|
|
189
191
|
image_dummy(id, caption, lines)
|
|
190
192
|
end
|
|
191
193
|
end
|
|
@@ -203,7 +205,7 @@ module ReVIEW
|
|
|
203
205
|
table_header(id, caption)
|
|
204
206
|
end
|
|
205
207
|
rescue KeyError
|
|
206
|
-
|
|
208
|
+
app_error "no such table: #{id}"
|
|
207
209
|
end
|
|
208
210
|
end
|
|
209
211
|
|
|
@@ -218,7 +220,7 @@ module ReVIEW
|
|
|
218
220
|
when 'verticalbar'
|
|
219
221
|
Regexp.new('\s*\\' + escape('|') + '\s*')
|
|
220
222
|
else
|
|
221
|
-
|
|
223
|
+
app_error "Unknown value for 'table_row_separator', shold be: tabs, singletab, spaces, verticalbar"
|
|
222
224
|
end
|
|
223
225
|
end
|
|
224
226
|
|
|
@@ -233,7 +235,7 @@ module ReVIEW
|
|
|
233
235
|
rows.push(line.strip.split(table_row_separator_regexp).map { |s| s.sub(/\A\./, '') })
|
|
234
236
|
end
|
|
235
237
|
rows = adjust_n_cols(rows)
|
|
236
|
-
|
|
238
|
+
app_error 'no rows in the table' if rows.empty?
|
|
237
239
|
[sepidx, rows]
|
|
238
240
|
end
|
|
239
241
|
|
|
@@ -294,19 +296,19 @@ module ReVIEW
|
|
|
294
296
|
def inline_chapref(id)
|
|
295
297
|
compile_inline(@book.chapter_index.display_string(id))
|
|
296
298
|
rescue KeyError
|
|
297
|
-
|
|
299
|
+
app_error "unknown chapter: #{id}"
|
|
298
300
|
end
|
|
299
301
|
|
|
300
302
|
def inline_chap(id)
|
|
301
303
|
@book.chapter_index.number(id)
|
|
302
304
|
rescue KeyError
|
|
303
|
-
|
|
305
|
+
app_error "unknown chapter: #{id}"
|
|
304
306
|
end
|
|
305
307
|
|
|
306
308
|
def inline_title(id)
|
|
307
309
|
compile_inline(@book.chapter_index.title(id))
|
|
308
310
|
rescue KeyError
|
|
309
|
-
|
|
311
|
+
app_error "unknown chapter: #{id}"
|
|
310
312
|
end
|
|
311
313
|
|
|
312
314
|
def inline_list(id)
|
|
@@ -317,7 +319,7 @@ module ReVIEW
|
|
|
317
319
|
%Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [chapter.list(id).number])})
|
|
318
320
|
end
|
|
319
321
|
rescue KeyError
|
|
320
|
-
|
|
322
|
+
app_error "unknown list: #{id}"
|
|
321
323
|
end
|
|
322
324
|
|
|
323
325
|
def inline_img(id)
|
|
@@ -328,7 +330,7 @@ module ReVIEW
|
|
|
328
330
|
%Q(#{I18n.t('image')}#{I18n.t('format_number_without_chapter', [chapter.image(id).number])})
|
|
329
331
|
end
|
|
330
332
|
rescue KeyError
|
|
331
|
-
|
|
333
|
+
app_error "unknown image: #{id}"
|
|
332
334
|
end
|
|
333
335
|
|
|
334
336
|
def inline_imgref(id)
|
|
@@ -349,7 +351,7 @@ module ReVIEW
|
|
|
349
351
|
%Q(#{I18n.t('table')}#{I18n.t('format_number_without_chapter', [chapter.table(id).number])})
|
|
350
352
|
end
|
|
351
353
|
rescue KeyError
|
|
352
|
-
|
|
354
|
+
app_error "unknown table: #{id}"
|
|
353
355
|
end
|
|
354
356
|
|
|
355
357
|
def inline_eq(id)
|
|
@@ -360,13 +362,13 @@ module ReVIEW
|
|
|
360
362
|
%Q(#{I18n.t('equation')}#{I18n.t('format_number_without_chapter', [chapter.equation(id).number])})
|
|
361
363
|
end
|
|
362
364
|
rescue KeyError
|
|
363
|
-
|
|
365
|
+
app_error "unknown equation: #{id}"
|
|
364
366
|
end
|
|
365
367
|
|
|
366
368
|
def inline_fn(id)
|
|
367
369
|
@chapter.footnote(id).content
|
|
368
370
|
rescue KeyError
|
|
369
|
-
|
|
371
|
+
app_error "unknown footnote: #{id}"
|
|
370
372
|
end
|
|
371
373
|
|
|
372
374
|
def inline_bou(str)
|
|
@@ -422,7 +424,7 @@ module ReVIEW
|
|
|
422
424
|
inline_hd_chap(@chapter, id)
|
|
423
425
|
end
|
|
424
426
|
rescue KeyError
|
|
425
|
-
|
|
427
|
+
app_error "unknown headline: #{id}"
|
|
426
428
|
end
|
|
427
429
|
|
|
428
430
|
def inline_column(id)
|
|
@@ -436,7 +438,7 @@ module ReVIEW
|
|
|
436
438
|
inline_column_chap(@chapter, id)
|
|
437
439
|
end
|
|
438
440
|
rescue KeyError
|
|
439
|
-
|
|
441
|
+
app_error "unknown column: #{id}"
|
|
440
442
|
end
|
|
441
443
|
|
|
442
444
|
def inline_column_chap(chapter, id)
|
|
@@ -460,7 +462,7 @@ module ReVIEW
|
|
|
460
462
|
if translated
|
|
461
463
|
escape(translated)
|
|
462
464
|
else
|
|
463
|
-
warn "word not bound: #{s}"
|
|
465
|
+
warn "word not bound: #{s}", location: @location
|
|
464
466
|
escape("[missing word: #{s}]")
|
|
465
467
|
end
|
|
466
468
|
end
|
|
@@ -496,18 +498,6 @@ module ReVIEW
|
|
|
496
498
|
end
|
|
497
499
|
end
|
|
498
500
|
|
|
499
|
-
def warn(msg)
|
|
500
|
-
@logger.warn "#{@location}: #{msg}"
|
|
501
|
-
end
|
|
502
|
-
|
|
503
|
-
def error(msg)
|
|
504
|
-
if msg =~ /:\d+: error: /
|
|
505
|
-
raise ApplicationError, msg
|
|
506
|
-
else
|
|
507
|
-
raise ApplicationError, "#{@location}: error: #{msg}"
|
|
508
|
-
end
|
|
509
|
-
end
|
|
510
|
-
|
|
511
501
|
def handle_metric(str)
|
|
512
502
|
str
|
|
513
503
|
end
|
|
@@ -582,7 +572,7 @@ module ReVIEW
|
|
|
582
572
|
|
|
583
573
|
def check_nested_minicolumn
|
|
584
574
|
if @doc_status[:minicolumn]
|
|
585
|
-
|
|
575
|
+
app_error "#{@location}: nested mini-column is not allowed"
|
|
586
576
|
end
|
|
587
577
|
end
|
|
588
578
|
|
|
@@ -732,18 +722,22 @@ EOTGNUPLOT
|
|
|
732
722
|
str
|
|
733
723
|
end
|
|
734
724
|
|
|
725
|
+
def previous_list_type
|
|
726
|
+
@compiler.previous_list_type
|
|
727
|
+
end
|
|
728
|
+
|
|
735
729
|
def beginchild
|
|
736
730
|
@children ||= []
|
|
737
|
-
unless
|
|
738
|
-
|
|
731
|
+
unless previous_list_type
|
|
732
|
+
app_error "//beginchild is shown, but previous element isn't ul, ol, or dl"
|
|
739
733
|
end
|
|
740
|
-
puts "\x01→#{
|
|
741
|
-
@children.push(
|
|
734
|
+
puts "\x01→#{previous_list_type}←\x01"
|
|
735
|
+
@children.push(previous_list_type)
|
|
742
736
|
end
|
|
743
737
|
|
|
744
738
|
def endchild
|
|
745
739
|
if @children.nil? || @children.empty?
|
|
746
|
-
|
|
740
|
+
app_error "//endchild is shown, but any opened //beginchild doesn't exist"
|
|
747
741
|
else
|
|
748
742
|
puts "\x01→/#{@children.pop}←\x01"
|
|
749
743
|
end
|
|
@@ -751,7 +745,7 @@ EOTGNUPLOT
|
|
|
751
745
|
|
|
752
746
|
def caption_top?(type)
|
|
753
747
|
unless %w[top bottom].include?(@book.config['caption_position'][type])
|
|
754
|
-
warn
|
|
748
|
+
warn "invalid caption_position/#{type} parameter. 'top' is assumed", location: @location
|
|
755
749
|
end
|
|
756
750
|
@book.config['caption_position'][type] != 'bottom'
|
|
757
751
|
end
|