aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3dv/texinfo.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3dv/texinfo.rb')
-rw-r--r--lib/sisu/v3dv/texinfo.rb119
1 files changed, 69 insertions, 50 deletions
diff --git a/lib/sisu/v3dv/texinfo.rb b/lib/sisu/v3dv/texinfo.rb
index 121cf1ae..145712e1 100644
--- a/lib/sisu/v3dv/texinfo.rb
+++ b/lib/sisu/v3dv/texinfo.rb
@@ -137,19 +137,22 @@ module SiSU_TexInfo
end
def songsheet
begin
- @data=pre
- @data=endnote
- @data=markup
- @data=tail
- output
+ data=@data
+ data=pre(data)
+ data=endnote(data)
+ data=markup(data)
+ objects=tail(data)
+ #output(objects)
+ output(@tex_file)
+ #output(data.compact)
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
@@ -161,13 +164,15 @@ module SiSU_TexInfo
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_new=@data,[]
+ def endnote(data)
+ data_new=[]
data.each do |dob|
- if dob.of=~/para|block/
+ 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
@@ -176,24 +181,24 @@ module SiSU_TexInfo
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 +206,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,13 +218,15 @@ module SiSU_TexInfo
end
end
@tex_file << dob.obj
+ data_new << dob
end
+ data_new
end
def code_lines
data,data_new=@data,[]
data.each do |line|
- if line =~ /\S/ \
- and line !~ /#{Mx[:gr_o]}(code|verse).+/ #fix
+ 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']
@@ -230,7 +237,7 @@ module SiSU_TexInfo
end
end
def tables
- data=@data
+ data,data_new=@data,[]
@tex_file=[]
@@tableheader=0
data.each do |dob|
@@ -239,10 +246,12 @@ module SiSU_TexInfo
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"
@@ -254,12 +263,12 @@ module SiSU_TexInfo
n_menu,n_submenu=0,0
@submenu,@subsubmenu={},{}
data.each do |dob|
- if dob.is =='heading' \
- and dob.ln.to_s =~ /^[1-3]$/
+ 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]$/
+ elsif dob.is ==:heading \
+ && (dob.ln.to_s =~ /^[4-6]$/)
toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob)
texinfo_menu << toc.menu
case dob.ln
@@ -278,7 +287,9 @@ module SiSU_TexInfo
else
dob.obj=dob.obj.gsub(/\s*(?:<:?br>|<br \/>)\s*/,"\n\n")
end
+ data_new << dob
end
+ data=data_new
texinfo_menu=texinfo_menu.compact
texinfo_menu << "* Dublin Core::"
@tex_file << texinfo_menu
@@ -287,15 +298,16 @@ 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_TexInfoFormat::Texinfo.new(@md,dob)
- if dob.is=='heading'
+ 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;
@@ -305,7 +317,7 @@ module SiSU_TexInfo
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
@@ -313,37 +325,42 @@ module SiSU_TexInfo
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=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
+ if dob.obj \
+ && (dob.is !=:structure \
+ && dob.is !=:comment)
+ @tex_file << dob.obj
+ end
+ data_new << dob
end
- data=@tex_file
+ data_new
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*<!h-.+?-!>/ \
- and dob.obj !~ /<:\d-endnotes>/
+ if (@md.markup =~ /num_top/i) \
+ && (dob.obj !~ /#{Rx[:meta]}/)
+ if (dob.obj =~ /^[1-6]\\+(?:~\S+)?\s*<!h-.+?-!>/) \
+ && (dob.obj !~ /<:\d-endnotes>/)
header=dob.obj[/<!h-(.+?)-!>/m, 1].gsub(/-/m,'.')
dob.obj=dob.obj.gsub(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*<!h-.+?-!>/,
"\\1 #{header} ")
@@ -355,16 +372,18 @@ module SiSU_TexInfo
end
@tex_file << dob.obj
end
- data=@tex_file
+ data_new << dob
end
- def tail
- data=@data
+ def tail(data)
tex=SiSU_TexInfoFormat::Texinfo.new(@md)
- data << tex.dublincore
- data << tex.tail
+ objects=[]
+ data.each do |dob|
+ objects << dob.obj if dob.obj
+ end
+ objects << tex.dublincore << tex.tail
+ objects
end
- def output
- 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/