review-retrovert 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1800fdc491a64bc922e8164e966bf6f84c4c2c2439a2330e106398ea97c55cc8
4
- data.tar.gz: 3b1c672c1c85dc6ec2ca28628c64b4ba0f14263eacdc1952d4ca9427644446bf
3
+ metadata.gz: 02507e93743d82045d68c54d9aa2acec9666def48b1187b7577e1e70ade8a4f5
4
+ data.tar.gz: f2121fe5b228534e7f1ada87cbce40d35674cc7f1b92f2de14d04e500ef5b640
5
5
  SHA512:
6
- metadata.gz: acf0b640bb8ebb2e3f4549103dd73be14e2258f85a720580d8cb0bdb31d5f150e3ffde958dd77672ba16fd3a9b1f5a99e87d65927dfe9277186e529b89298c57
7
- data.tar.gz: 5c16364152fc108a2214f1126f3583435dba1eafb080e6c07c3fc20a3de8d7702921e8a89143ce6577323182e10df3da50f9b3f08e07115203e1cbcb6d07a319
6
+ metadata.gz: edcf427bdad063863a08aff465863a8a6f6f0fc626b8491aab77df8902b46439239298fe21e220b2a7e8e712f93367267ae3a7a7a3a67eb89780a56f3e72ab03
7
+ data.tar.gz: 66b55029a3127ad59626c8852c883a9c1d264be675686d4562d56ec9e58ee41458aa89e9a6a49e9a506684902256f18924b68f0a68bafa7fd53de37af1088f13
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- review-retrovert (0.9.5)
4
+ review-retrovert (0.9.6)
5
5
  review (>= 3.0.0)
6
6
  thor
7
7
 
data/README.md CHANGED
@@ -21,6 +21,12 @@ And then execute:
21
21
  Or install it yourself as:
22
22
 
23
23
  $ gem install review-retrovert
24
+
25
+ ## Use Docker
26
+
27
+ ```
28
+ docker run -v "$(pwd):/work" -w /work srzzumix/review-retrovert convert target/config.yml outdir
29
+ ```
24
30
 
25
31
  ## Commands
26
32
 
@@ -33,16 +39,16 @@ Commands:
33
39
 
34
40
  ### Convert
35
41
 
36
- e.g.
42
+ #### e.g.
37
43
 
38
44
  ```sh
39
45
  review-retrovert convert /path/to/dir/review-starter/config.yml <output directory>
40
46
  ```
41
47
 
42
- Options
48
+ #### Options
43
49
 
44
50
  ```sh
45
- Usage:
51
+ sage:
46
52
  review-retrovert convert {review_starter_configfile} {outdir}
47
53
 
48
54
  Options:
@@ -54,6 +60,8 @@ Options:
54
60
  [--table-br-replace=TABLE-BR-REPLACE] # @<br>{} in table replace string (Default: empty)
55
61
  [--table-empty-replace=TABLE-EMPTY-REPLACE] # empty cell(.) in table replace string (Default full-width space)
56
62
  # Default:  
63
+ [--ird], [--no-ird] # for IRD
64
+ [--no-image] # donot copy image
57
65
 
58
66
  convert Re:VIEW Starter project to Re:VIEW project
59
67
  ```
@@ -11,6 +11,8 @@ module ReVIEW
11
11
  method_option "tabwidth", desc: 'Preproc tabwidth option value', type: :numeric, default: 0
12
12
  method_option "table-br-replace", desc: '@<br>{} in table replace string (Default: empty)', type: :string, default: ''
13
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
@@ -15,6 +16,7 @@ module ReVIEW
15
16
  @configs = YamlConfig.new
16
17
  @embeded_contents = []
17
18
  @catalog_contents = []
19
+ @ird = false
18
20
  end
19
21
 
20
22
  def error(msg)
@@ -47,21 +49,50 @@ module ReVIEW
47
49
  FileUtils.cp_r(Dir.glob(File.join(path, '*.re')), outdir)
48
50
  end
49
51
 
50
- def copy_images(outdir)
52
+ def get_out_imagedir(outdir)
51
53
  imagedir = @config['imagedir']
52
- srcpath = File.join(@basedir, imagedir)
53
54
  outimagedir = File.basename(imagedir) # Re:VIEW not support sub-directory
54
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)
55
81
  FileUtils.mkdir_p(outpath)
56
- image_ext = @config['image_ext']
57
- srcroot = Pathname.new(srcpath)
58
- image_ext.each { |ext|
59
- Dir.glob(File.join(srcpath, "**/*.#{ext}")).each { |srcimg|
60
- outimg = File.join(outpath, Pathname.new(srcimg).relative_path_from(srcroot))
61
- FileUtils.makedirs(File.dirname(outimg))
62
- FileUtils.cp(srcimg, outimg)
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
+ }
63
94
  }
64
- }
95
+ end
65
96
  @configs.rewrite_yml('imagedir', outimagedir)
66
97
  end
67
98
 
@@ -69,7 +100,6 @@ module ReVIEW
69
100
  @configs.rewrite_yml('contentdir', '.')
70
101
  @configs.rewrite_yml('hook_beforetexcompile', 'null')
71
102
  @configs.rewrite_yml('texstyle', '["reviewmacro"]')
72
- # @configs.rewrite_yml('chapterlink', 'null')
73
103
  pagesize = @config['starter']['pagesize'].downcase
74
104
  @configs.rewrite_yml_array('texdocumentclass', "[\"review-jsbook\", \"media=print,paper=#{pagesize}\"]")
75
105
  @config['retrovert'].each{ |k,v|
@@ -77,6 +107,9 @@ module ReVIEW
77
107
  @configs.commentout_root_yml(k)
78
108
  end
79
109
  }
110
+ if @ird
111
+ @configs.rewrite_yml('chapterlink', 'null')
112
+ end
80
113
  end
81
114
 
82
115
  def replace_compatible_block_command_outline(content, command, new_command, option_count)
@@ -359,9 +392,13 @@ module ReVIEW
359
392
  delete_block_command(content, 'clearpage')
360
393
  delete_block_command(content, 'flushright')
361
394
  delete_block_command(content, 'centering')
362
- delete_block_command(content, 'noindent')
363
395
  delete_block_command(content, 'paragraphend')
364
396
 
397
+ # delete IRD unsupported commands
398
+ if @ird
399
+ delete_block_command(content, 'noindent')
400
+ end
401
+
365
402
  replace_inline_command(content, 'secref', 'hd')
366
403
  replace_inline_command(content, 'file', 'kw')
367
404
  replace_inline_command(content, 'hlink', 'href')
@@ -394,9 +431,6 @@ module ReVIEW
394
431
  add_linkurl_footnote(content, filename)
395
432
  end
396
433
 
397
- # # br to blankline
398
- # content.gsub!(/(.*)@<br>{}(.*)/, '\1\n//blankline\n\2')
399
-
400
434
  # nested command
401
435
  replace_block_command_nested_boxed_articles(content)
402
436
 
@@ -427,6 +461,12 @@ module ReVIEW
427
461
  # fix deprecated
428
462
  fix_deprecated_list(content)
429
463
 
464
+ if @ird
465
+ # br to blankline
466
+ content.gsub!(/(.*)@<br>{}$/, "\\1\n\n")
467
+ content.gsub!(/(.*)@<br>{}(.*)$/, "\\1\n\n\\2")
468
+ end
469
+
430
470
  File.write(contentfile, content)
431
471
  copy_embedded_contents(outdir, content)
432
472
  end
@@ -536,12 +576,14 @@ module ReVIEW
536
576
  def execute(yamlfile, outdir, options)
537
577
  @table_br_replace = options['table-br-replace']
538
578
  @table_empty_replace = options['table-empty-replace']
579
+ @ird = options['ird']
539
580
  load_config(yamlfile)
581
+ store_image_dir = store_out_image(outdir) if options['no-image']
540
582
  create_initial_project(outdir, options)
541
583
 
542
584
  copy_config(outdir)
543
585
  copy_catalog(outdir)
544
- copy_images(outdir)
586
+ copy_images(outdir, store_image_dir)
545
587
  update_config(outdir)
546
588
  update_contents(outdir, options)
547
589
 
@@ -1,5 +1,5 @@
1
1
  module ReVIEW
2
2
  module Retrovert
3
- VERSION = "0.9.5"
3
+ VERSION = "0.9.6"
4
4
  end
5
5
  end
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.5
4
+ version: 0.9.6
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-16 00:00:00.000000000 Z
11
+ date: 2021-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  - !ruby/object:Gem::Version
193
193
  version: '0'
194
194
  requirements: []
195
- rubygems_version: 3.2.3
195
+ rubygems_version: 3.1.4
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Re:VIEW Starter to Re:VIEW