review-retrovert 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +60 -3
- data/lib/review/retrovert/cli.rb +2 -2
- data/lib/review/retrovert/converter.rb +33 -16
- data/lib/review/retrovert/version.rb +1 -1
- data/lib/review/retrovert/yamlconfig.rb +20 -1
- 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 +4 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d88019dcbdef1f19522028bd668913c7f2100d2774796ca208a7e72df829b3ef
|
4
|
+
data.tar.gz: 4b3605223424275e592269e6fbfd1124275087c322522b0d5cb309434ee202ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519813a8c9690db53484fb206084a97c36c8bfe1c230fe09bb623c7d93ce178a81b1bb91eed87a9edfb1c753b345e0d12ca36f50bf8789ea0a6906126b62e771
|
7
|
+
data.tar.gz: '02823e04d7787079bcf94273ab43af37d903c8d8de357fde7c8394094ff88a5e2275e173284496eccf328f74da11c11b8b3d2233814529cb00b4021ff014b19d'
|
data/Gemfile.lock
CHANGED
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
|
|
@@ -22,12 +22,69 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
$ gem install review-retrovert
|
24
24
|
|
25
|
-
##
|
25
|
+
## Commands
|
26
|
+
|
27
|
+
```sh
|
28
|
+
Commands:
|
29
|
+
review-retrovert convert {review_starter_configfile} {outdir} # convert Re:VIEW Starter project to Re:VIEW project
|
30
|
+
review-retrovert help [COMMAND] # Describe available commands or one specific command
|
31
|
+
review-retrovert version # show version
|
32
|
+
```
|
33
|
+
|
34
|
+
### Convert
|
35
|
+
|
36
|
+
e.g.
|
26
37
|
|
27
38
|
```sh
|
28
39
|
review-retrovert convert /path/to/dir/review-starter/config.yml <output directory>
|
29
40
|
```
|
30
41
|
|
42
|
+
Options
|
43
|
+
|
44
|
+
```sh
|
45
|
+
Usage:
|
46
|
+
review-retrovert convert {review_starter_configfile} {outdir}
|
47
|
+
|
48
|
+
Options:
|
49
|
+
f, [--force] # Force output
|
50
|
+
[--strict], [--no-strict] # Only process files registered in the catalog
|
51
|
+
[--preproc], [--no-preproc] # Execute preproc after conversion
|
52
|
+
[--tabwidth=N] # Preproc tabwidth option value
|
53
|
+
# Default: 0
|
54
|
+
[--table-br-replace=TABLE-BR-REPLACE] # @<br>{} in table replace string (Default: empty)
|
55
|
+
[--table-empty-replace=TABLE-EMPTY-REPLACE] # empty cell(.) in table replace string (Default full-width space)
|
56
|
+
# Default:
|
57
|
+
|
58
|
+
convert Re:VIEW Starter project to Re:VIEW project
|
59
|
+
```
|
60
|
+
|
61
|
+
#### retrovert config
|
62
|
+
|
63
|
+
If the retrovert key is present in config.yml, the subordinate elements will take effect after convert.
|
64
|
+
|
65
|
+
If you have a setting that you want to enable only after retrovert, use inherit as shown below.
|
66
|
+
|
67
|
+
* config-retrovert.yml
|
68
|
+
|
69
|
+
```yml
|
70
|
+
retrovert:
|
71
|
+
chapterlink: null
|
72
|
+
```
|
73
|
+
|
74
|
+
* config-base.yml
|
75
|
+
|
76
|
+
```yml
|
77
|
+
chapterlink: true
|
78
|
+
```
|
79
|
+
|
80
|
+
* config.yml
|
81
|
+
|
82
|
+
```yml
|
83
|
+
inherit: ["config-base.yml", "config-starter.yml", "config-retrovert.yml"]
|
84
|
+
|
85
|
+
#chapterlink: true
|
86
|
+
```
|
87
|
+
|
31
88
|
## Development
|
32
89
|
|
33
90
|
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 +97,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/srz-zu
|
|
40
97
|
|
41
98
|
## Develop
|
42
99
|
|
43
|
-
docker run -it --rm -v $(pwd)/:/work -w /work vvakame/review:
|
100
|
+
docker run -it --rm -v $(pwd)/:/work -w /work vvakame/review:5.0 bash
|
44
101
|
|
45
102
|
## License
|
46
103
|
|
data/lib/review/retrovert/cli.rb
CHANGED
@@ -9,8 +9,8 @@ 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
14
|
def convert(review_starter_configfile, outdir)
|
15
15
|
Converter.execute(review_starter_configfile, outdir, options)
|
16
16
|
end
|
@@ -13,6 +13,8 @@ module ReVIEW
|
|
13
13
|
@outimagedir = nil
|
14
14
|
@logger = ReVIEW.logger
|
15
15
|
@configs = YamlConfig.new
|
16
|
+
@embeded_contents = []
|
17
|
+
@catalog_contents = []
|
16
18
|
end
|
17
19
|
|
18
20
|
def error(msg)
|
@@ -67,9 +69,14 @@ module ReVIEW
|
|
67
69
|
@configs.rewrite_yml('contentdir', '.')
|
68
70
|
@configs.rewrite_yml('hook_beforetexcompile', 'null')
|
69
71
|
@configs.rewrite_yml('texstyle', '["reviewmacro"]')
|
70
|
-
@configs.rewrite_yml('chapterlink', 'null')
|
72
|
+
# @configs.rewrite_yml('chapterlink', 'null')
|
71
73
|
pagesize = @config['starter']['pagesize'].downcase
|
72
74
|
@configs.rewrite_yml_array('texdocumentclass', "[\"review-jsbook\", \"media=print,paper=#{pagesize}\"]")
|
75
|
+
@config['retrovert'].each{ |k,v|
|
76
|
+
unless v..is_a?(Hash)
|
77
|
+
@configs.commentout_root_yml(k)
|
78
|
+
end
|
79
|
+
}
|
73
80
|
end
|
74
81
|
|
75
82
|
def replace_compatible_block_command_outline(content, command, new_command, option_count)
|
@@ -294,6 +301,7 @@ module ReVIEW
|
|
294
301
|
outpath = File.join(File.absolute_path(outdir), filepath)
|
295
302
|
FileUtils.mkdir_p(File.dirname(outpath))
|
296
303
|
FileUtils.cp(srcpath, outpath)
|
304
|
+
@embeded_contents.push(filepath[0])
|
297
305
|
update_content(outpath, outpath)
|
298
306
|
end
|
299
307
|
end
|
@@ -420,8 +428,13 @@ module ReVIEW
|
|
420
428
|
files = contentfiles.is_a?(String) ? contentfiles.split(/\R/) : contentfiles
|
421
429
|
files.each do |content|
|
422
430
|
contentpath = File.join(contentdir, content)
|
431
|
+
srccontentpath = File.join(@srccontentsdir, content)
|
432
|
+
if @embeded_contents.include?(srccontentpath)
|
433
|
+
info "skip copy maped file #{contentpath}"
|
434
|
+
next
|
435
|
+
end
|
423
436
|
unless File.exist?(contentpath)
|
424
|
-
srcpath = File.join(
|
437
|
+
srcpath = File.join(@basedir, srccontentpath)
|
425
438
|
# info srcpath
|
426
439
|
if File.exist?(srcpath)
|
427
440
|
FileUtils.cp(srcpath, contentdir)
|
@@ -437,15 +450,11 @@ module ReVIEW
|
|
437
450
|
contentdir = abspath
|
438
451
|
info 'replace starter block command'
|
439
452
|
info 'replace starter inline command'
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
update_content_files(outdir, contentdir, catalog.postdef())
|
446
|
-
else
|
447
|
-
# copy_contents(outdir)
|
448
|
-
contentsfiles = Pathname.glob(File.join(File.join(@basedir, @srccontentsdir), '*.re')).map(&:basename)
|
453
|
+
catalog = ReVIEW::Catalog.new(File.open(File.join(abspath, yamlfile)))
|
454
|
+
update_content_files(outdir, contentdir, @catalog_contents)
|
455
|
+
unless options['strict']
|
456
|
+
all_contentsfiles = Pathname.glob(File.join(File.join(@basedir, @srccontentsdir), '*.re')).map(&:basename)
|
457
|
+
contentsfiles = all_contentsfiles.select{ |path| ! @catalog_contents.include?(path.to_s) }
|
449
458
|
update_content_files(outdir, contentdir, contentsfiles)
|
450
459
|
end
|
451
460
|
end
|
@@ -463,6 +472,7 @@ module ReVIEW
|
|
463
472
|
Dir.chdir(pwd)
|
464
473
|
content = buf.string
|
465
474
|
content.gsub!(/^#[@]map.*$/, '')
|
475
|
+
content.gsub!(/^#[@]end$/, '')
|
466
476
|
File.write(contentpath, content)
|
467
477
|
end
|
468
478
|
end
|
@@ -478,12 +488,8 @@ module ReVIEW
|
|
478
488
|
|
479
489
|
if options['strict']
|
480
490
|
catalog = ReVIEW::Catalog.new(File.open(File.join(abspath, yamlfile)))
|
481
|
-
preproc_content_files(outdir, pp, contentdir,
|
482
|
-
preproc_content_files(outdir, pp, contentdir, catalog.chaps())
|
483
|
-
preproc_content_files(outdir, pp, contentdir, catalog.appendix())
|
484
|
-
preproc_content_files(outdir, pp, contentdir, catalog.postdef())
|
491
|
+
preproc_content_files(outdir, pp, contentdir, @catalog_contents)
|
485
492
|
else
|
486
|
-
# copy_contents(outdir)
|
487
493
|
contentsfiles = Pathname.glob(File.join(File.join(@basedir, @srccontentsdir), '*.re')).map(&:basename)
|
488
494
|
preproc_content_files(outdir, pp, contentdir, contentsfiles)
|
489
495
|
end
|
@@ -496,11 +502,22 @@ module ReVIEW
|
|
496
502
|
FileUtils.rm(Dir.glob(File.join(outdir, '*.re')))
|
497
503
|
end
|
498
504
|
|
505
|
+
def add_catalog_contents(contentfiles)
|
506
|
+
files = contentfiles.is_a?(String) ? contentfiles.split(/\R/) : contentfiles
|
507
|
+
@catalog_contents.concat(files)
|
508
|
+
end
|
509
|
+
|
499
510
|
def load_config(yamlfile)
|
500
511
|
@configs.open(yamlfile)
|
501
512
|
@config = @configs.config
|
502
513
|
@basedir = @configs.basedir
|
503
514
|
@srccontentsdir = @config['contentdir']
|
515
|
+
|
516
|
+
catalog = ReVIEW::Catalog.new(File.open(@configs.catalogfile()))
|
517
|
+
add_catalog_contents(catalog.predef())
|
518
|
+
add_catalog_contents(catalog.chaps())
|
519
|
+
add_catalog_contents(catalog.appendix())
|
520
|
+
add_catalog_contents(catalog.postdef())
|
504
521
|
end
|
505
522
|
|
506
523
|
def create_initial_project(outdir, options)
|
@@ -87,9 +87,19 @@ module ReVIEW
|
|
87
87
|
rewrite_retrovert_yml()
|
88
88
|
end
|
89
89
|
|
90
|
+
def commentout(yamlfile, key)
|
91
|
+
content = File.read(yamlfile)
|
92
|
+
content.gsub!(/^(\s*)#{key}:(.*)$/, "#\\1#{key}:\\2")
|
93
|
+
File.write(yamlfile, content)
|
94
|
+
end
|
95
|
+
|
96
|
+
def commentout_root_yml(key)
|
97
|
+
commentout(File.join(@basedir, @basename), key)
|
98
|
+
end
|
99
|
+
|
90
100
|
def rewrite_yml_(yamlfile, key, val)
|
91
101
|
content = File.read(yamlfile)
|
92
|
-
content.gsub!(/^(\s*)#{key}:.*$/,
|
102
|
+
content.gsub!(/^(\s*)#{key}:.*$/, "\\1#{key}: #{val}")
|
93
103
|
File.write(yamlfile, content)
|
94
104
|
end
|
95
105
|
|
@@ -121,6 +131,7 @@ module ReVIEW
|
|
121
131
|
# YAML.dump(yaml, File.open(yamlfile, "w"))
|
122
132
|
content = Psych.dump(yaml)
|
123
133
|
content.gsub!('---','')
|
134
|
+
content.gsub!(/^(.*):\s*$/, '\1: null')
|
124
135
|
File.write(yamlfile, content)
|
125
136
|
}
|
126
137
|
end
|
@@ -137,6 +148,14 @@ module ReVIEW
|
|
137
148
|
return yaml
|
138
149
|
end
|
139
150
|
|
151
|
+
def path()
|
152
|
+
File.join(@basedir, @basename)
|
153
|
+
end
|
154
|
+
|
155
|
+
def catalogfile()
|
156
|
+
File.join(@basedir, @config['catalogfile'])
|
157
|
+
end
|
158
|
+
|
140
159
|
end
|
141
160
|
end
|
142
161
|
end
|
data/review-retrovert.gemspec
CHANGED
data/testdata/mybook/catalog.yml
CHANGED
data/testdata/mybook/config.yml
CHANGED
@@ -15,7 +15,7 @@ review_version: 2.0
|
|
15
15
|
# その値がB.ymlよりも優先される。
|
16
16
|
# 同様にA.yml、B.yml内でさらにinherit:パラメータを使うこともできる。
|
17
17
|
# inherit: ["A.yml", "B.yml"]
|
18
|
-
inherit: ["config-starter.yml"]
|
18
|
+
inherit: ["config-starter.yml", "config-retrovert.yml"]
|
19
19
|
|
20
20
|
# ブック名(ファイル名になるもの。ASCII範囲の文字を使用)
|
21
21
|
bookname: mybook
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: review-retrovert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- srz_zumix
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: 3.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
54
|
+
version: 3.0.0
|
55
55
|
description: Re:VIEW Starter to Re:VIEW
|
56
56
|
email:
|
57
57
|
- zumix.cpp@gmail.com
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- testdata/mybook/README.md
|
91
91
|
- testdata/mybook/Rakefile
|
92
92
|
- testdata/mybook/catalog.yml
|
93
|
+
- testdata/mybook/config-retrovert.yml
|
93
94
|
- testdata/mybook/config-starter.yml
|
94
95
|
- testdata/mybook/config.yml
|
95
96
|
- testdata/mybook/contents/00-preface.re
|
@@ -103,6 +104,8 @@ files:
|
|
103
104
|
- testdata/mybook/contents/92-filelist.re
|
104
105
|
- testdata/mybook/contents/93-background.re
|
105
106
|
- testdata/mybook/contents/99-postface.re
|
107
|
+
- testdata/mybook/contents/r0-inner.re
|
108
|
+
- testdata/mybook/contents/r0-root.re
|
106
109
|
- testdata/mybook/css/normalize.css
|
107
110
|
- testdata/mybook/css/webstyle.css
|
108
111
|
- testdata/mybook/images/03-syntax/favicon-16x16.png
|