review-retrovert 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/review/retrovert/converter.rb +87 -19
- data/lib/review/retrovert/version.rb +1 -1
- data/testdata/mybook/config-retrovert.yml +9 -0
- data/testdata/mybook/contents/r0-root.re +24 -2
- data/testdata/mybook/contents/table.csv +4 -0
- data/testdata/mybook/contents/test.txt +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d9d91f7b09b23b82d592e511474884b0fa179c39c0ee008a7aad2c69435ddb
|
4
|
+
data.tar.gz: 2f72ede1612ddcc17733fbffa6cab7e9acd1479de4d74f04f6e91af3b0de67bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e37f04cfa04cdaf146ec9b4db1ac784c2f94f372d43ea43adb2ce451ea01191cb90ad3c2307d6acd405b75178bd5d996e29d292cef6f34235a6e682c7b04fad
|
7
|
+
data.tar.gz: 86f95748aaf68ff476af88c72dd2ab7ac095c92a0f96c2c66ae280b56b5438b20840c01e45d89a1d14bdb8e4ccc43ea21d3dad208c14dc876b5474c825deff05
|
data/Gemfile.lock
CHANGED
@@ -127,15 +127,17 @@ module ReVIEW
|
|
127
127
|
|
128
128
|
# words
|
129
129
|
words_files = @config['words_file']
|
130
|
-
if words_files
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
if words_files
|
131
|
+
if words_files.is_a?(Array)
|
132
|
+
new_words_files = []
|
133
|
+
words_files.each do |words_file|
|
134
|
+
new_words_files.push copy_wards(outdir, words_file)
|
135
|
+
end
|
136
|
+
@configs.rewrite_yml('words_file', "[#{new_words_files.join(',')}]")
|
137
|
+
else
|
138
|
+
new_words_file = copy_wards(outdir, words_files)
|
139
|
+
@configs.rewrite_yml('words_file', new_words_file)
|
134
140
|
end
|
135
|
-
@configs.rewrite_yml('words_file', "[#{new_words_files.join(',')}]")
|
136
|
-
else
|
137
|
-
new_words_file = copy_wards(outdir, words_files)
|
138
|
-
@configs.rewrite_yml('words_file', new_words_file)
|
139
141
|
end
|
140
142
|
|
141
143
|
# makeindex_dic
|
@@ -173,6 +175,12 @@ module ReVIEW
|
|
173
175
|
replace_compatible_block_command_outline(content, cmd, cmd, max_option_num)
|
174
176
|
end
|
175
177
|
|
178
|
+
def exclude_exta_options(content, commands, max_option_num)
|
179
|
+
commands.each do |cmd|
|
180
|
+
exclude_exta_option(content, cmd, max_option_num)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
176
184
|
def starter_caption_to_text(content, command, n)
|
177
185
|
content.gsub!(/^\/\/#{command}(?<option>(\[[^\r\n]*?\]){0,#{n-1}})\[(?<caption>#{@r_option_inner})\](?<post>.*)$/, "\\k<caption>\n//#{command}\\k<option>\\k<post>")
|
178
186
|
end
|
@@ -368,7 +376,13 @@ module ReVIEW
|
|
368
376
|
end
|
369
377
|
|
370
378
|
def remove_option_param(content, commands, n, param)
|
371
|
-
content.gsub!(/(
|
379
|
+
content.gsub!(/(^\/\/(#{commands.join('|')})(\[.*?\]){#{n-1}}\[.*?)((,|)\s*#{param}=[^,\]]*)(.*?\])/) {
|
380
|
+
prev = $1
|
381
|
+
cmd = $2
|
382
|
+
opt = $4
|
383
|
+
post = $6
|
384
|
+
"#{prev}#{post}"
|
385
|
+
}
|
372
386
|
end
|
373
387
|
|
374
388
|
def remove_starter_options(content)
|
@@ -385,7 +399,7 @@ module ReVIEW
|
|
385
399
|
# image pos
|
386
400
|
remove_option_param(content, ["image"], 3, "pos")
|
387
401
|
# list lineno
|
388
|
-
remove_option_param(content, ["list"], 3, "lineno")
|
402
|
+
remove_option_param(content, ["list", "listnum"], 3, "lineno")
|
389
403
|
end
|
390
404
|
|
391
405
|
# talklist to //#{cmd}[]{ //emlist[]{}... }
|
@@ -429,7 +443,36 @@ module ReVIEW
|
|
429
443
|
replace_block_command_nested_boxed_article(content, 'emlist')
|
430
444
|
end
|
431
445
|
|
432
|
-
def
|
446
|
+
def replace_file_option(content, matched, fence_open, option)
|
447
|
+
file_param_m = option.match(/\s*file\s*=\s*([^,\]]*)/)
|
448
|
+
if file_param_m
|
449
|
+
fence_close = ReViewDef::fence_close(fence_open)
|
450
|
+
filepath = file_param_m[1]
|
451
|
+
if fence_close
|
452
|
+
content.gsub!(/#{Regexp.escape(matched)}(.*?)^\/\/#{fence_close}/m) {
|
453
|
+
"#{matched}\n\#@mapfile(#{filepath})\n\#@end\n//#{fence_close}"
|
454
|
+
}
|
455
|
+
end
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
def convert_starter_option(content)
|
460
|
+
# file
|
461
|
+
r = /^(?<matched>\/\/(list|listnum|table)\[#{@r_option_inner}\]\[#{@r_option_inner}\]\[(?<options>#{@r_option_inner})\](?<open>.))$/
|
462
|
+
content.dup.scan(r) { |m|
|
463
|
+
matched = m[0]
|
464
|
+
options = m[1]
|
465
|
+
fence_open = m[2]
|
466
|
+
options.split(',').each { |option|
|
467
|
+
replace_file_option(content, matched, fence_open, option)
|
468
|
+
}
|
469
|
+
}
|
470
|
+
remove_option_param(content, ["list", "listnum", "table"], 3, "file")
|
471
|
+
# csv
|
472
|
+
convert_csv_option(content)
|
473
|
+
end
|
474
|
+
|
475
|
+
def convert_csv_option(content)
|
433
476
|
r_table = /^(?<matched>\/\/table\[#{@r_option_inner}\]\[#{@r_option_inner}\]\[(?<options>#{@r_option_inner})\](?<open>.))$/
|
434
477
|
content.dup.scan(r_table) { |m|
|
435
478
|
matched = m[0]
|
@@ -457,8 +500,16 @@ module ReVIEW
|
|
457
500
|
end
|
458
501
|
content.gsub!(outer, "#{matched}#{new_header}#{sep}#{new_body}//#{close}")
|
459
502
|
else
|
503
|
+
im = inner.match(/^\#@mapfile\((.*?)\)\R^\#@end/m)
|
504
|
+
if im
|
505
|
+
inner_file = im[1]
|
506
|
+
csv_text = "\n"
|
507
|
+
csv_text += File.open(File.join(@basedir, inner_file)).read()
|
508
|
+
else
|
509
|
+
csv_text = inner
|
510
|
+
end
|
460
511
|
new_body = ""
|
461
|
-
CSV.parse(
|
512
|
+
CSV.parse(csv_text) do |c|
|
462
513
|
new_body += Utils::GenerateTsv(c)
|
463
514
|
end
|
464
515
|
content.gsub!(outer, "#{matched}#{new_body}//#{close}")
|
@@ -479,13 +530,17 @@ module ReVIEW
|
|
479
530
|
end
|
480
531
|
|
481
532
|
def copy_embedded_contents(outdir, content)
|
482
|
-
content.scan(/\#@mapfile\((.*?)\)/).each do |
|
533
|
+
content.scan(/\#@mapfile\((.*?)\)/).each do |filepath_|
|
534
|
+
filepath = filepath_[0]
|
535
|
+
if filepath.blank?
|
536
|
+
next
|
537
|
+
end
|
483
538
|
srcpath = File.join(@basedir, filepath)
|
484
539
|
if File.exist?(srcpath)
|
485
540
|
outpath = File.join(File.absolute_path(outdir), filepath)
|
486
541
|
FileUtils.mkdir_p(File.dirname(outpath))
|
487
542
|
FileUtils.cp(srcpath, outpath)
|
488
|
-
@embeded_contents.push(filepath
|
543
|
+
@embeded_contents.push(filepath)
|
489
544
|
update_content(outpath, outpath)
|
490
545
|
end
|
491
546
|
end
|
@@ -535,13 +590,19 @@ module ReVIEW
|
|
535
590
|
delete_block_command_outer(content, 'centering')
|
536
591
|
|
537
592
|
# convert starter option
|
538
|
-
|
593
|
+
convert_starter_option(content)
|
539
594
|
|
540
595
|
# delete starter option
|
541
596
|
# exclude_exta_option(content, 'cmd', 0)
|
542
597
|
starter_caption_to_text(content, 'cmd', 1)
|
543
|
-
|
544
|
-
|
598
|
+
exclude_exta_options(content, [
|
599
|
+
'imgtable',
|
600
|
+
'table',
|
601
|
+
# list/listnum の第3引数は言語指定だが、Starter の第3引数と全く異なるため 2 引数にしている
|
602
|
+
# Starter 側が言語指定対応したら修正
|
603
|
+
'list',
|
604
|
+
'listnum',
|
605
|
+
], 2)
|
545
606
|
# exclude_exta_option(content, 'tsize', 1)
|
546
607
|
replace_tsize(content)
|
547
608
|
|
@@ -554,6 +615,8 @@ module ReVIEW
|
|
554
615
|
content.gsub!(/^\/\/chapterauthor\[(.*?)\]/, "//lead{\n\\1\n//}")
|
555
616
|
# talklist/desclist
|
556
617
|
starter_list_to_nested_contents_list(content)
|
618
|
+
# empty caption imaget to indepimage
|
619
|
+
content.gsub!(/^\/\/image(\[#{@r_option_inner}\]\[\].*)$/, '//indepimage\1')
|
557
620
|
end
|
558
621
|
|
559
622
|
def delete_inline_command(content, command)
|
@@ -718,8 +781,13 @@ module ReVIEW
|
|
718
781
|
|
719
782
|
if @ird
|
720
783
|
# br to blankline
|
721
|
-
content.gsub!(/(
|
722
|
-
|
784
|
+
content.gsub!(/(^\/\/footnote\[.*?\]\[.*?)((.*?@<br>({}|\$\$|\|\|)){1,})(.*\])$/) { |m|
|
785
|
+
m.gsub(/@<br>({}|\$\$|\|\|)/, '@<fnbr>\1')
|
786
|
+
}
|
787
|
+
|
788
|
+
content.gsub!(/(.*)@<br>({}|\$\$|\|\|)$/, "\\1\n\n")
|
789
|
+
content.gsub!(/(.*)@<br>({}|\$\$|\|\|)(.*)$/, "\\1\n\n\\2")
|
790
|
+
content.gsub!(/@<fnbr>({}|\$\$|\|\|)/, '@<br>\1')
|
723
791
|
end
|
724
792
|
|
725
793
|
# nop replace must be last step
|
@@ -5,3 +5,12 @@
|
|
5
5
|
# 上記のようにすることで retrovert 後のプロジェクトでのみ設定を上書きできます
|
6
6
|
retrovert:
|
7
7
|
chapterlink: null
|
8
|
+
|
9
|
+
# ソースコードハイライトを利用する (rouge,pygmentsには外部gemが必要)
|
10
|
+
highlight:
|
11
|
+
# html: "rouge"
|
12
|
+
# 「×」が Package inputenc Error: Invalid UTF-8 byte sequence. になるので有効にしない
|
13
|
+
# latex: "listings"
|
14
|
+
# \ などがエスケープされないためエラーになる
|
15
|
+
# latex: "rouge"
|
16
|
+
# latex: "pygments"
|
@@ -1,9 +1,31 @@
|
|
1
1
|
= Retrovert テスト用
|
2
2
|
|
3
|
+
//blankline
|
4
|
+
|
5
|
+
test@<br>{}
|
6
|
+
|
7
|
+
== テスト
|
8
|
+
|
9
|
+
=== File
|
10
|
+
|
3
11
|
#@mapfile(contents/r0-inner.re)
|
4
12
|
#@end
|
5
13
|
|
6
|
-
//
|
14
|
+
//list[][][file=contents/test.txt]{
|
15
|
+
//}
|
7
16
|
|
8
|
-
|
17
|
+
//table[][][csv=on,file=contents/table.csv]{
|
18
|
+
//}
|
19
|
+
|
20
|
+
=== コマンド
|
21
|
+
|
22
|
+
===={subsubtest} Secref テスト用
|
23
|
+
|
24
|
+
secref: @<secref>{subsubtest}
|
25
|
+
secref: @<secref>{r0-root|subsubtest}
|
26
|
+
secref: @<secref>{01-install|RubyとTeXLiveのインストール}
|
27
|
+
#@# secref: @<secref>{01-install|Rubyのインストール}
|
28
|
+
|
29
|
+
==== footnote bar
|
9
30
|
|
31
|
+
//footnote[fnbar][test@<br>{}hoge]
|
@@ -0,0 +1 @@
|
|
1
|
+
TestText-250c8d96-1d5d-434c-a43f-7dc3ad5a588b
|
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.9
|
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-07-
|
11
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -161,6 +161,8 @@ files:
|
|
161
161
|
- testdata/mybook/contents/99-postface.re
|
162
162
|
- testdata/mybook/contents/r0-inner.re
|
163
163
|
- testdata/mybook/contents/r0-root.re
|
164
|
+
- testdata/mybook/contents/table.csv
|
165
|
+
- testdata/mybook/contents/test.txt
|
164
166
|
- testdata/mybook/css/normalize.css
|
165
167
|
- testdata/mybook/css/webstyle.css
|
166
168
|
- testdata/mybook/data/terms.txt
|