hikiutils 0.2.3.12 → 0.2.3.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/hikiutils_bob/Rakefile +3 -2
  3. data/hikiutils_yamane/Rakefile +148 -30
  4. data/hikiutils_yamane/Rakefile~ +477 -0
  5. data/hikiutils_yamane/command.hiki +13 -13
  6. data/hikiutils_yamane/compare.hiki +96 -5
  7. data/hikiutils_yamane/figs/hikiutils_yamane.001.jpg +0 -0
  8. data/hikiutils_yamane/figs/hikiutils_yamane.002.jpg +0 -0
  9. data/hikiutils_yamane/figs/hikiutils_yamane.003.jpg +0 -0
  10. data/hikiutils_yamane/figs/hikiutils_yamane.004.jpg +0 -0
  11. data/hikiutils_yamane/figs/hikiutils_yamane.005.jpg +0 -0
  12. data/hikiutils_yamane/figs/hikiutils_yamane.006.jpg +0 -0
  13. data/hikiutils_yamane/figs/hikiutils_yamane.007.jpg +0 -0
  14. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.001.jpeg +0 -0
  15. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.002.jpeg +0 -0
  16. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.003.jpeg +0 -0
  17. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.004.jpeg +0 -0
  18. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.005.jpeg +0 -0
  19. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.006.jpeg +0 -0
  20. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.007.jpeg +0 -0
  21. data/hikiutils_yamane/hikiutils_yamane.hiki +6 -10
  22. data/hikiutils_yamane/introduction.hiki +5 -5
  23. data/hikiutils_yamane/latex_dir/%CA%FD/313/241.aux +21 -0
  24. data/hikiutils_yamane/latex_dir/abstract.aux +2 -2
  25. data/hikiutils_yamane/latex_dir/command.aux +15 -14
  26. data/hikiutils_yamane/latex_dir/command.log +0 -0
  27. data/hikiutils_yamane/latex_dir/command.tex +15 -14
  28. data/hikiutils_yamane/latex_dir/compare.aux +11 -5
  29. data/hikiutils_yamane/latex_dir/compare.tex +97 -5
  30. data/hikiutils_yamane/latex_dir/hikiutils_yamane.aux +6 -3
  31. data/hikiutils_yamane/latex_dir/hikiutils_yamane.log +113 -162
  32. data/hikiutils_yamane/latex_dir/hikiutils_yamane.pdf +0 -0
  33. data/hikiutils_yamane/latex_dir/hikiutils_yamane.synctex.gz +0 -0
  34. data/hikiutils_yamane/latex_dir/hikiutils_yamane.tex +15 -18
  35. data/hikiutils_yamane/latex_dir/hikiutils_yamane.toc +31 -26
  36. data/hikiutils_yamane/latex_dir/introduction.aux +6 -4
  37. data/hikiutils_yamane/latex_dir/introduction.tex +5 -4
  38. data/hikiutils_yamane/latex_dir/jlisting.sty +216 -0
  39. data/hikiutils_yamane/latex_dir/optparse.aux +11 -9
  40. data/hikiutils_yamane/latex_dir/optparse.tex +11 -8
  41. data/hikiutils_yamane/latex_dir/pre.tex +36 -0
  42. data/hikiutils_yamane/latex_dir/thor.aux +13 -13
  43. data/hikiutils_yamane/latex_dir/thor.tex +9 -11
  44. data/hikiutils_yamane/optparse.hiki +7 -6
  45. data/hikiutils_yamane/test.rb +10 -0
  46. data/hikiutils_yamane/thor.hiki +4 -5
  47. data/lib/hikiutils/version.rb +1 -1
  48. data/lib/hikiutils_thor.rb +39 -39
  49. data/lib/hikiutils_thor.rb~ +3 -4
  50. data/lib/templates/Rakefile_hiki_sync +3 -2
  51. metadata +15 -9
  52. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.001.jpg +0 -0
  53. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.002.jpg +0 -0
  54. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.003.jpg +0 -0
  55. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.004.jpg +0 -0
  56. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.005.jpg +0 -0
  57. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.006.jpg +0 -0
  58. data/hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.007.jpg +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62a3407c3f768b2e1b46dd533be0cf2abd6707be
4
- data.tar.gz: 9cb4306e6aeadb395e53cd2fad88af3603ca312a
3
+ metadata.gz: 2bf7e048b1569915303318d0b3b865e55753a422
4
+ data.tar.gz: 22c3c6e74a468ad1a53f70c06f2c845ea4b06e7a
5
5
  SHA512:
6
- metadata.gz: 18bf3738cd6bdda20de6c961b9ee0bb9413e83b097a82b9885a6b2943fdbc91d11248e0ea5db2834a1b427b94fd7a3ef8cb1913e9f649ad2a9ccd8df4fbfc46a
7
- data.tar.gz: 6ec1f8567f1c2a1e7fb5b8e1ddeeebfbe426803ad1cb70d1bc77bfb6af5b3eb879284c6dd5d68f1e38660ed45a66aecea6d075bbcab251f3edb7b2cac13d2756
6
+ metadata.gz: 5417c0e72a9e427af8b888ab1eda43a652f2d109bf12bf5f40206faba5472015ab89475c4685a53de695cfbde3042c632207a024383e002e0296a1164ce27f42
7
+ data.tar.gz: 10ba14e9fb5a05f95be423761a826ae7a665c06346bf60b9f599a0dbd6a96256c1ec7a22801ca0c16fe1ea39699b75d0e8667893299a8d1ab3685094417dec25
@@ -36,7 +36,7 @@ task :reset_hiki do
36
36
  }
37
37
  r_files = files.reverse[0..-4]
38
38
  r_files.each{|file|
39
- print "remove #{file}[ynqlA]? ".red
39
+ print "remove #{file}? [ynqlA] ".red
40
40
  input=STDIN.gets.chomp
41
41
  case input
42
42
  when 'y'
@@ -49,7 +49,7 @@ task :reset_hiki do
49
49
  when 'q'
50
50
  exit
51
51
  when 'A'
52
- print "\nAre you sure[Yn]? ".magenta
52
+ print "\nAre you sure? [Yn] ".magenta
53
53
  input2 = STDIN.gets.chomp
54
54
  case input2
55
55
  when 'Y'
@@ -189,6 +189,7 @@ end
189
189
 
190
190
  desc "すべてのhikiファイルをlatex変換"
191
191
  task :latex_all do
192
+ check_bounding_box
192
193
  p entries=Dir.entries('.')
193
194
  main_file = latex_loop(entries,opts={:main=>true})
194
195
  latex_loop(entries)
@@ -1,9 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'systemu'
3
3
  require 'tempfile'
4
+ require 'colorize'
4
5
  # -*- coding: utf-8 -*-
5
6
  begin
6
- target_dir = File.readlines('./.hikirc')[0].chomp
7
+ $hiki_dir = File.readlines('./.hikirc')[0].chomp
7
8
  rescue => e
8
9
  puts e
9
10
  exit
@@ -20,10 +21,48 @@ end
20
21
  desc "Githubのdirをsafariでopen"
21
22
  task :github do
22
23
  status, stdout, stderr = systemu %q( git remote -v |grep origin )
23
- p github_dir=stdout.match(/(.+):(.+) \(push\)/)[2]
24
+ github_dir=stdout.match(/(.+):(.+) \(push\)/)[2]
25
+ puts github_dir.blue
24
26
  system "open https://github.com/#{github_dir}"
25
27
  end
26
28
 
29
+ desc "hikiシステムにあるゴミファイルを掃除する"
30
+ task :reset_hiki do
31
+ status, stdout, stderr = systemu "hiki -l #{$basename}"
32
+ print stdout
33
+ files=[]
34
+ stdout.split("\n").each{|line|
35
+ files << line.split(/\s+/)[-1]
36
+ }
37
+ r_files = files.reverse[0..-4]
38
+ r_files.each{|file|
39
+ print "remove #{file}[ynqlA]? ".red
40
+ input=STDIN.gets.chomp
41
+ case input
42
+ when 'y'
43
+ p command="hiki --remove #{file}"
44
+ system command
45
+ when 'n'
46
+ when 'l'
47
+ p command="hiki -l #{$basename}"
48
+ system command
49
+ when 'q'
50
+ exit
51
+ when 'A'
52
+ print "\nAre you sure[Yn]? ".magenta
53
+ input2 = STDIN.gets.chomp
54
+ case input2
55
+ when 'Y'
56
+ r_files.each{|file| system "hiki --remove #{file}"}
57
+ p target = File.join($hiki_dir,'cache','attach',$basename)
58
+ exit
59
+ when 'n'
60
+ exit
61
+ end
62
+ end
63
+ }
64
+ end
65
+
27
66
  desc "latex_dirのゴミを掃除"
28
67
  task :reset_latex_dir do
29
68
  system "mv latex_dir/head.tex ."
@@ -41,14 +80,10 @@ task :mk_toc do
41
80
  if m=line.match(/\\contentsline \{(.+)\}\{\\numberline \{([\d|\.]+)\}(.+)\}\{\d+\}/)
42
81
  layer,sec_no,title=m[1],m[2],m[3]
43
82
  d = case m[1]
44
- when 'section'
45
- 1
46
- when 'subsection'
47
- 2
48
- when 'subsubsection'
49
- 3
50
- else
51
- 4
83
+ when 'section'; 1
84
+ when 'subsection'; 2
85
+ when 'subsubsection'; 3
86
+ else; 4
52
87
  end
53
88
  layer = "!"*d
54
89
  title.gsub!('\_','_')
@@ -59,16 +94,39 @@ task :mk_toc do
59
94
  File.open("toc.hiki",'w'){|file| file.print cont}
60
95
  end
61
96
 
62
- desc "hikiシステムを最新状態に更新"
97
+ desc "FILE.hikiあるいはhikiファイルすべてを最新状態に更新"
63
98
  task :touch do
64
- Dir.entries('.').each{|file|
99
+ if file=ARGV[1]
65
100
  file_split=file.split(".")
66
- if file_split[1]=='hiki'
67
- next if file_split[0]==$basename
68
- p target = $basename+"_"+file_split[0]
69
- system "hiki -u #{target}"
70
- end
71
- }
101
+ p target = $basename==file_split[0] ? $basename : $basename+"_"+file_split[0]
102
+ system "hiki -u #{target}"
103
+ else
104
+ p target = File.join($hiki_dir,'cache','attach',$basename)
105
+ system "touch #{target}/*"
106
+ Dir.entries('.').each{|file|
107
+ file_split=file.split(".")
108
+ if file_split[1]=='hiki'
109
+ p target = $basename==file_split[0] ? $basename : $basename+"_"+file_split[0]
110
+ system "hiki -u #{target}"
111
+ end
112
+ }
113
+ end
114
+ exit
115
+ end
116
+
117
+ desc "FILE.hikiあるいはhikiファイルをedtiorで開く"
118
+ task :open do
119
+ if file=ARGV[1]
120
+ system "open -a mi #{file}"
121
+ else
122
+ Dir.entries('.').each{|file|
123
+ file_split=file.split(".")
124
+ if file_split[1]=='hiki'
125
+ p target = file_split[0]
126
+ system "open -a mi #{target}"
127
+ end
128
+ }
129
+ end
72
130
  end
73
131
 
74
132
  desc "FILE1をlatexに変換"
@@ -82,6 +140,7 @@ task :latex_wrap => [:latex_base, :change_wrap] do
82
140
  end
83
141
 
84
142
  def latex_loop(entries,opts={})
143
+ check_bounding_box
85
144
  main_file=""
86
145
  entries.each{|file|
87
146
  options={:latex_all=>true}
@@ -120,6 +179,11 @@ def check_section_layers(lines)
120
179
  p $section_layer
121
180
  end
122
181
 
182
+ def check_bounding_box
183
+ # $bounding_box="0 0 442 432"
184
+ $bounding_box=" 0 0 737 553"
185
+ end
186
+
123
187
  desc "すべてのhikiファイルをlatex変換"
124
188
  task :latex_all do
125
189
  p entries=Dir.entries('.')
@@ -129,12 +193,15 @@ task :latex_all do
129
193
  p reg_exp = Regexp.new("#{$basename}_(.+)")
130
194
  toc = false
131
195
  File.readlines(File.join($latex_dir,"#{main_file}.tex")).each{|line|
132
- if line.match(/\\tableofcontents/)
133
- p line
134
- line = "" if toc== true
135
- toc = true if toc == false
196
+ # line, toc = "", true if line.match(/\\tableofcontents/) and toc == true #only one
197
+ if line.match(/\\tableofcontents/)
198
+ if toc == false #only one
199
+ toc = true
200
+ else
201
+ line = ''
202
+ end
136
203
  end
137
-
204
+ line ="\\usepackage{listings,jlisting}" if line.match(/\\usepackage{listings}/)
138
205
  if line.match(/section{(.+)}/)
139
206
  if m=line.match(/\\verb\|(.+)\((.+)\)\|/)
140
207
  p m
@@ -156,6 +223,7 @@ task :latex_all do
156
223
  end
157
224
 
158
225
  task :latex_base do
226
+ check_bounding_box
159
227
  Dir.mkdir($latex_dir) unless Dir.exist?($latex_dir)
160
228
  convert_to_latex(ARGV[1])
161
229
  system("open #{$save_name}")
@@ -183,10 +251,27 @@ def convert_to_latex(file_name, options={})
183
251
  system "hiki2latex #{pre_command} #{options[:latex]} #{tf1} > #{tf2}"
184
252
  lines = File.readlines(tf2)
185
253
  system "rm #{tf1} #{tf2}"
186
- cont = ""
254
+ in_bib,cont=false,""
187
255
  lines.each{|line|
256
+ line=latex_cite_ref(line)
257
+ if m=line.match(/\\caption{\s*\((.+?)\)(.+)}/)
258
+ p m
259
+ puts line = "\\caption{#{m[2]}}\n\\label{#{m[1]}}\n"
260
+ end
261
+ if m=line.match(/\\section{reference:}(.+)/) and in_bib==false
262
+ in_bib=true
263
+ line = "\\begin{thebibliography}{99}\n"
264
+ puts line.blue
265
+ end
266
+ if m=line.match(/\\end{description}/) and in_bib==true
267
+ in_bib=false
268
+ line = "\\end{thebibliography}\n"
269
+ end
270
+ if m=line.match(/\\item\[(.+)\](.+)/) and in_bib==true
271
+ line ="\\bibitem{#{m[1]}} #{m[2]}"
272
+ end
188
273
  if m=line.match(/\\includegraphics\[width=6cm\]\{(.+)\}/)
189
- p line="\\includegraphics\[width=6cm,bb=0 0 442 432\]\{../figs/#{m[1]}\}\n"
274
+ p line="\\includegraphics\[width=10cm,bb=#{$bounding_box}\]\{../figs/#{m[1]}\}\n"
190
275
  cont << line
191
276
  else
192
277
  cont << line
@@ -195,6 +280,18 @@ def convert_to_latex(file_name, options={})
195
280
  File.open($save_name,'w'){|file| file.print cont }
196
281
  end
197
282
 
283
+ def latex_cite_ref(line)
284
+ r_pair=[/\\verb\|{{cite\((.+?)\)}}\|/,/\\verb\|{{ref\((.+?)\)}}\|/]
285
+ while m=line.match(r_pair[0])
286
+ line.sub!(r_pair[0],"\\cite\{#{m[1]}\}")
287
+ end
288
+ while m=line.match(r_pair[1])
289
+ line.sub!(r_pair[1],"\\ref\{#{m[1]}\}")
290
+ end
291
+ # puts line.chomp.blue
292
+ return line
293
+ end
294
+
198
295
  task :change_wrap do
199
296
  lines = File.readlines($save_name)
200
297
 
@@ -283,6 +380,26 @@ task :sync => [:check_previous,:sync0]
283
380
  desc "hikiの強制同期"
284
381
  task :force_sync => [:sync0]
285
382
 
383
+ def hiki_cite_ref(file)
384
+ tf1 = 'tmp1.txt'
385
+ lines = File.readlines(file)
386
+ inside_pre_form,cont = false,""
387
+ lines.each{|line|
388
+ inside_pre_form=true if line.match(/^<<</) and !inside_pre_form
389
+ inside_pre_form=false if line.match(/^>>>/) and inside_pre_form
390
+ tr_pair=[/\{\{cite\((.+?)\)\}\}/,/\{\{ref\((.+)\)\}\}/]
391
+ while m=line.match(tr_pair[0]) and !inside_pre_form
392
+ puts line.sub!(tr_pair[0], "\[[[#{m[1]}|#{$basename}_references]]\]").chomp.green
393
+ end
394
+ while m=line.match(tr_pair[1]) and !inside_pre_form
395
+ puts line.sub!(tr_pair[1],"#{m[1]}").chomp.green
396
+ end
397
+ cont << line
398
+ }
399
+ File.open(tf1,'w'){|file| file.print cont }
400
+ return tf1
401
+ end
402
+
286
403
  task :sync0 do
287
404
  entries=Dir.entries('.')
288
405
  entries[2..-1].each{|source| #cp *.hiki
@@ -290,11 +407,12 @@ task :sync0 do
290
407
  next if source.include?('.hikirc')
291
408
  p base = source.split('.')[0]
292
409
  name = (base==$basename)? base : $basename+'_'+base
293
- p target = File.join(target_dir,'text',name)
410
+ p target = File.join($hiki_dir,'text',name)
411
+ source = hiki_cite_ref(source)
294
412
  FileUtils.cp(source,target,:verbose=>true)
295
413
  }
296
414
  p entries=Dir.entries('./figs') #cp files in figs
297
- p target = File.join(target_dir,'cache','attach',$basename)
415
+ p target = File.join($hiki_dir,'cache','attach',$basename)
298
416
  FileUtils.mkdir_p(target,:verbose=>true) unless File.exists?(target)
299
417
  entries[2..-1].each{|file|
300
418
  p source = File.join('./figs',file)
@@ -303,7 +421,7 @@ task :sync0 do
303
421
 
304
422
  File.open('./.hikirc','w'){|file|
305
423
  status, stdout, stderr =systemu "hiki -l #{$basename}*"
306
- file.print(target_dir+"\n")
424
+ file.print($hiki_dir+"\n")
307
425
  stdout.split("\n")[3..-1].each{|line|
308
426
  file.print line+"\n"
309
427
  }
@@ -314,8 +432,8 @@ end
314
432
  desc "For hiki Errno::ENOENT, Errno::EACCES"
315
433
  task :chenv do
316
434
  p user = ENV['USER']
317
- system("sudo chmod -R a+w #{target_dir}")
318
- # system("sudo chown -R #{user} #{target_dir}")
435
+ system("sudo chmod -R a+w #{$hiki_dir}")
436
+ # system("sudo chown -R #{user} #{$hiki_dir}")
319
437
  end
320
438
 
321
439
  desc "self copy to hikiutils template directory"