nb_util 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/.DS_Store +0 -0
- data/lib/data/thesis/thesis.tex +9 -3
- data/lib/nb_util/ipynb2tex.rb +65 -57
- data/lib/nb_util/version.rb +1 -1
- data/nb_util.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92eec37d4cc03123b3f8e76f953041a5ce035bdadd4d612dd3b5d8c8b4608da4
|
4
|
+
data.tar.gz: c43039b7b4dc1a6978cb6cc00930b4f9a8dbd8dafd616eb57f9be37ec10babf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c827fa8512622ba9ffe0488ecfe603749f8dc0c033a12e71abbefb52bd7874a400016ddd5fd21eca0b96d50bea62c66047165b5e7174f83ea84abb28621411d4
|
7
|
+
data.tar.gz: 3c809decb9c9cac0852f69b77d2e629d609019d9debb788aa039ffea795a5956e3f724c98595688294eafdafb9b981c894cd5e7a41cb76407bdb94156f4de8a1
|
data/lib/.DS_Store
CHANGED
Binary file
|
data/lib/data/thesis/thesis.tex
CHANGED
@@ -4,15 +4,21 @@
|
|
4
4
|
\input{../thesis_pieces/usepackage}% pieces
|
5
5
|
\input{../thesis_pieces/form00_style}% pieces
|
6
6
|
\input{../thesis_pieces/tightlist_setting}% pieces
|
7
|
-
|
7
|
+
%参考文献の設定============================================================
|
8
8
|
\renewcommand{\bibname}{参考文献}
|
9
9
|
|
10
|
-
|
10
|
+
%表紙=====================================================================
|
11
11
|
\input{../split_files/informations/informations}
|
12
12
|
|
13
|
-
|
13
|
+
%目次=====================================================================
|
14
14
|
\tableofcontents
|
15
15
|
|
16
|
+
% 表目次の表示==============================================================
|
17
|
+
\listoftables
|
18
|
+
|
19
|
+
% 図目次の表示==============================================================
|
20
|
+
\listoffigures
|
21
|
+
|
16
22
|
%本文======================================================================
|
17
23
|
\input{./.splits_location.tex}
|
18
24
|
|
data/lib/nb_util/ipynb2tex.rb
CHANGED
@@ -69,6 +69,7 @@ module NbUtil
|
|
69
69
|
|
70
70
|
mk_latex_and_mv_to_latex(target, target_parent, "thesis")
|
71
71
|
Open3.capture3("open #{target_parent}")
|
72
|
+
# p File.join(target_parent,"mk_latex/thesis")
|
72
73
|
Open3.capture3("open #{target_parent}/mk_latex/thesis/thesis.tex/")
|
73
74
|
|
74
75
|
exit
|
@@ -81,63 +82,70 @@ module NbUtil
|
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
85
|
+
def ipynb2tex_handout(target)
|
86
|
+
loop do
|
87
|
+
target_parent = File.dirname(target)
|
88
|
+
exist_info = File.join(target_parent, 'mk_latex/split_files/informations/informations.tex')
|
89
|
+
if File.exist?(exist_info)
|
90
|
+
FileUtils.mkdir_p(target_parent + '/split_files/informations')
|
91
|
+
FileUtils.cp(exist_info, target_parent)
|
92
|
+
else
|
93
|
+
your_informations(ARGV[1], "handout")
|
94
|
+
end
|
95
|
+
print "Are you ok with it?: "
|
96
|
+
input = STDIN.gets.to_s.chomp
|
97
|
+
if input == 'Y' || input == 'y'
|
98
|
+
location = Open3.capture3("gem environment gemdir")
|
99
|
+
versions = Open3.capture3("gem list nb_util")
|
100
|
+
latest_version = versions[0].split(",")
|
101
|
+
cp_lib_data_handout_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/handout")
|
102
|
+
cp_lib_data_handout_pieces_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/handout_pieces")
|
103
|
+
cp_lib_data_handout_bundle = File.join(Dir.pwd, '/lib/data/handout')
|
104
|
+
cp_lib_data_handout_pieces_bundle = File.join(Dir.pwd, '/lib/data/handout_pieces')
|
105
|
+
re_fig = /(.+\.jpg)|(.+\.jpeg)|(.+\.png)/
|
98
106
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
107
|
+
print "\e[32minputfile: \e[0m"
|
108
|
+
target = File.expand_path(ARGV[1])
|
109
|
+
print "\e[32m#{target}\n\e[0m"
|
110
|
+
print "\e[32moutputfile: \e[0m"
|
111
|
+
tex_src = target.sub('.ipynb', '.tex')
|
112
|
+
print "\e[32m#{tex_src}\n\e[0m"
|
113
|
+
target_parent = File.dirname(target)
|
114
|
+
target_basename = File.basename(tex_src)
|
115
|
+
Open3.capture3("jupyter nbconvert --to latex #{target}")
|
116
|
+
lines = File.readlines(tex_src)
|
117
|
+
lines.each_with_index do |line, i|
|
118
|
+
line.sub!("\documentclass[11pt]{article}",
|
119
|
+
"\documentclass[11pt,dvipdfmx]{jsarticle}")
|
120
|
+
print "\e[32m#{line}\n\e[0m" if line =~ re_fig #redにする"\e[31m\e[0m"
|
121
|
+
line.sub!(line, '%' + line) if line.include?('.svg')
|
122
|
+
end
|
123
|
+
File.open(tex_src, 'w') { |file| file.print lines.join }
|
116
124
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
125
|
+
FileUtils.mkdir_p(target_parent + '/latex')
|
126
|
+
FileUtils.mv(tex_src, target_parent + '/latex')
|
127
|
+
replace_figs(File.join(target_parent + '/latex', target_basename), "handout")
|
128
|
+
revise_lines(File.join(target_parent + '/latex', target_basename))
|
129
|
+
split_files(File.join(target_parent + '/latex', target_basename), target, "handout")
|
130
|
+
FileUtils.mv(target_parent + '/tmp.tex', target_parent + '/split_files/tmp')
|
131
|
+
FileUtils.mv(target_parent + '/informations.tex', target_parent + '/split_files/informations')
|
132
|
+
mk_thesis_location(target, "handout")
|
133
|
+
FileUtils.mv(target_parent + '/.splits_location.tex', target_parent + '/handout')
|
126
134
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
+
mk_xbb(target, re_fig)
|
136
|
+
if Dir.exist?(cp_lib_data_handout_pieces_bundle.to_s) && Dir.exist?(cp_lib_data_handout_bundle.to_s)
|
137
|
+
FileUtils.cp_r(cp_lib_data_handout_pieces_bundle, target_parent)
|
138
|
+
FileUtils.cp_r(cp_lib_data_handout_bundle, target_parent)
|
139
|
+
else
|
140
|
+
FileUtils.cp_r(cp_lib_data_handout_pieces_gem, target_parent)
|
141
|
+
FileUtils.cp_r(cp_lib_data_handout_gem, target_parent)
|
142
|
+
end
|
135
143
|
|
136
|
-
|
137
|
-
|
138
|
-
|
144
|
+
mk_latex_and_mv_to_latex(target, target_parent, "handout")
|
145
|
+
Open3.capture3("open #{target_parent}")
|
146
|
+
Open3.capture3("open #{target_parent}/mk_latex/handout/handout.tex/")
|
139
147
|
|
140
|
-
|
148
|
+
exit
|
141
149
|
break
|
142
150
|
elsif input == 'N' || input == 'n'
|
143
151
|
target_parent = File.dirname(target)
|
@@ -210,7 +218,7 @@ module NbUtil
|
|
210
218
|
chapter_size = chapter.size
|
211
219
|
p chapter
|
212
220
|
for num in 0..chapter_size-1 do
|
213
|
-
splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num}")],
|
221
|
+
splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num+1}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num+1}")],
|
214
222
|
["\\begin{Verbatim}", target_parent + '/tmp.tex', FileUtils.mkdir_p(target_parent + '/split_files/tmp')]]
|
215
223
|
cont = File.read(target)
|
216
224
|
splitters.reverse.each do |splitter|
|
@@ -230,14 +238,14 @@ module NbUtil
|
|
230
238
|
end
|
231
239
|
end
|
232
240
|
end
|
233
|
-
FileUtils.mv(target_parent + "/chapter#{num}.tex", target_parent + "/split_files/chapter#{num}")
|
241
|
+
FileUtils.mv(target_parent + "/chapter#{num+1}.tex", target_parent + "/split_files/chapter#{num+1}")
|
234
242
|
end
|
235
243
|
end
|
236
244
|
|
237
245
|
if thesis_or_handout == "handout"
|
238
246
|
section_size = chapter.size
|
239
247
|
for num in 0..section_size-1 do
|
240
|
-
splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num}")],
|
248
|
+
splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num+1}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num+1}")],
|
241
249
|
["\\begin{Verbatim}", target_parent + '/tmp.tex', FileUtils.mkdir_p(target_parent + '/split_files/tmp')]]
|
242
250
|
cont = File.read(target)
|
243
251
|
splitters.reverse.each do |splitter|
|
@@ -253,7 +261,7 @@ module NbUtil
|
|
253
261
|
end
|
254
262
|
end
|
255
263
|
end
|
256
|
-
FileUtils.mv(target_parent + "/chapter#{num}.tex", target_parent + "/split_files/chapter#{num}")
|
264
|
+
FileUtils.mv(target_parent + "/chapter#{num+1}.tex", target_parent + "/split_files/chapter#{num+1}")
|
257
265
|
end
|
258
266
|
end
|
259
267
|
end
|
@@ -420,7 +428,7 @@ EOS
|
|
420
428
|
end
|
421
429
|
File.open(target_parent + '/.splits_location.tex', "w") do |f|
|
422
430
|
for num in 0..chapter_size-1 do
|
423
|
-
f.print("\\input{../split_files/chapter#{num}/chapter#{num}}\n")
|
431
|
+
f.print("\\input{../split_files/chapter#{num+1}/chapter#{num+1}}\n")
|
424
432
|
end
|
425
433
|
end
|
426
434
|
end
|
data/lib/nb_util/version.rb
CHANGED
data/nb_util.gemspec
CHANGED
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "bundler", "~> 1.16"
|
34
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
35
35
|
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
-
spec.
|
36
|
+
spec.add_dependency "thor"
|
37
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nb_util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masatoshi Kowaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|