hikiutils 0.2.3.11 → 0.2.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/hikiutils.gemspec +1 -0
  3. data/hikiutils_bob/Rakefile +61 -8
  4. data/hikiutils_bob/code.hiki +52 -0
  5. data/hikiutils_bob/figs/hikiutils_bob.004.jpeg +0 -0
  6. data/hikiutils_bob/figs/hikiutils_bob.006.jpeg +0 -0
  7. data/hikiutils_bob/figs/hikiutils_bob.pdf +0 -0
  8. data/hikiutils_bob/hikiutils_bob/hikiutils_bob.004.jpeg +0 -0
  9. data/hikiutils_bob/hikiutils_bob/hikiutils_bob.006.jpeg +0 -0
  10. data/hikiutils_bob/hikiutils_bob.hiki +1 -1
  11. data/hikiutils_bob/hikiutils_bob.key +0 -0
  12. data/hikiutils_bob/latex_all.hiki +2 -2
  13. data/hikiutils_bob/latex_dir/code.aux +33 -0
  14. data/hikiutils_bob/latex_dir/code.tex +57 -0
  15. data/hikiutils_bob/latex_dir/hikiutils_bob.aux +1 -1
  16. data/hikiutils_bob/latex_dir/hikiutils_bob.log +70 -69
  17. data/hikiutils_bob/latex_dir/hikiutils_bob.pdf +0 -0
  18. data/hikiutils_bob/latex_dir/hikiutils_bob.tex +9 -9
  19. data/hikiutils_bob/latex_dir/hikiutils_bob.toc +10 -7
  20. data/hikiutils_bob/latex_dir/jlisting.tex +216 -0
  21. data/hikiutils_bob/latex_dir/latex2hiki.aux +11 -7
  22. data/hikiutils_bob/latex_dir/latex2hiki.tex +40 -20
  23. data/hikiutils_bob/latex_dir/latex_all.aux +1 -1
  24. data/hikiutils_bob/latex_dir/latex_all.tex +5 -5
  25. data/hikiutils_bob/latex_dir/pre.tex +1 -1
  26. data/hikiutils_bob/latex_dir/references.tex +4 -0
  27. data/hikiutils_bob/latex_dir/sync.aux +4 -3
  28. data/hikiutils_bob/latex_dir/sync.tex +18 -14
  29. data/hikiutils_bob/references.hiki +3 -0
  30. data/hikiutils_bob/sync.hiki +15 -10
  31. data/hikiutils_bob/tmp1.txt +32 -0
  32. data/lib/hikiutils/version.rb +1 -1
  33. data/lib/hikiutils.rb +1 -1
  34. data/lib/hikiutils.rb~ +3 -1
  35. data/lib/templates/Rakefile_hiki_sync +61 -8
  36. metadata +25 -7
  37. data/hikiutils_bob/.#Rakefile +0 -1
  38. data/hikiutils_bob/hikiutils_bob/hikiutils_bob.002.bb +0 -5
  39. data/hikiutils_bob/latex2hiki.hiki +0 -25
  40. data/hikiutils_bob/latex_dir/hikiutils_bob.synctex.gz +0 -0
  41. data/hikiutils_bob/latex_dir/sync.log +0 -28
@@ -1,6 +1,7 @@
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
7
  $hiki_dir = File.readlines('./.hikirc')[0].chomp
@@ -20,7 +21,8 @@ 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
 
@@ -32,9 +34,9 @@ task :reset_hiki do
32
34
  stdout.split("\n").each{|line|
33
35
  files << line.split(/\s+/)[-1]
34
36
  }
35
- p r_files = files.reverse[0..-4]
37
+ r_files = files.reverse[0..-4]
36
38
  r_files.each{|file|
37
- print "remove #{file}[ynqlA]?"
39
+ print "remove #{file}[ynqlA]? ".red
38
40
  input=STDIN.gets.chomp
39
41
  case input
40
42
  when 'y'
@@ -47,7 +49,7 @@ task :reset_hiki do
47
49
  when 'q'
48
50
  exit
49
51
  when 'A'
50
- print "\nAre you sure?[Yn]"
52
+ print "\nAre you sure[Yn]? ".magenta
51
53
  input2 = STDIN.gets.chomp
52
54
  case input2
53
55
  when 'Y'
@@ -108,11 +110,12 @@ task :touch do
108
110
  file_split=file.split(".")
109
111
  if file_split[1]=='hiki'
110
112
  next if file_split[0]==$basename
111
- p target = $basename+"_"+file_split[0]
113
+ p target = $basename==file_split[0] ? $basename : $basename+"_"+file_split[0]
112
114
  system "hiki -u #{target}"
113
115
  end
114
116
  }
115
117
  end
118
+ exit
116
119
  end
117
120
 
118
121
  desc "FILE.hikiあるいはhikiファイルをedtiorで開く"
@@ -181,13 +184,12 @@ end
181
184
 
182
185
  def check_bounding_box
183
186
  # $bounding_box="0 0 442 432"
184
- $bounding_box=" 0 0 737 453"
187
+ $bounding_box=" 0 0 737 553"
185
188
  end
186
189
 
187
190
  desc "すべてのhikiファイルをlatex変換"
188
191
  task :latex_all do
189
192
  p entries=Dir.entries('.')
190
- check_bounding_box
191
193
  main_file = latex_loop(entries,opts={:main=>true})
192
194
  latex_loop(entries)
193
195
  cont=""
@@ -217,6 +219,7 @@ task :latex_all do
217
219
  end
218
220
 
219
221
  task :latex_base do
222
+ check_bounding_box
220
223
  Dir.mkdir($latex_dir) unless Dir.exist?($latex_dir)
221
224
  convert_to_latex(ARGV[1])
222
225
  system("open #{$save_name}")
@@ -244,8 +247,25 @@ def convert_to_latex(file_name, options={})
244
247
  system "hiki2latex #{pre_command} #{options[:latex]} #{tf1} > #{tf2}"
245
248
  lines = File.readlines(tf2)
246
249
  system "rm #{tf1} #{tf2}"
247
- cont = ""
250
+ in_bib,cont=false,""
248
251
  lines.each{|line|
252
+ line=latex_cite_ref(line)
253
+ if m=line.match(/\\caption{\s*\((.+?)\)(.+)}/)
254
+ p m
255
+ puts line = "\\caption{#{m[2]}}\n\\label{#{m[1]}}\n"
256
+ end
257
+ if m=line.match(/\\section{reference:}(.+)/) and in_bib==false
258
+ in_bib=true
259
+ line = "\\begin{thebibliography}{99}\n"
260
+ puts line.blue
261
+ end
262
+ if m=line.match(/\\end{description}/) and in_bib==true
263
+ in_bib=false
264
+ line = "\\end{thebibliography}\n"
265
+ end
266
+ if m=line.match(/\\item\[(.+)\](.+)/) and in_bib==true
267
+ line ="\\bibitem{#{m[1]}} #{m[2]}"
268
+ end
249
269
  if m=line.match(/\\includegraphics\[width=6cm\]\{(.+)\}/)
250
270
  p line="\\includegraphics\[width=10cm,bb=#{$bounding_box}\]\{../figs/#{m[1]}\}\n"
251
271
  cont << line
@@ -256,6 +276,18 @@ def convert_to_latex(file_name, options={})
256
276
  File.open($save_name,'w'){|file| file.print cont }
257
277
  end
258
278
 
279
+ def latex_cite_ref(line)
280
+ r_pair=[/\\verb\|{{cite\((.+?)\)}}\|/,/\\verb\|{{ref\((.+?)\)}}\|/]
281
+ while m=line.match(r_pair[0])
282
+ line.sub!(r_pair[0],"\\cite\{#{m[1]}\}")
283
+ end
284
+ while m=line.match(r_pair[1])
285
+ line.sub!(r_pair[1],"\\ref\{#{m[1]}\}")
286
+ end
287
+ puts line.chomp.blue
288
+ return line
289
+ end
290
+
259
291
  task :change_wrap do
260
292
  lines = File.readlines($save_name)
261
293
 
@@ -344,6 +376,26 @@ task :sync => [:check_previous,:sync0]
344
376
  desc "hikiの強制同期"
345
377
  task :force_sync => [:sync0]
346
378
 
379
+ def hiki_cite_ref(file)
380
+ tf1 = 'tmp1.txt'
381
+ lines = File.readlines(file)
382
+ inside_pre_form,cont = false,""
383
+ lines.each{|line|
384
+ inside_pre_form=true if line.match(/^<<</) and !inside_pre_form
385
+ inside_pre_form=false if line.match(/^>>>/) and inside_pre_form
386
+ tr_pair=[/\{\{cite\((.+?)\)\}\}/,/\{\{ref\((.+)\)\}\}/]
387
+ while m=line.match(tr_pair[0]) and !inside_pre_form
388
+ puts line.sub!(tr_pair[0], "\[[[#{m[1]}|#{$basename}_references]]\]").chomp.green
389
+ end
390
+ while m=line.match(tr_pair[1]) and !inside_pre_form
391
+ puts line.sub!(tr_pair[1],"#{m[1]}").chomp.green
392
+ end
393
+ cont << line
394
+ }
395
+ File.open(tf1,'w'){|file| file.print cont }
396
+ return tf1
397
+ end
398
+
347
399
  task :sync0 do
348
400
  entries=Dir.entries('.')
349
401
  entries[2..-1].each{|source| #cp *.hiki
@@ -352,6 +404,7 @@ task :sync0 do
352
404
  p base = source.split('.')[0]
353
405
  name = (base==$basename)? base : $basename+'_'+base
354
406
  p target = File.join($hiki_dir,'text',name)
407
+ source = hiki_cite_ref(source)
355
408
  FileUtils.cp(source,target,:verbose=>true)
356
409
  }
357
410
  p entries=Dir.entries('./figs') #cp files in figs
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hikiutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3.11
4
+ version: 0.2.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeto R. Nishitani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: colorize
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  description: "."
182
196
  email:
183
197
  - shigeto_nishitani@me.com
@@ -300,9 +314,9 @@ files:
300
314
  - hikiutils.wiki/README.md
301
315
  - hikiutils.wiki/README_ja.md
302
316
  - hikiutils.wiki/yamane.md
303
- - hikiutils_bob/.#Rakefile
304
317
  - hikiutils_bob/.gitignore
305
318
  - hikiutils_bob/Rakefile
319
+ - hikiutils_bob/code.hiki
306
320
  - hikiutils_bob/figs/calphad_bob.pdf
307
321
  - hikiutils_bob/figs/hikiutils_bob.001.bb
308
322
  - hikiutils_bob/figs/hikiutils_bob.001.jpeg
@@ -311,6 +325,7 @@ files:
311
325
  - hikiutils_bob/figs/hikiutils_bob.003.jpeg
312
326
  - hikiutils_bob/figs/hikiutils_bob.004.jpeg
313
327
  - hikiutils_bob/figs/hikiutils_bob.005.jpeg
328
+ - hikiutils_bob/figs/hikiutils_bob.006.jpeg
314
329
  - hikiutils_bob/figs/hikiutils_bob.pdf
315
330
  - hikiutils_bob/figs/sync.pdf
316
331
  - hikiutils_bob/hiki_help.yml
@@ -318,30 +333,33 @@ files:
318
333
  - hikiutils_bob/hikiutils_bob.hiki
319
334
  - hikiutils_bob/hikiutils_bob.key
320
335
  - hikiutils_bob/hikiutils_bob/hikiutils_bob.001.jpeg
321
- - hikiutils_bob/hikiutils_bob/hikiutils_bob.002.bb
322
336
  - hikiutils_bob/hikiutils_bob/hikiutils_bob.002.jpeg
323
337
  - hikiutils_bob/hikiutils_bob/hikiutils_bob.003.jpeg
324
338
  - hikiutils_bob/hikiutils_bob/hikiutils_bob.004.jpeg
325
339
  - hikiutils_bob/hikiutils_bob/hikiutils_bob.005.jpeg
326
- - hikiutils_bob/latex2hiki.hiki
340
+ - hikiutils_bob/hikiutils_bob/hikiutils_bob.006.jpeg
327
341
  - hikiutils_bob/latex_all.hiki
342
+ - hikiutils_bob/latex_dir/code.aux
343
+ - hikiutils_bob/latex_dir/code.tex
328
344
  - hikiutils_bob/latex_dir/head.tex
329
345
  - hikiutils_bob/latex_dir/hikiutils_bob.aux
330
346
  - hikiutils_bob/latex_dir/hikiutils_bob.log
331
347
  - hikiutils_bob/latex_dir/hikiutils_bob.pdf
332
- - hikiutils_bob/latex_dir/hikiutils_bob.synctex.gz
333
348
  - hikiutils_bob/latex_dir/hikiutils_bob.tex
334
349
  - hikiutils_bob/latex_dir/hikiutils_bob.toc
335
350
  - hikiutils_bob/latex_dir/jlisting.sty
351
+ - hikiutils_bob/latex_dir/jlisting.tex
336
352
  - hikiutils_bob/latex_dir/latex2hiki.aux
337
353
  - hikiutils_bob/latex_dir/latex2hiki.tex
338
354
  - hikiutils_bob/latex_dir/latex_all.aux
339
355
  - hikiutils_bob/latex_dir/latex_all.tex
340
356
  - hikiutils_bob/latex_dir/pre.tex
357
+ - hikiutils_bob/latex_dir/references.tex
341
358
  - hikiutils_bob/latex_dir/sync.aux
342
- - hikiutils_bob/latex_dir/sync.log
343
359
  - hikiutils_bob/latex_dir/sync.tex
360
+ - hikiutils_bob/references.hiki
344
361
  - hikiutils_bob/sync.hiki
362
+ - hikiutils_bob/tmp1.txt
345
363
  - hikiutils_bob/toc.hiki
346
364
  - hikiutils_yamane/.gitignore
347
365
  - hikiutils_yamane/Rakefile
@@ -1 +0,0 @@
1
- bob@bob.local.81065
@@ -1,5 +0,0 @@
1
- %%Title: hikiutils_bob.002.jpeg
2
- %%Creator: extractbb 20160307
3
- %%BoundingBox: 0 0 737 553
4
- %%CreationDate: Mon Feb 6 21:52:49 2017
5
-
@@ -1,25 +0,0 @@
1
- !latexからhikiへの変換
2
- !!rake mk_toc
3
- latexが作成するtableofcontentsの実態であるtocファイルからhiki用のtoc.hikiを作成する.
4
-
5
- !!listings
6
- <<< latex
7
- \lstset{
8
- basicstyle={\ttfamily\scriptsize},
9
- identifierstyle={\scriptsize},
10
- commentstyle={\scriptsize\itshape\color{red}},
11
- keywordstyle={\scriptsize\bfseries\color{cyan}},
12
- ndkeywordstyle={\scriptsize},
13
- stringstyle={\scriptsize\color{blue}},
14
- frame={tb},
15
- breaklines=true,
16
- numbers=left,
17
- numberstyle={\footnotesize},
18
- stepnumber=1,
19
- numbersep=1zw,
20
- xrightmargin=0zw,
21
- xleftmargin=3zw,
22
- lineskip=-0.5ex
23
- }
24
- >>>
25
-
@@ -1,28 +0,0 @@
1
- This is e-pTeX, Version 3.14159265-p3.7-160201-2.6 (utf8.euc) (TeX Live 2016) (preloaded format=platex 2017.1.26) 6 FEB 2017 09:51
2
- entering extended mode
3
- restricted \write18 enabled.
4
- file:line:error style messages enabled.
5
- %&-line parsing enabled.
6
- **sync.tex
7
- (./sync.tex
8
- pLaTeX2e <2016/11/29> (based on LaTeX2e <2017/01/01>)
9
- Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
10
- ./sync.tex:2: Undefined control sequence.
11
- l.2 \section
12
- {イントロダクション}
13
- ?
14
- ./sync.tex:2: Emergency stop.
15
- l.2 \section
16
- {イントロダクション}
17
- End of file on the terminal!
18
-
19
-
20
- Here is how much of TeX's memory you used:
21
- 4 strings out of 493683
22
- 30 string characters out of 6149653
23
- 53892 words of memory out of 5000000
24
- 3671 multiletter control sequences out of 15000+600000
25
- 7511 words of font info for 31 fonts, out of 8000000 for 9000
26
- 929 hyphenation exceptions out of 8191
27
- 5i,0n,3p,39b,8s stack positions out of 5000i,500n,10000p,200000b,80000s
28
- No pages of output.