review-retrovert 0.3.3 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/retrovert.yml +39 -0
  3. data/.gitignore +2 -2
  4. data/.ruby-version +1 -0
  5. data/Gemfile +1 -0
  6. data/Gemfile.lock +67 -1
  7. data/README.md +6 -3
  8. data/lib/review/retrovert/converter.rb +231 -6
  9. data/lib/review/retrovert/version.rb +1 -1
  10. data/review-retrovert.gemspec +1 -1
  11. data/testdata/mybook/.gitignore +7 -0
  12. data/testdata/mybook/README.md +43 -0
  13. data/testdata/mybook/Rakefile +16 -0
  14. data/testdata/mybook/catalog.yml +33 -0
  15. data/testdata/mybook/config-starter.yml +139 -0
  16. data/testdata/mybook/config.yml +375 -0
  17. data/testdata/mybook/contents/00-preface.re +83 -0
  18. data/testdata/mybook/contents/01-install.re +272 -0
  19. data/testdata/mybook/contents/02-tutorial.re +1008 -0
  20. data/testdata/mybook/contents/03-syntax.re +2613 -0
  21. data/testdata/mybook/contents/04-customize.re +728 -0
  22. data/testdata/mybook/contents/05-faq.re +328 -0
  23. data/testdata/mybook/contents/06-bestpractice.re +971 -0
  24. data/testdata/mybook/contents/91-compare.re +18 -0
  25. data/testdata/mybook/contents/92-filelist.re +119 -0
  26. data/testdata/mybook/contents/93-background.re +267 -0
  27. data/testdata/mybook/contents/99-postface.re +38 -0
  28. data/testdata/mybook/css/normalize.css +349 -0
  29. data/testdata/mybook/css/webstyle.css +514 -0
  30. data/testdata/mybook/images/03-syntax/favicon-16x16.png +0 -0
  31. data/testdata/mybook/images/03-syntax/figure_heretop.png +0 -0
  32. data/testdata/mybook/images/03-syntax/tw-icon1.jpg +0 -0
  33. data/testdata/mybook/images/03-syntax/tw-icon2.jpg +0 -0
  34. data/testdata/mybook/images/03-syntax/tw-icon3.jpg +0 -0
  35. data/testdata/mybook/images/03-syntax/tw-icon4.jpg +0 -0
  36. data/testdata/mybook/images/04-customize/caption_pagebreak.png +0 -0
  37. data/testdata/mybook/images/04-customize/chaptitlepage_sample.png +0 -0
  38. data/testdata/mybook/images/05-faq/codeblock_rpadding1.png +0 -0
  39. data/testdata/mybook/images/05-faq/codeblock_rpadding2.png +0 -0
  40. data/testdata/mybook/images/06-bestpractice/figure_heretop.png +0 -0
  41. data/testdata/mybook/images/06-bestpractice/font_beramono.png +0 -0
  42. data/testdata/mybook/images/06-bestpractice/heading_design1.png +0 -0
  43. data/testdata/mybook/images/06-bestpractice/heading_design2.png +0 -0
  44. data/testdata/mybook/images/06-bestpractice/margin_book.png +0 -0
  45. data/testdata/mybook/images/06-bestpractice/multiline-title.png +0 -0
  46. data/testdata/mybook/images/06-bestpractice/preface_numbered.png +0 -0
  47. data/testdata/mybook/images/06-bestpractice/program_border.png +0 -0
  48. data/testdata/mybook/images/06-bestpractice/sechead_design_4.png +0 -0
  49. data/testdata/mybook/images/06-bestpractice/titlepage-samples.png +0 -0
  50. data/testdata/mybook/images/93-background/bug913.png +0 -0
  51. data/testdata/mybook/images/93-background/slide2.png +0 -0
  52. data/testdata/mybook/images/cover_a5.pdf +0 -0
  53. data/testdata/mybook/images/cover_b5.pdf +0 -0
  54. data/testdata/mybook/images/tw-icon.jpg +0 -0
  55. data/testdata/mybook/layouts/layout.epub.erb +29 -0
  56. data/testdata/mybook/layouts/layout.html5.erb +106 -0
  57. data/testdata/mybook/layouts/layout.tex.erb +546 -0
  58. data/testdata/mybook/lib/hooks/beforetexcompile.rb +55 -0
  59. data/testdata/mybook/lib/ruby/review-builder.rb +503 -0
  60. data/testdata/mybook/lib/ruby/review-cli.rb +58 -0
  61. data/testdata/mybook/lib/ruby/review-compiler.rb +523 -0
  62. data/testdata/mybook/lib/ruby/review-epubmaker.rb +606 -0
  63. data/testdata/mybook/lib/ruby/review-htmlbuilder.rb +661 -0
  64. data/testdata/mybook/lib/ruby/review-latexbuilder.rb +782 -0
  65. data/testdata/mybook/lib/ruby/review-maker.rb +235 -0
  66. data/testdata/mybook/lib/ruby/review-monkeypatch.rb +91 -0
  67. data/testdata/mybook/lib/ruby/review-pdfmaker.rb +468 -0
  68. data/testdata/mybook/lib/ruby/review-textbuilder.rb +36 -0
  69. data/testdata/mybook/lib/ruby/review-tocparser.rb +285 -0
  70. data/testdata/mybook/lib/ruby/review-webmaker.rb +433 -0
  71. data/testdata/mybook/lib/tasks/mytasks.rake +31 -0
  72. data/testdata/mybook/lib/tasks/review.rake +142 -0
  73. data/testdata/mybook/lib/tasks/review.rake.orig +72 -0
  74. data/testdata/mybook/lib/tasks/starter.rake +326 -0
  75. data/testdata/mybook/locale.yml +6 -0
  76. data/testdata/mybook/review-ext.rb +206 -0
  77. data/testdata/mybook/sty/jumoline.sty +310 -0
  78. data/testdata/mybook/sty/mycolophon.sty +81 -0
  79. data/testdata/mybook/sty/mystyle.sty +8 -0
  80. data/testdata/mybook/sty/mytextsize.sty +61 -0
  81. data/testdata/mybook/sty/mytitlepage.sty +103 -0
  82. data/testdata/mybook/sty/reviewmacro.sty +60 -0
  83. data/testdata/mybook/sty/starter-codeblock.sty +332 -0
  84. data/testdata/mybook/sty/starter-color.sty +79 -0
  85. data/testdata/mybook/sty/starter-font.sty +112 -0
  86. data/testdata/mybook/sty/starter-heading.sty +514 -0
  87. data/testdata/mybook/sty/starter-note.sty +127 -0
  88. data/testdata/mybook/sty/starter-section.sty +262 -0
  89. data/testdata/mybook/sty/starter-toc.sty +72 -0
  90. data/testdata/mybook/sty/starter.sty +554 -0
  91. data/testdata/mybook/style.css +597 -0
  92. metadata +100 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4018ff4ea97d4ea7a151e769c871e9d1f91d6c1ce2b18a500ae68a569987d1d0
4
- data.tar.gz: 862bc4e9be33d25e15a2b1b3bfac1b3f231af1568e35d320ee5458740629ac50
3
+ metadata.gz: a9311aa0fa85bd42652cbbe163b02383bb3e3ce8b82d5c10f1d85af48ecda098
4
+ data.tar.gz: cac37e6eae36803b96a0f009695ffe480a7fafe4642a1bb45a44a4bcc1eb948b
5
5
  SHA512:
6
- metadata.gz: 4423300d41d6ba1ad911c99145fa830c8c36a9dd4a54273dda177b27bca65ae8d86bb5300382f28b5bc05abe27ce8fb12c6313fb4967f2244d0583a4c32c1bed
7
- data.tar.gz: 68d804e35464032a32bc6d4b0cd45f919128fecced2bf4e8692db0e0e9e62212e64c1e4539b943f076e32ea10baf5fdb631d146eb0afaaa465375f4a67b58886
6
+ metadata.gz: 506fd1726a38d677b12c6641ba1f77330c332c9ec75d9d18427cedc8647ec319762df7025b8bcc65458e7bac9921fd62b6c3e7f3d6faf0447c5ad15a486ed2a9
7
+ data.tar.gz: 21dabf3b90b0d6f93183d7e48aa7a3b32614b37edc078f6c538c6e8b810fc5c5f4ae7577ca10d9f6a45cc8732867d2e12f558f7ff5d1fb4fb97ddefe547c80fa
@@ -0,0 +1,39 @@
1
+ on:
2
+ pull_request:
3
+ push:
4
+ branches:
5
+ - master
6
+
7
+ name: Retrovert
8
+ jobs:
9
+ review:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6
16
+ - run: bundle install
17
+ # spec
18
+ - name: spec
19
+ run: bundle exec rake spec
20
+ # convert
21
+ - name: convert
22
+ run: bundle exec review-retrovert convert testdata/mybook/config.yml tmp -f
23
+ # build
24
+ - name: review build
25
+ uses: docker://srzzumix/review-retrovert
26
+ with:
27
+ entrypoint: bash
28
+ args: -c "cd tmp; rake preproc all"
29
+ # artifacts
30
+ - name: artifacts
31
+ uses: actions/upload-artifact@v1
32
+ with:
33
+ name: mybook
34
+ path: tmp/mybook.pdf
35
+ - name: artifacts
36
+ uses: actions/upload-artifact@v1
37
+ with:
38
+ name: mybook
39
+ path: tmp/mybook.epub
data/.gitignore CHANGED
@@ -5,11 +5,11 @@
5
5
  /doc/
6
6
  /pkg/
7
7
  /spec/reports/
8
- /tmp/
8
+ tmp/
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  .rakeTasks
13
13
  .idea
14
14
 
15
- *.gem
15
+ *.gem
@@ -0,0 +1 @@
1
+ 2.5.5
data/Gemfile CHANGED
@@ -5,3 +5,4 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "rspec", "~> 3.0"
8
+ gem 'aruba', '~> 1.0.2'
@@ -1,15 +1,74 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- review-retrovert (0.3.3)
4
+ review-retrovert (0.3.4)
5
5
  review (>= 3.2.0, < 4.0)
6
6
  thor
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
+ activesupport (6.0.3.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2, >= 2.2.2)
17
+ aruba (1.0.2)
18
+ childprocess (>= 2.0, < 5.0)
19
+ contracts (~> 0.16.0)
20
+ cucumber (>= 2.4, < 5.0)
21
+ ffi (~> 1.9)
22
+ rspec-expectations (~> 3.4)
23
+ thor (~> 1.0)
24
+ builder (3.2.4)
25
+ childprocess (4.0.0)
26
+ concurrent-ruby (1.1.6)
27
+ contracts (0.16.0)
28
+ cucumber (4.1.0)
29
+ builder (~> 3.2, >= 3.2.3)
30
+ cucumber-core (~> 7.1, >= 7.1.0)
31
+ cucumber-create-meta (~> 1.0.0, >= 1.0.0)
32
+ cucumber-cucumber-expressions (~> 10.1, >= 10.1.0)
33
+ cucumber-gherkin (~> 14.0, >= 14.0.1)
34
+ cucumber-html-formatter (~> 7.0, >= 7.0.0)
35
+ cucumber-messages (~> 12.2, >= 12.2.0)
36
+ cucumber-wire (~> 3.1, >= 3.1.0)
37
+ diff-lcs (~> 1.3, >= 1.3, < 1.4)
38
+ multi_test (~> 0.1, >= 0.1.2)
39
+ sys-uname (~> 1.0, >= 1.0.2)
40
+ cucumber-core (7.1.0)
41
+ cucumber-gherkin (~> 14.0, >= 14.0.1)
42
+ cucumber-messages (~> 12.2, >= 12.2.0)
43
+ cucumber-tag-expressions (~> 2.0, >= 2.0.4)
44
+ cucumber-create-meta (1.0.0)
45
+ cucumber-messages (~> 12.2, >= 12.2.0)
46
+ sys-uname (~> 1.2, >= 1.2.1)
47
+ cucumber-cucumber-expressions (10.2.2)
48
+ cucumber-gherkin (14.2.0)
49
+ cucumber-messages (~> 12.4, >= 12.4.0)
50
+ cucumber-html-formatter (7.2.0)
51
+ cucumber-messages (~> 12.4, >= 12.4.0)
52
+ cucumber-messages (12.4.0)
53
+ protobuf-cucumber (~> 3.10, >= 3.10.8)
54
+ cucumber-tag-expressions (2.0.4)
55
+ cucumber-wire (3.1.0)
56
+ cucumber-core (~> 7.1, >= 7.1.0)
57
+ cucumber-cucumber-expressions (~> 10.1, >= 10.1.0)
58
+ cucumber-messages (~> 12.2, >= 12.2.0)
11
59
  diff-lcs (1.3)
60
+ ffi (1.13.1)
61
+ i18n (1.8.5)
62
+ concurrent-ruby (~> 1.0)
12
63
  image_size (2.0.2)
64
+ middleware (0.1.0)
65
+ minitest (5.14.1)
66
+ multi_test (0.1.2)
67
+ protobuf-cucumber (3.10.8)
68
+ activesupport (>= 3.2)
69
+ middleware
70
+ thor
71
+ thread_safe
13
72
  rake (12.3.3)
14
73
  review (3.2.0)
15
74
  image_size
@@ -30,12 +89,19 @@ GEM
30
89
  rspec-support (~> 3.9.0)
31
90
  rspec-support (3.9.2)
32
91
  rubyzip (2.3.0)
92
+ sys-uname (1.2.1)
93
+ ffi (>= 1.0.0)
33
94
  thor (1.0.1)
95
+ thread_safe (0.3.6)
96
+ tzinfo (1.2.7)
97
+ thread_safe (~> 0.1)
98
+ zeitwerk (2.4.0)
34
99
 
35
100
  PLATFORMS
36
101
  ruby
37
102
 
38
103
  DEPENDENCIES
104
+ aruba (~> 1.0.2)
39
105
  rake (~> 12.0)
40
106
  review-retrovert!
41
107
  rspec (~> 3.0)
data/README.md CHANGED
@@ -4,6 +4,8 @@
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
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -22,7 +24,9 @@ Or install it yourself as:
22
24
 
23
25
  ## Usage
24
26
 
25
- TODO: Write usage instructions here
27
+ ```sh
28
+ review-retrovert convert /path/to/dir/review-starter/config.yml <output directory>
29
+ ```
26
30
 
27
31
  ## Development
28
32
 
@@ -34,10 +38,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
34
38
 
35
39
  Bug reports and pull requests are welcome on GitHub at https://github.com/srz-zumix/review-retrovert.
36
40
 
37
-
38
41
  ## Develop
39
42
 
40
- docker run -it --rm -v $(pwd)/../:/github vvakame/review:3.2 bash
43
+ docker run -it --rm -v $(pwd)/:/work -w /work vvakame/review:3.2 bash
41
44
 
42
45
  ## License
43
46
 
@@ -69,8 +69,31 @@ module ReVIEW
69
69
  @configs.rewrite_yml('texstyle', '["reviewmacro"]')
70
70
  end
71
71
 
72
- def replace_inline_command(content, command, sub)
72
+ def replace_compatible_block_command_outline(content, command, new_command, option_count)
73
+ content.gsub!(/^\/\/#{command}(?<option>(\[[^\r\n]*?\]){0,#{option_count}})(\[[^\r\n]*\])*{(?<inner>.*?)\/\/}/m, "//#{new_command}\\k<option>{\\k<inner>//}")
74
+ end
75
+
76
+ def replace_compatible_block_command_to_outside(content, command, new_command, option_count, add_options="", new_body="")
77
+ body = new_body
78
+ body += '\n' unless body.empty?
79
+ content.gsub!(/^\/\/#{command}(?<option>(\[[^\r\n]*?\]){0,#{option_count}})(\[[^\r\n]*\])*{(?<inner>.*?)\/\/}/m, "//#{new_command}\\k<option>#{add_options}{\n#{new_body}//}\\k<inner>")
80
+ end
81
+
82
+ def replace_block_command_outline(content, command, new_command, use_option)
83
+ if use_option
84
+ content.gsub!(/^\/\/#{command}(?<option>\[[^\r\n]*\])*{(?<inner>.*?)\/\/}/m, "//#{new_command}\\k<option>{\\k<inner>//}")
85
+ else
86
+ content.gsub!(/^\/\/#{command}(?<option>\[[^\r\n]*?\])*{(?<inner>.*?)\/\/}/m, "//#{new_command}{\\k<inner>//}")
87
+ end
88
+ end
73
89
 
90
+ def delete_block_command_outer(content, command)
91
+ content.gsub!(/^\/\/#{command}(\[[^\r\n]*?\])*{(?<inner>.*?)\/\/}\R/m, '\k<inner>')
92
+ end
93
+
94
+ def delete_block_command(content, command)
95
+ content.gsub!(/^\/\/#{command}(\[[^\r\n]*?\])*{.*?\/\/}\R/m, '')
96
+ content.gsub!(/^\/\/#{command}(\[.*?\])*\s*\R/, '')
74
97
  end
75
98
 
76
99
  def delete_inline_command(content, command)
@@ -78,6 +101,156 @@ module ReVIEW
78
101
  content.gsub!(/@<#{command}>(?:(\$)|(?:({)|(\|)))((?:.*@<\w*>[\|${].*?[\|$}].*?|.*?)*)(?(1)(\$)|(?(2)(})|(\|)))/){"#{$4}"}
79
102
  end
80
103
 
104
+ def replace_inline_command(content, command, new_command)
105
+ content.gsub!(/@<#{command}>/, "@<#{new_command}>")
106
+ end
107
+
108
+ def replace_block_command_nested_boxed_article(content, box)
109
+ found = false
110
+ content.dup.scan(/(^\/\/#{box})(\[[^\r\n]*?\])*(?:(\$)|(?:({)|(\|)))(.*?)(^\/\/)(?(3)(\$)|(?(4)(})|(\|)).*?[\r\n]+)/m) { |m|
111
+ matched = m[0..-1].join
112
+ inner = m[5]
113
+ im = inner.match(/^\/\/(\w+)((\[.*?\])*)([$|{])/)
114
+ unless im.nil?
115
+ inner_cmd = im[1]
116
+ inner_open = im[4]
117
+ inner_opts = im[2]
118
+ first_opt = inner_opts.match(/^\[(.*?)\]/)[1]
119
+
120
+ is_commentout = true
121
+ unless first_opt.empty?
122
+ if inner.match(/@<.*?>[$|{]#{first_opt}/)
123
+ is_commentout = false
124
+ end
125
+ end
126
+ cmd_begin = m[0..4].join
127
+ cmd_end = m[6..-1].join
128
+ # check other fence inner block (block command has fence??)
129
+ if inner_open == m[2..4].join
130
+ # if same fence then cmd_end == inner_end
131
+ if is_commentout
132
+ inner.gsub!(/(^\/\/(\w+\[.*?\])*#{inner_open})/, '#@#\1')
133
+ content.gsub!(/#{Regexp.escape(matched)}/m, "#{cmd_begin}#{inner}#@##{cmd_end}")
134
+ else
135
+ imb = inner.match(/(\R((^\/\/\w+(\[.*?\])*)\s*)*^\/\/\w+\[#{first_opt}\](\[.*?\])*#{inner_open}.*)\R/m)
136
+ to_out_block = imb[1]
137
+ inner.gsub!(/#{Regexp.escape(to_out_block)}/m, '')
138
+ content.gsub!(/#{Regexp.escape(matched)}/m, "#{cmd_begin}#{inner}#{cmd_end}#{to_out_block}")
139
+ end
140
+ else
141
+ close = inner_open == '{' ? '}' : inner_open
142
+ if is_commentout
143
+ inner.gsub!(/(^\/\/(\w+\[.*?\])*#{inner_open})(.*?)(^\/\/#{close})/m, '#@#\1\2#@#\3')
144
+ content.gsub!(/#{Regexp.escape(matched)}/m, "#{cmd_begin}#{inner}#{cmd_end}")
145
+ else
146
+ imb = inner.match(/\R((^\/\/\w+(\[.*?\])*)\s*)*^\/\/(\w+)\[#{first_opt}\](\[[^\r\n]*?\])*(?:(\$)|(?:({)|(\|)))(.*?)(^\/\/)(?(3)(\$)|(?(4)(})|(\|)))/m)
147
+ to_out_block = imb[0]
148
+ inner.gsub!(/#{Regexp.escape(to_out_block)}/m, '')
149
+ content.gsub!(/#{Regexp.escape(matched)}/m, "#{cmd_begin}#{inner}#{cmd_end}#{to_out_block}")
150
+ end
151
+ end
152
+ found = true
153
+ end
154
+ }
155
+ if found
156
+ replace_block_command_nested_boxed_article(content, box)
157
+ end
158
+ end
159
+
160
+ def replace_block_command_nested_boxed_articles(content)
161
+ replace_block_command_nested_boxed_article(content, 'note')
162
+ replace_block_command_nested_boxed_article(content, 'memo')
163
+ replace_block_command_nested_boxed_article(content, 'tip')
164
+ replace_block_command_nested_boxed_article(content, 'info')
165
+ replace_block_command_nested_boxed_article(content, 'warning')
166
+ replace_block_command_nested_boxed_article(content, 'important')
167
+ replace_block_command_nested_boxed_article(content, 'caution')
168
+ replace_block_command_nested_boxed_article(content, 'notice')
169
+ end
170
+
171
+ def replace_block_commentout(content)
172
+ d = content.dup
173
+ d.gsub!(/(^\/\/sampleoutputbegin\[)(.*?)(\])(.*?)(^\/\/sampleoutputend)/m, '')
174
+ d.scan(/(^#@)(\++)(.*?)(^#@)(-+)/m) { |m|
175
+ matched = m[0..-1].join
176
+ inner = m[2]
177
+ inner.gsub!(/(^.)/, '#@#\1')
178
+ content.gsub!(/#{Regexp.escape(matched)}/m, "#@##{m[1]}#{inner}#@##{m[4]}")
179
+ }
180
+ end
181
+
182
+ def replace_sampleoutput(content)
183
+ replace_block_commentout(content)
184
+ content.dup.scan(/(^\/\/sampleoutputbegin\[)(.*?)(\].*?\R)(.*?)(^\/\/sampleoutputend)/m) { |m|
185
+ matched = m[0..-1].join
186
+ sampleoutputbegin = m[0..2].join
187
+ sampleoutputend = m[4]
188
+ option = m[1]
189
+ inner = m[3]
190
+ # inner.gsub!(/^\/\//, '//@<nop>{}')
191
+ content.gsub!(/#{Regexp.escape(matched)}/m, "#{option}\n#@##{sampleoutputbegin}#{inner}#@##{sampleoutputend}")
192
+ }
193
+ end
194
+
195
+ def replace_auto_ids(content, command, require_option_count)
196
+ index = -1
197
+ content.gsub!(/^\/\/#{command}\[(|\?)\]/) { |s| index += 1; "//#{command}[starter_auto_id_#{command}_#{index}]" }
198
+ if require_option_count > 0
199
+ while !content.gsub!(/(^\/\/#{command}(\[[^\[\]]*?\]){0,#{require_option_count-1}})($|{)/, '\1[]\3').nil?
200
+ end
201
+ end
202
+ end
203
+
204
+ def remove_starter_refid(content)
205
+ # note - noteref
206
+ content.dup.scan(/(@<noteref>)(?:(\$)|(?:({)|(\|)))(.*?)(?(2)(\$)|(?(3)(})|(\|)))/) { |m|
207
+ matched = m[0..-1].join
208
+ ref = m[4]
209
+ n = content.match(/^\/\/note\[#{ref}\](\[.*?\])/)
210
+ unless n.nil?
211
+ content.gsub!(/#{Regexp.escape(matched)}/, n[1])
212
+ content.gsub!(/^\/\/note\[#{ref}\](\[.*?\])/, '//note\1')
213
+ else
214
+ # content.gsub!(/#{Regexp.escape(matched)}/, "noteref<#{ref}>")
215
+ end
216
+ }
217
+ end
218
+
219
+ def remove_starter_options(content)
220
+ # image border
221
+ content.gsub!(/(^\/\/image\[.*?\]\[.*?\]\[.*?)((,|)border=[^,\]]*)(.*?\])/, '\1\4')
222
+ # list lineno
223
+ content.gsub!(/(^\/\/list\[.*?\]\[.*?\]\[.*?)((,|)lineno=[^,\]]*)(.*?\])/, '\1\4')
224
+ end
225
+
226
+ def expand_nested_inline_command(content)
227
+ found = false
228
+ content.dup.scan(/(@<.*?>)(?:(\$)|(?:({)|(\|)))(.*?)(?(2)(\$)|(?(3)(})|(\|)))/) { |m|
229
+ matched = m.join
230
+ body = m[4]
231
+ im = body.match(/(.*)(@<.*?>)(?:(\$)|(?:({)|(\|)))(.*?)(?(3)(\$)|(?(4)(})|(\|)))(.*)/)
232
+ if im.nil?
233
+ im = body.match(/(.*)(@<.*?>)#{m[1..3].join}/)
234
+ unless im.nil?
235
+ outcmd_begin = m[0] + "$|{".gsub(m[1..3].join, '')
236
+ outcmd_end = "$|}".gsub(m[5..7].join, '')
237
+ rep = "#{outcmd_begin}#{body}#{outcmd_end}"
238
+ content.gsub!(matched, rep)
239
+ found = true
240
+ end
241
+ else
242
+ outcmd_begin = m[0..3].join
243
+ outcmd_end = m[5..7].join
244
+ rep = "#{outcmd_begin}#{im[1]}#{outcmd_end}#{im[2..9].join}#{outcmd_begin}#{im[-1]}#{outcmd_end}"
245
+ content.gsub!(matched, rep)
246
+ found = true
247
+ end
248
+ }
249
+ if found
250
+ expand_nested_inline_command(content)
251
+ end
252
+ end
253
+
81
254
  def copy_embedded_contents(outdir, content)
82
255
  content.scan(/\#@mapfile\((.*?)\)/).each do |filepath|
83
256
  srcpath = File.join(@basedir, filepath)
@@ -93,8 +266,6 @@ module ReVIEW
93
266
  def update_content(outdir, contentfile)
94
267
  info contentfile
95
268
  content = File.read(contentfile)
96
- content.gsub!(/(\/\/sideimage\[.*?\]\[.*?\])\[.*?\]/, '\1')
97
- content.gsub!(/\/\/sideimage/, '//image')
98
269
  content.gsub!(/@<href>{(.*?)#.*?,(.*?)}/, '@<href>{\1,\2}')
99
270
  content.gsub!(/@<href>{(.*?)#.*?}/, '@<href>{\1}')
100
271
  # table 内の @ コマンドは不安定らしい
@@ -103,8 +274,62 @@ module ReVIEW
103
274
  # 空セルが2行になることがあるらしい
104
275
  while !content.gsub!(/(\/\/table.*\s)\.(\s.*?\/\/})/m, "\\1#{@table_empty_replace}\\2").nil? do
105
276
  end
106
- delete_inline_command(content , 'xsmall')
107
- delete_inline_command(content , 'weak')
277
+ # Re:VIEW Starter commands
278
+ replace_compatible_block_command_outline(content, 'terminal', 'cmd', 1)
279
+ replace_compatible_block_command_to_outside(content, 'sideimage', 'image', 1, '[]')
280
+ replace_block_command_outline(content, 'abstract', 'lead', true)
281
+ delete_block_command(content, 'needvspace')
282
+ delete_block_command(content, 'clearpage')
283
+ delete_block_command(content, 'flushright')
284
+ delete_block_command(content, 'centering')
285
+ delete_block_command(content, 'noindent')
286
+ delete_block_command(content, 'paragraphend')
287
+
288
+ replace_inline_command(content, 'secref', 'hd')
289
+ replace_inline_command(content, 'file', 'kw')
290
+ replace_inline_command(content, 'hlink', 'href')
291
+ replace_inline_command(content, 'B', 'strong')
292
+ delete_inline_command(content, 'userinput')
293
+ delete_inline_command(content, 'weak')
294
+ delete_inline_command(content, 'cursor')
295
+ # font size
296
+ delete_inline_command(content, 'small')
297
+ delete_inline_command(content, 'xsmall')
298
+ delete_inline_command(content, 'xxsmall')
299
+ delete_inline_command(content, 'large')
300
+ delete_inline_command(content, 'xlarge')
301
+ delete_inline_command(content, 'xxlarge')
302
+
303
+ # fixed lack of options
304
+ content.gsub!(/^\/\/list{/, '//list[][]{')
305
+
306
+ # special command
307
+ replace_sampleoutput(content)
308
+
309
+ # nested command
310
+ replace_block_command_nested_boxed_articles(content)
311
+
312
+ # empty ids
313
+ replace_auto_ids(content, 'list', 2)
314
+ replace_auto_ids(content, 'listnum', 2)
315
+
316
+ # remove starter extension
317
+ remove_starter_refid(content)
318
+ remove_starter_options(content)
319
+
320
+ # special charactor
321
+ content.gsub!('@<LaTeX>{}', 'LaTeX')
322
+ content.gsub!('@<TeX>{}', 'TeX')
323
+ content.gsub!('@<hearts>{}', '!HEART!')
324
+
325
+ # nop replace must be last step
326
+ content.gsub!('@<nop>$$', '@<b>$$')
327
+ content.gsub!('@<nop>||', '@<b>||')
328
+ content.gsub!('@<nop>{}', '@<b>{}')
329
+
330
+ # expand nested inline command
331
+ expand_nested_inline_command(content)
332
+
108
333
  File.write(contentfile, content)
109
334
  copy_embedded_contents(outdir, content)
110
335
  end
@@ -128,7 +353,7 @@ module ReVIEW
128
353
  yamlfile = @config['catalogfile']
129
354
  abspath = File.absolute_path(outdir)
130
355
  contentdir = abspath
131
- info 'replace //sideimage to //image'
356
+ info 'replace starter block command'
132
357
  info 'replace starter inline command'
133
358
  if options['strict']
134
359
  catalog = ReVIEW::Catalog.new(File.open(File.join(abspath, yamlfile)))