review-retrovert 0.9.2 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/retrovert.yml +32 -10
- data/Dockerfile +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +57 -58
- data/README.md +75 -3
- data/lib/review/retrovert/cli.rb +4 -2
- data/lib/review/retrovert/converter.rb +168 -41
- data/lib/review/retrovert/ext/review-ext.rb +71 -0
- data/lib/review/retrovert/sty/ird.sty +318 -0
- data/lib/review/retrovert/version.rb +1 -1
- data/lib/review/retrovert/yamlconfig.rb +33 -2
- data/review-retrovert.gemspec +1 -1
- data/testdata/mybook/catalog.yml +1 -0
- data/testdata/mybook/config-retrovert.yml +7 -0
- data/testdata/mybook/config.yml +1 -1
- data/testdata/mybook/contents/r0-inner.re +2 -0
- data/testdata/mybook/contents/r0-root.re +9 -0
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d85946bda0b18fbe3dddfbd6f37ef15a2e2c6892376a1e91245c8d0a98053399
|
4
|
+
data.tar.gz: a0f7697228f0bf308bb091fb5d7d0ee279d2dbdbdf7fff4580f5ccf6298ad0b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7faaa36fd24484680cd909eeab26a46ab67e7085a59807e0d3d725586422df13be6f0a0d7942bec592bb2e89bef3b1e3faad659e7484c4991b00737864578960
|
7
|
+
data.tar.gz: 80ff4eea7e4b43cb20486fb87cf9dd6431b0e4766d58fbc24680cdff254bb28e265ce1d3552deef4167d11247b958d2df9caf1a4df9e8b0a294a14d2efc81afa
|
@@ -8,12 +8,22 @@ name: Retrovert
|
|
8
8
|
jobs:
|
9
9
|
review:
|
10
10
|
runs-on: ubuntu-latest
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
review-version: [ "3.2", "4.2", "5.0" ]
|
14
|
+
fail-fast: false
|
11
15
|
steps:
|
12
16
|
- uses: actions/checkout@v2
|
13
17
|
- uses: ruby/setup-ruby@v1
|
14
18
|
with:
|
15
19
|
ruby-version: 2.6
|
16
|
-
- run:
|
20
|
+
- run: |
|
21
|
+
rm -f Gemfile.lock
|
22
|
+
cp Gemfile Gemfile-${{ matrix.review-version }}
|
23
|
+
echo 'gem "review", "${{ matrix.review-version }}"' >> Gemfile-${{ matrix.review-version }}
|
24
|
+
cat Gemfile-${{ matrix.review-version }}
|
25
|
+
echo "BUNDLE_GEMFILE=Gemfile-${{ matrix.review-version }}" >> $GITHUB_ENV
|
26
|
+
- run: bundle install --gemfile=Gemfile-${{ matrix.review-version }}
|
17
27
|
# spec
|
18
28
|
- name: spec
|
19
29
|
run: bundle exec rake spec
|
@@ -21,19 +31,31 @@ jobs:
|
|
21
31
|
- name: convert
|
22
32
|
run: bundle exec review-retrovert convert testdata/mybook/config.yml tmp -f
|
23
33
|
# build
|
24
|
-
- name: review build
|
25
|
-
|
34
|
+
# - name: review build
|
35
|
+
# uses: ${{ matrix.uses }}
|
36
|
+
# with:
|
37
|
+
# entrypoint: bash
|
38
|
+
# args: -c "cd tmp; rake preproc all"
|
39
|
+
# docker login
|
40
|
+
- name: Login to DockerHub
|
41
|
+
uses: docker/login-action@v1
|
26
42
|
with:
|
27
|
-
|
28
|
-
|
43
|
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
44
|
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
45
|
+
- name: build html
|
46
|
+
run: |
|
47
|
+
docker run --rm -v "$(pwd)/tmp":/work -w /work vvakame/review:${{ matrix.review-version }} rake preproc html
|
48
|
+
- name: build pdf
|
49
|
+
run: |
|
50
|
+
docker run --rm -v "$(pwd)/tmp":/work -w /work vvakame/review:${{ matrix.review-version }} rake preproc pdf
|
29
51
|
# artifacts
|
30
52
|
- name: artifacts
|
31
53
|
uses: actions/upload-artifact@v1
|
32
54
|
with:
|
33
55
|
name: mybook
|
34
56
|
path: tmp/mybook.pdf
|
35
|
-
- name: artifacts
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
57
|
+
# - name: artifacts
|
58
|
+
# uses: actions/upload-artifact@v1
|
59
|
+
# with:
|
60
|
+
# name: mybook
|
61
|
+
# path: tmp/mybook.epub
|
data/Dockerfile
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,68 +1,67 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
review-retrovert (0.9.
|
5
|
-
review (>= 3.
|
4
|
+
review-retrovert (0.9.7)
|
5
|
+
review (>= 3.0.0)
|
6
6
|
thor
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (6.
|
11
|
+
activesupport (6.1.1)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
-
i18n (>=
|
14
|
-
minitest (
|
15
|
-
tzinfo (~>
|
16
|
-
zeitwerk (~> 2.
|
17
|
-
aruba (1.0.
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
aruba (1.0.4)
|
18
18
|
childprocess (>= 2.0, < 5.0)
|
19
19
|
contracts (~> 0.16.0)
|
20
|
-
cucumber (>= 2.4, <
|
21
|
-
ffi (~> 1.9)
|
20
|
+
cucumber (>= 2.4, < 6.0)
|
22
21
|
rspec-expectations (~> 3.4)
|
23
22
|
thor (~> 1.0)
|
24
23
|
builder (3.2.4)
|
25
24
|
childprocess (4.0.0)
|
26
|
-
concurrent-ruby (1.1.
|
25
|
+
concurrent-ruby (1.1.7)
|
27
26
|
contracts (0.16.0)
|
28
|
-
cucumber (
|
29
|
-
builder (~> 3.2, >= 3.2.
|
30
|
-
cucumber-core (~>
|
31
|
-
cucumber-create-meta (~>
|
32
|
-
cucumber-cucumber-expressions (~> 10.
|
33
|
-
cucumber-gherkin (~>
|
34
|
-
cucumber-html-formatter (~>
|
35
|
-
cucumber-messages (~>
|
36
|
-
cucumber-wire (~>
|
37
|
-
diff-lcs (~> 1.
|
27
|
+
cucumber (5.2.0)
|
28
|
+
builder (~> 3.2, >= 3.2.4)
|
29
|
+
cucumber-core (~> 8.0, >= 8.0.1)
|
30
|
+
cucumber-create-meta (~> 2.0, >= 2.0.2)
|
31
|
+
cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
|
32
|
+
cucumber-gherkin (~> 15.0, >= 15.0.2)
|
33
|
+
cucumber-html-formatter (~> 9.0, >= 9.0.0)
|
34
|
+
cucumber-messages (~> 13.1, >= 13.1.0)
|
35
|
+
cucumber-wire (~> 4.0, >= 4.0.1)
|
36
|
+
diff-lcs (~> 1.4, >= 1.4.4)
|
38
37
|
multi_test (~> 0.1, >= 0.1.2)
|
39
|
-
sys-uname (~> 1.
|
40
|
-
cucumber-core (
|
41
|
-
cucumber-gherkin (~>
|
42
|
-
cucumber-messages (~>
|
38
|
+
sys-uname (~> 1.2, >= 1.2.1)
|
39
|
+
cucumber-core (8.0.1)
|
40
|
+
cucumber-gherkin (~> 15.0, >= 15.0.2)
|
41
|
+
cucumber-messages (~> 13.0, >= 13.0.1)
|
43
42
|
cucumber-tag-expressions (~> 2.0, >= 2.0.4)
|
44
|
-
cucumber-create-meta (
|
45
|
-
cucumber-messages (~>
|
43
|
+
cucumber-create-meta (2.0.4)
|
44
|
+
cucumber-messages (~> 13.1, >= 13.1.0)
|
46
45
|
sys-uname (~> 1.2, >= 1.2.1)
|
47
|
-
cucumber-cucumber-expressions (10.
|
48
|
-
cucumber-gherkin (
|
49
|
-
cucumber-messages (~>
|
50
|
-
cucumber-html-formatter (
|
51
|
-
cucumber-messages (~>
|
52
|
-
cucumber-messages (
|
46
|
+
cucumber-cucumber-expressions (10.3.0)
|
47
|
+
cucumber-gherkin (15.0.2)
|
48
|
+
cucumber-messages (~> 13.0, >= 13.0.1)
|
49
|
+
cucumber-html-formatter (9.0.0)
|
50
|
+
cucumber-messages (~> 13.0, >= 13.0.1)
|
51
|
+
cucumber-messages (13.2.1)
|
53
52
|
protobuf-cucumber (~> 3.10, >= 3.10.8)
|
54
53
|
cucumber-tag-expressions (2.0.4)
|
55
|
-
cucumber-wire (
|
56
|
-
cucumber-core (~>
|
57
|
-
cucumber-cucumber-expressions (~> 10.
|
58
|
-
cucumber-messages (~>
|
59
|
-
diff-lcs (1.
|
60
|
-
ffi (1.
|
61
|
-
i18n (1.8.
|
54
|
+
cucumber-wire (4.0.1)
|
55
|
+
cucumber-core (~> 8.0, >= 8.0.1)
|
56
|
+
cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
|
57
|
+
cucumber-messages (~> 13.0, >= 13.0.1)
|
58
|
+
diff-lcs (1.4.4)
|
59
|
+
ffi (1.14.2)
|
60
|
+
i18n (1.8.7)
|
62
61
|
concurrent-ruby (~> 1.0)
|
63
62
|
image_size (2.1.0)
|
64
63
|
middleware (0.1.0)
|
65
|
-
minitest (5.14.
|
64
|
+
minitest (5.14.3)
|
66
65
|
multi_test (0.1.2)
|
67
66
|
protobuf-cucumber (3.10.8)
|
68
67
|
activesupport (>= 3.2)
|
@@ -70,32 +69,32 @@ GEM
|
|
70
69
|
thor
|
71
70
|
thread_safe
|
72
71
|
rake (12.3.3)
|
73
|
-
review (
|
72
|
+
review (5.0.0)
|
74
73
|
image_size
|
75
74
|
rouge
|
76
75
|
rubyzip
|
77
76
|
rouge (3.26.0)
|
78
|
-
rspec (3.
|
79
|
-
rspec-core (~> 3.
|
80
|
-
rspec-expectations (~> 3.
|
81
|
-
rspec-mocks (~> 3.
|
82
|
-
rspec-core (3.
|
83
|
-
rspec-support (~> 3.
|
84
|
-
rspec-expectations (3.
|
77
|
+
rspec (3.10.0)
|
78
|
+
rspec-core (~> 3.10.0)
|
79
|
+
rspec-expectations (~> 3.10.0)
|
80
|
+
rspec-mocks (~> 3.10.0)
|
81
|
+
rspec-core (3.10.1)
|
82
|
+
rspec-support (~> 3.10.0)
|
83
|
+
rspec-expectations (3.10.1)
|
85
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
86
|
-
rspec-support (~> 3.
|
87
|
-
rspec-mocks (3.
|
85
|
+
rspec-support (~> 3.10.0)
|
86
|
+
rspec-mocks (3.10.1)
|
88
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
89
|
-
rspec-support (~> 3.
|
90
|
-
rspec-support (3.
|
88
|
+
rspec-support (~> 3.10.0)
|
89
|
+
rspec-support (3.10.1)
|
91
90
|
rubyzip (2.3.0)
|
92
|
-
sys-uname (1.2.
|
93
|
-
ffi (
|
91
|
+
sys-uname (1.2.2)
|
92
|
+
ffi (~> 1.1)
|
94
93
|
thor (1.0.1)
|
95
94
|
thread_safe (0.3.6)
|
96
|
-
tzinfo (
|
97
|
-
|
98
|
-
zeitwerk (2.4.
|
95
|
+
tzinfo (2.0.4)
|
96
|
+
concurrent-ruby (~> 1.0)
|
97
|
+
zeitwerk (2.4.2)
|
99
98
|
|
100
99
|
PLATFORMS
|
101
100
|
ruby
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# ReVIEW::Retrovert
|
6
6
|
|
7
|
-
[Re:VIEW Starter](https://kauplan.org/reviewstarter/) Project convert to [Re:VIEW](https://reviewml.org/ja/) 3.X
|
7
|
+
[Re:VIEW Starter](https://kauplan.org/reviewstarter/) Project convert to [Re:VIEW](https://reviewml.org/ja/) 3.X/4.X/5.X
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -21,13 +21,85 @@ And then execute:
|
|
21
21
|
Or install it yourself as:
|
22
22
|
|
23
23
|
$ gem install review-retrovert
|
24
|
+
|
25
|
+
## Use Docker
|
24
26
|
|
25
|
-
|
27
|
+
```
|
28
|
+
docker run -v "$(pwd):/work" -w /work srzzumix/review-retrovert convert target/config.yml outdir
|
29
|
+
```
|
30
|
+
|
31
|
+
## Commands
|
32
|
+
|
33
|
+
```sh
|
34
|
+
Commands:
|
35
|
+
review-retrovert convert {review_starter_configfile} {outdir} # convert Re:VIEW Starter project to Re:VIEW project
|
36
|
+
review-retrovert help [COMMAND] # Describe available commands or one specific command
|
37
|
+
review-retrovert version # show version
|
38
|
+
```
|
39
|
+
|
40
|
+
### Convert
|
41
|
+
|
42
|
+
#### e.g.
|
26
43
|
|
27
44
|
```sh
|
28
45
|
review-retrovert convert /path/to/dir/review-starter/config.yml <output directory>
|
29
46
|
```
|
30
47
|
|
48
|
+
#### Options
|
49
|
+
|
50
|
+
```sh
|
51
|
+
sage:
|
52
|
+
review-retrovert convert {review_starter_configfile} {outdir}
|
53
|
+
|
54
|
+
Options:
|
55
|
+
f, [--force] # Force output
|
56
|
+
[--strict], [--no-strict] # Only process files registered in the catalog
|
57
|
+
[--preproc], [--no-preproc] # Execute preproc after conversion
|
58
|
+
[--tabwidth=N] # Preproc tabwidth option value
|
59
|
+
# Default: 0
|
60
|
+
[--table-br-replace=TABLE-BR-REPLACE] # @<br>{} in table replace string (Default: empty)
|
61
|
+
[--table-empty-replace=TABLE-EMPTY-REPLACE] # empty cell(.) in table replace string (Default full-width space)
|
62
|
+
# Default:
|
63
|
+
[--ird], [--no-ird] # for IRD
|
64
|
+
[--no-image] # donot copy image
|
65
|
+
|
66
|
+
convert Re:VIEW Starter project to Re:VIEW project
|
67
|
+
```
|
68
|
+
|
69
|
+
#### retrovert config
|
70
|
+
|
71
|
+
If the retrovert key is present in config.yml, the subordinate elements will take effect after convert.
|
72
|
+
|
73
|
+
If you have a setting that you want to enable only after retrovert, use inherit as shown below.
|
74
|
+
|
75
|
+
* config-retrovert.yml
|
76
|
+
|
77
|
+
```yml
|
78
|
+
retrovert:
|
79
|
+
chapterlink: null
|
80
|
+
```
|
81
|
+
|
82
|
+
* config-base.yml
|
83
|
+
|
84
|
+
```yml
|
85
|
+
chapterlink: true
|
86
|
+
```
|
87
|
+
|
88
|
+
* config.yml
|
89
|
+
|
90
|
+
```yml
|
91
|
+
inherit: ["config-base.yml", "config-starter.yml", "config-retrovert.yml"]
|
92
|
+
|
93
|
+
#chapterlink: true
|
94
|
+
```
|
95
|
+
|
96
|
+
## Experimental
|
97
|
+
|
98
|
+
### IRD sty
|
99
|
+
|
100
|
+
--ird オプションを付けると IRD 組版に近いレイアウトにするために ird.sty と reveiw-ext.rb をプロジェクトに追加します。
|
101
|
+
こちらは実験的機能です。
|
102
|
+
|
31
103
|
## Development
|
32
104
|
|
33
105
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -40,7 +112,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/srz-zu
|
|
40
112
|
|
41
113
|
## Develop
|
42
114
|
|
43
|
-
docker run -it --rm -v $(pwd)/:/work -w /work vvakame/review:
|
115
|
+
docker run -it --rm -v $(pwd)/:/work -w /work vvakame/review:5.0 bash
|
44
116
|
|
45
117
|
## License
|
46
118
|
|
data/lib/review/retrovert/cli.rb
CHANGED
@@ -9,8 +9,10 @@ module ReVIEW
|
|
9
9
|
method_option "strict", desc: 'Only process files registered in the catalog', type: :boolean
|
10
10
|
method_option "preproc", desc: 'Execute preproc after conversion', type: :boolean
|
11
11
|
method_option "tabwidth", desc: 'Preproc tabwidth option value', type: :numeric, default: 0
|
12
|
-
method_option "table-br-replace", desc: '@<br>{} in table replace string', type: :string, default: ''
|
13
|
-
method_option "table-empty-replace", desc: 'empty cell(.) in table replace string', type: :string, default: ' '
|
12
|
+
method_option "table-br-replace", desc: '@<br>{} in table replace string (Default: empty)', type: :string, default: ''
|
13
|
+
method_option "table-empty-replace", desc: 'empty cell(.) in table replace string (Default full-width space)', type: :string, default: ' '
|
14
|
+
method_option "ird", desc: 'for IRD', type: :boolean
|
15
|
+
method_option "no-image", desc: 'donot copy image', type: :boolean
|
14
16
|
def convert(review_starter_configfile, outdir)
|
15
17
|
Converter.execute(review_starter_configfile, outdir, options)
|
16
18
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "review"
|
2
2
|
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
3
4
|
require "review/retrovert/yamlconfig"
|
4
5
|
|
5
6
|
module ReVIEW
|
@@ -13,6 +14,9 @@ module ReVIEW
|
|
13
14
|
@outimagedir = nil
|
14
15
|
@logger = ReVIEW.logger
|
15
16
|
@configs = YamlConfig.new
|
17
|
+
@embeded_contents = []
|
18
|
+
@catalog_contents = []
|
19
|
+
@ird = false
|
16
20
|
end
|
17
21
|
|
18
22
|
def error(msg)
|
@@ -45,21 +49,50 @@ module ReVIEW
|
|
45
49
|
FileUtils.cp_r(Dir.glob(File.join(path, '*.re')), outdir)
|
46
50
|
end
|
47
51
|
|
48
|
-
def
|
52
|
+
def get_out_imagedir(outdir)
|
49
53
|
imagedir = @config['imagedir']
|
50
|
-
srcpath = File.join(@basedir, imagedir)
|
51
54
|
outimagedir = File.basename(imagedir) # Re:VIEW not support sub-directory
|
52
55
|
outpath = File.join(outdir, outimagedir)
|
56
|
+
return outpath
|
57
|
+
end
|
58
|
+
|
59
|
+
def store_out_image(outdir)
|
60
|
+
outpath = get_out_imagedir(outdir)
|
61
|
+
if File.exist?(outpath)
|
62
|
+
dir = Dir.mktmpdir('review-retrovert')
|
63
|
+
FileUtils.mv(Dir.glob(File.join(outpath, "**/*")), dir)
|
64
|
+
return dir
|
65
|
+
end
|
66
|
+
return nil
|
67
|
+
end
|
68
|
+
|
69
|
+
def restore_out_image(outpath, tmpdir)
|
70
|
+
if File.exist?(tmpdir)
|
71
|
+
FileUtils.mkdir_p(outpath)
|
72
|
+
FileUtils.mv(Dir.glob(File.join(tmpdir, "**/*")), outpath)
|
73
|
+
FileUtils.rm_rf(tmpdir)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def copy_images(outdir, store_image_dir)
|
78
|
+
imagedir = @config['imagedir']
|
79
|
+
outimagedir = File.basename(imagedir) # Re:VIEW not support sub-directory
|
80
|
+
outpath = get_out_imagedir(outdir)
|
53
81
|
FileUtils.mkdir_p(outpath)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
82
|
+
if store_image_dir
|
83
|
+
restore_out_image(outpath, store_image_dir)
|
84
|
+
else
|
85
|
+
srcpath = File.join(@basedir, imagedir)
|
86
|
+
image_ext = @config['image_ext']
|
87
|
+
srcroot = Pathname.new(srcpath)
|
88
|
+
image_ext.each { |ext|
|
89
|
+
Dir.glob(File.join(srcpath, "**/*.#{ext}")).each { |srcimg|
|
90
|
+
outimg = File.join(outpath, Pathname.new(srcimg).relative_path_from(srcroot))
|
91
|
+
FileUtils.makedirs(File.dirname(outimg))
|
92
|
+
FileUtils.cp(srcimg, outimg)
|
93
|
+
}
|
61
94
|
}
|
62
|
-
|
95
|
+
end
|
63
96
|
@configs.rewrite_yml('imagedir', outimagedir)
|
64
97
|
end
|
65
98
|
|
@@ -67,6 +100,22 @@ module ReVIEW
|
|
67
100
|
@configs.rewrite_yml('contentdir', '.')
|
68
101
|
@configs.rewrite_yml('hook_beforetexcompile', 'null')
|
69
102
|
@configs.rewrite_yml('texstyle', '["reviewmacro"]')
|
103
|
+
pagesize = @config['starter']['pagesize'].downcase
|
104
|
+
jsbook_config = "media=print,paper=#{pagesize}"
|
105
|
+
if @ird
|
106
|
+
# # リュウミン Pr6N R-KL 12.5Q 22H (9pt = 12.7Q 15.5pt = 21.8Q(H))
|
107
|
+
# texdocumentclass: ["review-jsbook", "media=ebook,openany,paper=b5,fontsize=9pt,baselineskip=15.5pt,head_space=15mm,gutter=22mm,footskip=16mm,line_length=45zw,number_of_lines=38"]
|
108
|
+
jsbook_config = "media=ebook,openany,paper=b5,fontsize=9pt,baselineskip=15.5pt,head_space=15mm,gutter=22mm,footskip=16mm,line_length=45zw,number_of_lines=38"
|
109
|
+
end
|
110
|
+
@configs.rewrite_yml_array('texdocumentclass', "[\"review-jsbook\", \"#{jsbook_config}\"]")
|
111
|
+
@config['retrovert'].each{ |k,v|
|
112
|
+
unless v..is_a?(Hash)
|
113
|
+
@configs.commentout_root_yml(k)
|
114
|
+
end
|
115
|
+
}
|
116
|
+
if @ird
|
117
|
+
@configs.rewrite_yml('chapterlink', 'null')
|
118
|
+
end
|
70
119
|
end
|
71
120
|
|
72
121
|
def replace_compatible_block_command_outline(content, command, new_command, option_count)
|
@@ -173,17 +222,29 @@ module ReVIEW
|
|
173
222
|
end
|
174
223
|
|
175
224
|
def replace_block_command_nested_boxed_articles(content)
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
225
|
+
unless Gem::Version.new(ReVIEW::VERSION) >= Gem::Version.new('5.0.0')
|
226
|
+
replace_block_command_nested_boxed_article(content, 'note')
|
227
|
+
replace_block_command_nested_boxed_article(content, 'memo')
|
228
|
+
replace_block_command_nested_boxed_article(content, 'tip')
|
229
|
+
replace_block_command_nested_boxed_article(content, 'info')
|
230
|
+
replace_block_command_nested_boxed_article(content, 'warning')
|
231
|
+
replace_block_command_nested_boxed_article(content, 'important')
|
232
|
+
replace_block_command_nested_boxed_article(content, 'caution')
|
233
|
+
replace_block_command_nested_boxed_article(content, 'notice')
|
234
|
+
end
|
184
235
|
end
|
185
236
|
|
186
237
|
def replace_block_commentout(content)
|
238
|
+
d = content.dup
|
239
|
+
d.scan(/(^#@)(\++)(.*?)(^#@)(-+)/m) { |m|
|
240
|
+
matched = m[0..-1].join
|
241
|
+
inner = m[2]
|
242
|
+
inner.gsub!(/(^.)/, '#@#\1')
|
243
|
+
content.gsub!(/#{Regexp.escape(matched)}/m, "#@##{m[1]}#{inner}#@##{m[4]}")
|
244
|
+
}
|
245
|
+
end
|
246
|
+
|
247
|
+
def replace_block_commentout_without_sampleout(content)
|
187
248
|
d = content.dup
|
188
249
|
d.gsub!(/(^\/\/sampleoutputbegin\[)(.*?)(\])(.*?)(^\/\/sampleoutputend)/m, '')
|
189
250
|
d.scan(/(^#@)(\++)(.*?)(^#@)(-+)/m) { |m|
|
@@ -195,7 +256,7 @@ module ReVIEW
|
|
195
256
|
end
|
196
257
|
|
197
258
|
def replace_sampleoutput(content)
|
198
|
-
|
259
|
+
# replace_block_commentout_without_sampleout(content)
|
199
260
|
content.dup.scan(/(^\/\/sampleoutputbegin\[)(.*?)(\].*?\R)(.*?)(^\/\/sampleoutputend)/m) { |m|
|
200
261
|
matched = m[0..-1].join
|
201
262
|
sampleoutputbegin = m[0..2].join
|
@@ -216,6 +277,12 @@ module ReVIEW
|
|
216
277
|
end
|
217
278
|
end
|
218
279
|
|
280
|
+
def fix_deprecated_list(content)
|
281
|
+
if Gem::Version.new(ReVIEW::VERSION) >= Gem::Version.new('4.0.0')
|
282
|
+
content.gsub!(/^: (.*)/, ' : \1')
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
219
286
|
def remove_starter_refid(content)
|
220
287
|
# note - noteref
|
221
288
|
content.dup.scan(/(@<noteref>)(?:(\$)|(?:({)|(\|)))(.*?)(?(2)(\$)|(?(3)(})|(\|)))/) { |m|
|
@@ -273,12 +340,17 @@ module ReVIEW
|
|
273
340
|
outpath = File.join(File.absolute_path(outdir), filepath)
|
274
341
|
FileUtils.mkdir_p(File.dirname(outpath))
|
275
342
|
FileUtils.cp(srcpath, outpath)
|
343
|
+
@embeded_contents.push(filepath[0])
|
276
344
|
update_content(outpath, outpath)
|
277
345
|
end
|
278
346
|
end
|
279
347
|
end
|
280
348
|
|
281
|
-
def
|
349
|
+
def make_id_label(name)
|
350
|
+
name.gsub(/[^A-Za-z0-9]/, '_')
|
351
|
+
end
|
352
|
+
|
353
|
+
def add_linkurl_footnote(content, filename)
|
282
354
|
urls = {}
|
283
355
|
content.dup.scan(/(^.*)(@<href>{)(.*?)(,)(.*?)(})(.*)$/) { |m|
|
284
356
|
unless m[0].match(/^#@#/)
|
@@ -287,9 +359,9 @@ module ReVIEW
|
|
287
359
|
url = m[2]
|
288
360
|
text = m[4]
|
289
361
|
post = m[6]
|
290
|
-
id = "
|
362
|
+
id = "#{make_id_label(filename)}_link_auto_footnote#{urls.length}"
|
291
363
|
urls[id] = url
|
292
|
-
content.sub!(/#{matched}$/, "#{prev}@<href>{#{url},#{text}} @<fn>{#{id}} #{post}")
|
364
|
+
content.sub!(/#{Regexp.escape(matched)}$/, "#{prev}@<href>{#{url},#{text}} @<fn>{#{id}} #{post}")
|
293
365
|
end
|
294
366
|
}
|
295
367
|
|
@@ -306,6 +378,7 @@ module ReVIEW
|
|
306
378
|
|
307
379
|
def update_content(outdir, contentfile)
|
308
380
|
info contentfile
|
381
|
+
filename = File.basename(contentfile, '.*')
|
309
382
|
content = File.read(contentfile)
|
310
383
|
content.gsub!(/@<href>{(.*?)#.*?,(.*?)}/, '@<href>{\1,\2}')
|
311
384
|
content.gsub!(/@<href>{(.*?)#.*?}/, '@<href>{\1}')
|
@@ -325,9 +398,13 @@ module ReVIEW
|
|
325
398
|
delete_block_command(content, 'clearpage')
|
326
399
|
delete_block_command(content, 'flushright')
|
327
400
|
delete_block_command(content, 'centering')
|
328
|
-
delete_block_command(content, 'noindent')
|
329
401
|
delete_block_command(content, 'paragraphend')
|
330
402
|
|
403
|
+
# delete IRD unsupported commands
|
404
|
+
if @ird
|
405
|
+
delete_block_command(content, 'noindent')
|
406
|
+
end
|
407
|
+
|
331
408
|
replace_inline_command(content, 'secref', 'hd')
|
332
409
|
replace_inline_command(content, 'file', 'kw')
|
333
410
|
replace_inline_command(content, 'hlink', 'href')
|
@@ -345,12 +422,19 @@ module ReVIEW
|
|
345
422
|
|
346
423
|
# fixed lack of options
|
347
424
|
content.gsub!(/^\/\/list{/, '//list[][]{')
|
425
|
+
# empty br line to blankline
|
426
|
+
content.gsub!(/^\s*@<br>{}\s*$/, '//blankline')
|
427
|
+
|
428
|
+
if Gem::Version.new(ReVIEW::VERSION) >= Gem::Version.new('4.0.0')
|
429
|
+
# empty caption is not allow
|
430
|
+
content.gsub!(/^\/\/image\[(.*)\]\[\]{/, '//image[\1][ ]{')
|
431
|
+
end
|
348
432
|
|
349
433
|
# special command
|
350
434
|
replace_sampleoutput(content)
|
351
435
|
|
352
436
|
if linkurl_footnote
|
353
|
-
add_linkurl_footnote(content)
|
437
|
+
add_linkurl_footnote(content, filename)
|
354
438
|
end
|
355
439
|
|
356
440
|
# nested command
|
@@ -364,6 +448,9 @@ module ReVIEW
|
|
364
448
|
remove_starter_refid(content)
|
365
449
|
remove_starter_options(content)
|
366
450
|
|
451
|
+
# replace block comment
|
452
|
+
replace_block_commentout(content)
|
453
|
+
|
367
454
|
# special charactor
|
368
455
|
content.gsub!('@<LaTeX>{}', 'LaTeX')
|
369
456
|
content.gsub!('@<TeX>{}', 'TeX')
|
@@ -377,6 +464,15 @@ module ReVIEW
|
|
377
464
|
# expand nested inline command
|
378
465
|
expand_nested_inline_command(content)
|
379
466
|
|
467
|
+
# fix deprecated
|
468
|
+
fix_deprecated_list(content)
|
469
|
+
|
470
|
+
if @ird
|
471
|
+
# br to blankline
|
472
|
+
content.gsub!(/(.*)@<br>{}$/, "\\1\n\n")
|
473
|
+
content.gsub!(/(.*)@<br>{}(.*)$/, "\\1\n\n\\2")
|
474
|
+
end
|
475
|
+
|
380
476
|
File.write(contentfile, content)
|
381
477
|
copy_embedded_contents(outdir, content)
|
382
478
|
end
|
@@ -385,8 +481,13 @@ module ReVIEW
|
|
385
481
|
files = contentfiles.is_a?(String) ? contentfiles.split(/\R/) : contentfiles
|
386
482
|
files.each do |content|
|
387
483
|
contentpath = File.join(contentdir, content)
|
484
|
+
srccontentpath = File.join(@srccontentsdir, content)
|
485
|
+
if @embeded_contents.include?(srccontentpath)
|
486
|
+
info "skip copy maped file #{contentpath}"
|
487
|
+
next
|
488
|
+
end
|
388
489
|
unless File.exist?(contentpath)
|
389
|
-
srcpath = File.join(
|
490
|
+
srcpath = File.join(@basedir, srccontentpath)
|
390
491
|
# info srcpath
|
391
492
|
if File.exist?(srcpath)
|
392
493
|
FileUtils.cp(srcpath, contentdir)
|
@@ -402,15 +503,11 @@ module ReVIEW
|
|
402
503
|
contentdir = abspath
|
403
504
|
info 'replace starter block command'
|
404
505
|
info 'replace starter inline command'
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
update_content_files(outdir, contentdir, catalog.postdef())
|
411
|
-
else
|
412
|
-
# copy_contents(outdir)
|
413
|
-
contentsfiles = Pathname.glob(File.join(File.join(@basedir, @srccontentsdir), '*.re')).map(&:basename)
|
506
|
+
catalog = ReVIEW::Catalog.new(File.open(File.join(abspath, yamlfile)))
|
507
|
+
update_content_files(outdir, contentdir, @catalog_contents)
|
508
|
+
unless options['strict']
|
509
|
+
all_contentsfiles = Pathname.glob(File.join(File.join(@basedir, @srccontentsdir), '*.re')).map(&:basename)
|
510
|
+
contentsfiles = all_contentsfiles.select{ |path| ! @catalog_contents.include?(path.to_s) }
|
414
511
|
update_content_files(outdir, contentdir, contentsfiles)
|
415
512
|
end
|
416
513
|
end
|
@@ -428,6 +525,7 @@ module ReVIEW
|
|
428
525
|
Dir.chdir(pwd)
|
429
526
|
content = buf.string
|
430
527
|
content.gsub!(/^#[@]map.*$/, '')
|
528
|
+
content.gsub!(/^#[@]end$/, '')
|
431
529
|
File.write(contentpath, content)
|
432
530
|
end
|
433
531
|
end
|
@@ -443,17 +541,28 @@ module ReVIEW
|
|
443
541
|
|
444
542
|
if options['strict']
|
445
543
|
catalog = ReVIEW::Catalog.new(File.open(File.join(abspath, yamlfile)))
|
446
|
-
preproc_content_files(outdir, pp, contentdir,
|
447
|
-
preproc_content_files(outdir, pp, contentdir, catalog.chaps())
|
448
|
-
preproc_content_files(outdir, pp, contentdir, catalog.appendix())
|
449
|
-
preproc_content_files(outdir, pp, contentdir, catalog.postdef())
|
544
|
+
preproc_content_files(outdir, pp, contentdir, @catalog_contents)
|
450
545
|
else
|
451
|
-
# copy_contents(outdir)
|
452
546
|
contentsfiles = Pathname.glob(File.join(File.join(@basedir, @srccontentsdir), '*.re')).map(&:basename)
|
453
547
|
preproc_content_files(outdir, pp, contentdir, contentsfiles)
|
454
548
|
end
|
455
549
|
end
|
456
550
|
|
551
|
+
def update_sty(outdir, options)
|
552
|
+
# FileUtils.cp(File.join(@basedir, 'sty/review-custom.sty'), File.join(outdir, 'sty/review-custom.sty'))
|
553
|
+
if @ird
|
554
|
+
FileUtils.cp(File.join(__dir__, 'sty/ird.sty'), File.join(outdir, 'sty/ird.sty'))
|
555
|
+
file = File.open(File.join(outdir, 'sty/review-custom.sty'), 'a')
|
556
|
+
file.puts('\RequirePackage{ird}')
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
560
|
+
def update_ext(outdir, options)
|
561
|
+
if @ird
|
562
|
+
FileUtils.cp(File.join(__dir__, 'ext/review-ext.rb'), File.join(outdir, 'review-ext.rb'))
|
563
|
+
end
|
564
|
+
end
|
565
|
+
|
457
566
|
def clean_initial_project(outdir)
|
458
567
|
FileUtils.rm(File.join(outdir, 'config.yml'))
|
459
568
|
FileUtils.rm(File.join(outdir, 'catalog.yml'))
|
@@ -461,11 +570,22 @@ module ReVIEW
|
|
461
570
|
FileUtils.rm(Dir.glob(File.join(outdir, '*.re')))
|
462
571
|
end
|
463
572
|
|
573
|
+
def add_catalog_contents(contentfiles)
|
574
|
+
files = contentfiles.is_a?(String) ? contentfiles.split(/\R/) : contentfiles
|
575
|
+
@catalog_contents.concat(files)
|
576
|
+
end
|
577
|
+
|
464
578
|
def load_config(yamlfile)
|
465
579
|
@configs.open(yamlfile)
|
466
580
|
@config = @configs.config
|
467
581
|
@basedir = @configs.basedir
|
468
582
|
@srccontentsdir = @config['contentdir']
|
583
|
+
|
584
|
+
catalog = ReVIEW::Catalog.new(File.open(@configs.catalogfile()))
|
585
|
+
add_catalog_contents(catalog.predef())
|
586
|
+
add_catalog_contents(catalog.chaps())
|
587
|
+
add_catalog_contents(catalog.appendix())
|
588
|
+
add_catalog_contents(catalog.postdef())
|
469
589
|
end
|
470
590
|
|
471
591
|
def create_initial_project(outdir, options)
|
@@ -477,21 +597,28 @@ module ReVIEW
|
|
477
597
|
def execute(yamlfile, outdir, options)
|
478
598
|
@table_br_replace = options['table-br-replace']
|
479
599
|
@table_empty_replace = options['table-empty-replace']
|
600
|
+
@ird = options['ird']
|
480
601
|
load_config(yamlfile)
|
602
|
+
store_image_dir = store_out_image(outdir) if options['no-image']
|
481
603
|
create_initial_project(outdir, options)
|
482
604
|
|
483
605
|
copy_config(outdir)
|
484
606
|
copy_catalog(outdir)
|
485
|
-
copy_images(outdir)
|
607
|
+
copy_images(outdir, store_image_dir)
|
486
608
|
update_config(outdir)
|
487
609
|
update_contents(outdir, options)
|
610
|
+
update_sty(outdir, options)
|
611
|
+
update_ext(outdir, options)
|
488
612
|
|
489
613
|
pwd = Dir.pwd
|
490
614
|
Dir.chdir(outdir)
|
491
615
|
updater = ReVIEW::Update.new
|
492
616
|
updater.force = true
|
493
617
|
# updater.backup = false
|
494
|
-
|
618
|
+
begin
|
619
|
+
updater.execute()
|
620
|
+
rescue
|
621
|
+
end
|
495
622
|
Dir.chdir(pwd)
|
496
623
|
|
497
624
|
if options['preproc']
|