From 6811ac91f21a434fc7d967c11e1b20f33918c6ea Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 19 Mar 2012 22:07:29 -0400 Subject: v3: 3.2 branch is main (v3dv --> v3); dev (v3dv) branch directories removed * v3dv (3.2) "merged" into v3 (previously 3.1) (& removed) * conf/sisu/v3dv --> conf/sisu/v3 * data/sisu/v3dv --> data/sisu/v3 * lib/sisu/v3dv --> lib/sisu/v3 * bin/sisu* (v3dv references changed to v3) * (--dev modifier (superfluous for the time being) runs main v3 branch) --- lib/sisu/v3/texinfo.rb | 197 +++++++++++++++++++++++++++---------------------- 1 file changed, 107 insertions(+), 90 deletions(-) (limited to 'lib/sisu/v3/texinfo.rb') diff --git a/lib/sisu/v3/texinfo.rb b/lib/sisu/v3/texinfo.rb index 90810120..2496ce7a 100644 --- a/lib/sisu/v3/texinfo.rb +++ b/lib/sisu/v3/texinfo.rb @@ -63,7 +63,7 @@ module SiSU_TexInfo include SiSU_Viz #include Stamp ... needed removed arbitrarily 2005w05/1 (warnings about undefined flags) require_relative 'texinfo_format' # texinfo_format.rb - include SiSU_Texinfo_format + include SiSU_TexInfoFormat @tex_file=[] @@tabular="{tabular}" @@table_pagebreak_counter,@@tex_endnote_call_counter,@@tex_table_flag,@@tex_counter,@@tex_column,@@tex_columns,@@counting=0,0,0,0,0,0,0 @@ -78,8 +78,8 @@ module SiSU_TexInfo def initialize(opt) @opt=opt @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::Info_env.new(@opt.fns) - @vz=SiSU_Env::Get_init.instance.skin + @env=SiSU_Env::InfoEnv.new(@opt.fns) + @vz=SiSU_Env::GetInit.instance.skin end def directories begin @@ -107,7 +107,7 @@ module SiSU_TexInfo tell @md=SiSU_Param::Parameters.new(@opt).get directories - @marshalfile=SiSU_Env::Info_file.new(@opt.fns).marshal.dal_content + @marshalfile=SiSU_Env::InfoFile.new(@opt.fns).marshal.dal_content if FileTest.file?(@marshalfile)==true File.open(@marshalfile) { |f| @@tuned_file=Marshal.load(f)} #tell.meta_verse_skipped if @opt.cmd =~/[vVM]/ @@ -116,84 +116,88 @@ module SiSU_TexInfo SiSU_Metaverse.songsheet(tex_array) end tex_array=@@tuned_file - Texinfo_make.new(@md,tex_array).songsheet + TeXinfoMake.new(@md,tex_array).songsheet tex_array='' rescue; STDERR.puts SiSU_Screen::Ansi.new(@opt.cmd,$!,$@).rescue ensure end end end - class Texinfo_make + class TeXinfoMake include SiSU_Param - include SiSU_Texinfo_format + include SiSU_TexInfoFormat @@tex_1='(?:.+?)+~' #?? debug @@tabular="{tabular}" @@tex_pattern_margin_number="\\\\marginpar.+?\s+" def initialize(md,data) @md,@data=md,data - @env=SiSU_Env::Info_env.new(@md.fns) - @vz=SiSU_Env::Get_init.instance.skin - @f=SiSU_Env::SiSU_file.new(@md) + @env=SiSU_Env::InfoEnv.new(@md.fns) + @vz=SiSU_Env::GetInit.instance.skin + @f=SiSU_Env::FileOp.new(@md) end def songsheet begin - @data=pre - @data=endnote - @data=markup - @data=tail - output + data=@data + data=pre(data) + data=endnote(data) + data,head=markup(data) + objs_txt=tail(data) + doc_txt=[head,objs_txt] + output(doc_txt) makeinfo #KEEP reinstate when fixed #% place_info rescue; STDERR.puts SiSU_Screen::Ansi.new(@md.opt.cmd,$!,$@).rescue ensure end end - def pre - data=@data + def pre(data) + data_new=[] data.each do |dob| # DEBUG 2003w16 this is a kludge, because i could not get parameters # from param, Sort out ... revert to more elegant solution if dob.is =='table' @@flag['tables']='y' # KLUDGE get from param end - dob.obj.gsub!(/<:p[bn]>/,'') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1(\2 [linked to:] \3)') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') - do_mono=SiSU_Texinfo_format::Texinfo.new(@md,dob) + dob.obj=dob.obj.gsub(/<:p[bn]>/,''). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1(\2 [linked to:] \3)'). + gsub(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') + do_mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) dob.obj=do_mono.spec_char(dob.obj) + data_new << dob end - data + data_new end - def endnote - data=@data + def endnote(data) + data_new=[] data.each do |dob| - if dob.of=~/para|block/ - dob.obj.gsub!(/\s*#{Mx[:en_a_o]}(?:\d+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') - dob.obj.gsub!(/\s*#{Mx[:en_a_o]}(\*+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') + if dob.of==:para \ + || dob.of==:block + dob.obj=dob.obj.gsub(/\s*#{Mx[:en_a_o]}(?:\d+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} '). + gsub(/\s*#{Mx[:en_a_o]}(\*+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') end - dob + data_new << dob end - data + data_new end def poem - data=@data + data,data_new=@data,[] @tex_file=[] @@counting=0 data.each do |dob| - if dob.is =='code' + if dob.is ==:code @@flag['code']=true @@counting=1 end - if dob.is =='verse' + if dob.is ==:verse @@flag['poem']=1 end if @@flag['code'] if @@flag['code'] \ - and dob.obj =~ /#{Mx[:gr_o]}code[-_](?:end|close)#{Mx[:gr_c]}/ #watch change not tested 200501 #fix + && (dob.obj =~ /#{Mx[:gr_o]}code[-_](?:end|close)#{Mx[:gr_c]}/) #watch change not tested 200501 #fix @@flag['code']=false end if @@flag['code'] \ - and dob.obj =~ /\S/ + && (dob.obj =~ /\S/) sub_array=dob.obj.dup @@line_mode=sub_array.scan(/.+/) Tune.code_lines(@@line_mode) @@ -201,11 +205,11 @@ module SiSU_TexInfo end elsif @@flag['poem']==1 if @@flag['poem']==1 \ - and dob.obj =~ /#{Mx[:gr_o]}verse[-_](?:end|close)#{Mx[:gr_c]}/ #watch change not tested 200501 #fix + && (dob.obj =~ /#{Mx[:gr_o]}verse[-_](?:end|close)#{Mx[:gr_c]}/) #watch change not tested 200501 #fix @@flag['poem']=0 end if @@flag['poem']==1 \ - and dob.obj =~ /\S/ + && (dob.obj =~ /\S/) sub_array=dob.obj.dup @@line_mode=sub_array.scan(/.+/) Tune.code_lines(@@line_mode) @@ -213,53 +217,58 @@ module SiSU_TexInfo end end @tex_file << dob.obj + data_new << dob end + data_new end def code_lines - data=@data + data,data_new=@data,[] data.each do |line| - if line =~ /\S/ \ - and line !~ /#{Mx[:gr_o]}(code|verse).+/ #fix - if @@flag['code'] - line.gsub!(/^\s*(.+)/m,"\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") + if (line =~ /\S/) \ + && (line !~ /#{Mx[:gr_o]}(code|verse).+/) #fix + line=if @@flag['code'] + line.gsub(/^\s*(.+)/m,"\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") @@counting+=1 if @@flag['code'] - else line.gsub!(/(.+)/m,'\noindent\1') + else line.gsub(/(.+)/m,'\noindent\1') end end + data_new << line end end def tables - data=@data + data,data_new=@data,[] @tex_file=[] @@tableheader=0 data.each do |dob| if dob.obj =~ /#{Mx[:tc_p]}|#{Mx[:gr_o]}T/ui #fix - do_mono=SiSU_Texinfo_format::Texinfo.new(@md,dob) + do_mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) dob.obj=do_mono.longtable # using longtable latex package end @tex_file << dob.obj + data_new << dob end + data_new end - def markup - data=@data + def markup(data) + data_new=[] @tex_file=[] @row_break='\\\\\\' @break_page="#{@row_break}\n#{@row_break} \n" md={} - @tex_file << SiSU_Texinfo_format::Texinfo.new(@md).head - mono=SiSU_Texinfo_format::Texinfo.new(@md) + @tex_file << SiSU_TexInfoFormat::Texinfo.new(@md).head + mono=SiSU_TexInfoFormat::Texinfo.new(@md) @tex_file << mono.topnode(@md.title.full) texinfo_menu=[] n_menu,n_submenu=0,0 @submenu,@subsubmenu={},{} data.each do |dob| - if dob.is =='heading' \ - and dob.ln.to_s =~ /^[1-3]$/ - toc=SiSU_Texinfo_format::Texinfo.new(@md,dob) + if dob.is ==:heading \ + && (dob.ln.to_s =~ /^[1-3]$/) + toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob) texinfo_menu << toc.menu - elsif dob.is =='heading' \ - and dob.ln.to_s =~ /^[4-6]$/ - toc=SiSU_Texinfo_format::Texinfo.new(@md,dob) + elsif dob.is ==:heading \ + && (dob.ln.to_s =~ /^[4-6]$/) + toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob) texinfo_menu << toc.menu case dob.ln when 4 @@ -275,10 +284,12 @@ module SiSU_TexInfo @subsubmenu[n_submenu] << toc.menu end else - dob.obj.gsub!(/\s*(?:<:?br>|
)\s*/,"\n\n") + dob.obj=dob.obj.gsub(/\s*(?:<:?br>|
)\s*/,"\n\n") end + data_new << dob end - texinfo_menu.compact! + data=data_new + texinfo_menu=texinfo_menu.compact texinfo_menu << "* Dublin Core::" @tex_file << texinfo_menu @tex_file << "* Index::\n" + @@ -286,85 +297,91 @@ module SiSU_TexInfo "@c %% 5\n\n" n_menu,n_submenu=0,0 @@do_submenu,@@do_subsubmenu=1,1 + data_new=[] data.each do |dob| - mono=SiSU_Texinfo_format::Texinfo.new(@md,dob) - if dob.is=='heading' + mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) + if dob.is==:heading case dob.ln - when 1; mono.level1 - when 2; mono.level2 - when 3; mono.level3 + when 1; dob=mono.level1 + when 2; dob=mono.level2 + when 3; dob=mono.level3 when 4; - mono.level4 + dob=mono.level4 n_menu+=1 @@do_submenu,@@do_subsubmenu=1,1 when 5; n_submenu+=1 @@do_subsubmenu=1 if @@do_submenu==1 - menu=SiSU_Texinfo_format::Texinfo_txt.new(@md,dob,@submenu[n_menu]) + menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu]) dob.obj="#{menu.submenu}#{mono.level5.obj}" @@do_submenu=0 - else mono.level5 + else dob=mono.level5 end when 6; if @@do_submenu==1 - menu=SiSU_Texinfo_format::Texinfo_txt.new(@md,dob,@submenu[n_menu]) + menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu]) dob.obj="#{menu.subsubmenu}#{mono.level6.obj}" @@do_subsubmenu=0 else - mono.level6 + dob=mono.level6 end end else if dob.obj !~/\S/ dob.obj=nil else - if dob.is=='para' \ - and dob.obj !~/##{dob.ocn}/ + if dob.is==:para \ + && (dob.obj !~/##{dob.ocn}/) dob.obj="#{dob.obj} ##{dob.ocn}" end end end #%case with endnotes - dob.obj.gsub!(/\s*[0-8]\\+(\S+)?\s+/,' ') if dob.obj - @tex_file << dob.obj if dob.obj and dob.is !~/structure|comment/ #sort exceptions + dob.obj=dob.obj.gsub(/\s*[0-8]\\+(\S+)?\s+/,' ') if dob.obj + data_new << dob end - data=@tex_file + [data_new, @tex_file] end def number_titles - data=@data + data,data_new=@data,[] @tex_file=[] input=%{#{@md.markup}}[/(num_top\s*=\s*(\d?))?/m,2] # else default usually 4 # this was a bit of a trick required to pass nil to input if nothing matched... #puts input num_top=input.to_i t_no1=0; t_no2=0; t_no3=0; t_no4=0; no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3); data.each do |dob| - if @md.markup =~ /num_top/i \ - and dob.obj !~ /#{Rx[:meta]}/ - if dob.obj =~ /^[1-6]\\+(?:~\S+)?\s*/ \ - and dob.obj !~ /<:\d-endnotes>/ - header=dob.obj[//m, 1].gsub!(/-/m,'.') - dob.obj.gsub!(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*/, + if (@md.markup =~ /num_top/i) \ + && (dob.obj !~ /#{Rx[:meta]}/) + if (dob.obj =~ /^[1-6]\\+(?:~\S+)?\s*/) \ + && (dob.obj !~ /<:\d-endnotes>/) + header=dob.obj[//m, 1].gsub(/-/m,'.') + dob.obj=dob.obj.gsub(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*/, "\\1 #{header} ") end elsif dob.obj=~ /|||/ if dob.obj=~ // - dob.obj.gsub!(//,'\1 ') + dob.obj=dob.obj.gsub(//,'\1 ') end end @tex_file << dob.obj end - data=@tex_file + data_new << dob end - def tail - data=@data - tex=SiSU_Texinfo_format::Texinfo.new(@md) - data << tex.dublincore - data << tex.tail + def tail(data) + tex=SiSU_TexInfoFormat::Texinfo.new(@md) + objs_txt=[] + data.each do |dob| + if dob.obj \ + && (dob.is !=:structure \ + && dob.is !=:comment) + objs_txt << dob.obj if dob.obj + end + end + objs_txt << tex.dublincore << tex.tail + objs_txt end - def output - data=@data - data.compact! + def output(data) filename_texinfo=%{#{@env.processing_path.texi}/#{@md.fnb}.texinfo} file_texinfo=File.new(filename_texinfo,'w+') puts filename_texinfo if @md.opt.cmd =~/M/ @@ -378,9 +395,9 @@ module SiSU_TexInfo pwd=Dir.pwd case sfx when /(?:-|ssm\.)?sst$/ - @env=SiSU_Env::Info_env.new(@md.fns,@md.opt.cmd) + @env=SiSU_Env::InfoEnv.new(@md.fns,@md.opt.cmd) Dir.chdir(@env.processing_path.texi) - texinfo=SiSU_Env::System_call.new("#{fnb}.texinfo") + texinfo=SiSU_Env::SystemCall.new("#{fnb}.texinfo") texinfo.makeinfo end Dir.chdir(pwd) -- cgit v1.2.3