lib/templates/Rakefile_hiki_sync in hikiutils-0.2.3.4 vs lib/templates/Rakefile_hiki_sync in hikiutils-0.2.3.6

- old
+ new

@@ -41,15 +41,19 @@ option="-l 1 --listings -b " end convert_to_latex(file, option) } cont="" + p reg_exp = Regexp.new("#{basename}_(.+)") File.readlines(File.join($latex_dir,"#{main_file}.tex")).each{|line| - if line.match(/\\section{(.+)}/) - if m=line.match(/\\section{\\verb\|(.+)\|}/) + if line.match(/section{(.+)}/) + if m=line.match(/\\verb\|(.+)\((.+)\)\|/) p m - p reg_exp = Regexp.new("#{basename}_(.+)") + p m_t=m[2].match(reg_exp)[1] + line = "\\include{#{m_t}}\n" + elsif m=line.match(/section{\\verb\|(.+)\|}/) + p m p m_t=m[1].match(reg_exp)[1] line = "\\include{#{m_t}}\n" else line = "" end @@ -59,37 +63,10 @@ File.open(File.join($latex_dir,"#{main_file}.tex"),'w'){|file| file.print cont} system "open latex_dir/#{main_file}.tex" exit end -desc "change latex figures to wrap format" -task :change_wrap do - lines = File.readlines($save_name) - - cont = "" - lines.each{|line| - if line.include?('\begin{figure}[htbp]\begin{center}') - p line - cont << '\begin{wrapfigure}{r}{8cm}'+"\n" - cont << '\vspace{-2\baselineskip}'+"\n" - cont << '\begin{center}'+"\n" - elsif line.include?('\label{default}\end{center}\end{figure}') - p line - cont << '\end{center}'+"\n" - cont << '\vspace{2\baselineskip}'+"\n" - cont << '\end{wrapfigure}'+"\n" - else - cont << line - end - } - File.open($save_name,'w'){|file| file.print cont } - - system("open #{$save_name}") - exit -end - - desc "latex conversion FILE1(hiki) to FILE2(latex)" task :latex_base do Dir.mkdir($latex_dir) unless Dir.exist?($latex_dir) convert_to_latex(ARGV[1]) system("open #{$save_name}") @@ -125,10 +102,37 @@ end } File.open($save_name,'w'){|file| file.print cont } end +desc "change latex figures to wrap format" +task :change_wrap do + lines = File.readlines($save_name) + + cont = "" + lines.each{|line| + if line.include?('\begin{figure}[htbp]\begin{center}') + p line + cont << '\begin{wrapfigure}{r}{8cm}'+"\n" + cont << '\vspace{-2\baselineskip}'+"\n" + cont << '\begin{center}'+"\n" + elsif line.include?('\label{default}\end{center}\end{figure}') + p line + cont << '\end{center}'+"\n" + cont << '\vspace{2\baselineskip}'+"\n" + cont << '\end{wrapfigure}'+"\n" + else + cont << line + end + } + File.open($save_name,'w'){|file| file.print cont } + + system("open #{$save_name}") + exit +end + + desc "increment fig NUBERS in FILE" task :increment do number=ARGV[1] file = ARGV[2] dir = ARGV[3] || nil @@ -200,10 +204,10 @@ p target = File.join(target_dir,'text',name) FileUtils.cp(source,target,:verbose=>true) } p entries=Dir.entries('./figs') #cp files in figs p target = File.join(target_dir,'cache','attach',basename) - FileUtils.mkdir(target,:verbose=>true) unless File.exists?(target) + FileUtils.mkdir_p(target,:verbose=>true) unless File.exists?(target) entries[2..-1].each{|file| p source = File.join('./figs',file) FileUtils.cp(source,target,:verbose=>true) }