diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-06-19 19:17:23 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-06-19 19:17:23 -0400 |
commit | 83137da0f259e8366eba7f626319b5a5b9b27d6d (patch) | |
tree | 761c81279d2b228ba17535a06970f792cbfd7b45 /lib/sisu/v5 | |
parent | v5 v6: ao, misc, mostly minor cleaning (diff) |
v5 v6: indent spaces, minor
Diffstat (limited to 'lib/sisu/v5')
-rw-r--r-- | lib/sisu/v5/digests.rb | 17 | ||||
-rw-r--r-- | lib/sisu/v5/harvest_topics.rb | 77 | ||||
-rw-r--r-- | lib/sisu/v5/qrcode.rb | 8 | ||||
-rw-r--r-- | lib/sisu/v5/xml_docbook5.rb | 74 | ||||
-rw-r--r-- | lib/sisu/v5/xml_fictionbook2.rb | 68 | ||||
-rw-r--r-- | lib/sisu/v5/xml_scaffold_structure_collapsed.rb | 53 | ||||
-rw-r--r-- | lib/sisu/v5/xml_scaffold_structure_sisu.rb | 55 |
7 files changed, 182 insertions, 170 deletions
diff --git a/lib/sisu/v5/digests.rb b/lib/sisu/v5/digests.rb index 6cea7c3e..06851739 100644 --- a/lib/sisu/v5/digests.rb +++ b/lib/sisu/v5/digests.rb @@ -134,6 +134,9 @@ module SiSU_DigestView supplementary output end + def spaces + Ax[:spaces] + end def description(f,e='') puts f + e.to_s if @md.opt.act[:verbose_plus][:set]==:on @@description << f << e @@ -234,19 +237,19 @@ module SiSU_DigestView if t_o.is==:heading x=case t_o.ln when 0 then l[0] +=1 - ' '*0 << ':A' + spaces*0 << ':A' when 1 then l[1] +=1 - ' '*1 << ':B' + spaces*1 << ':B' when 2 then l[2] +=1 - ' '*2 << ':C' + spaces*2 << ':C' when 3 then l[3] +=1 - ' '*3 << ':D' + spaces*3 << ':D' when 4 then l[4] +=1 - ' '*4 << '1' + spaces*4 << '1' when 5 then l[5] +=1 - ' '*5 << '2' + spaces*5 << '2' when 6 then l[6] +=1 - ' '*6 << '3' + spaces*6 << '3' else nil end end diff --git a/lib/sisu/v5/harvest_topics.rb b/lib/sisu/v5/harvest_topics.rb index aeca5246..09739200 100644 --- a/lib/sisu/v5/harvest_topics.rb +++ b/lib/sisu/v5/harvest_topics.rb @@ -97,6 +97,11 @@ module SiSU_HarvestTopics SiSU_HarvestTopics::OutputIndex.new(@opt,the_hash).html_print.html_songsheet end end + class Mix + def spaces + Ax[:spaces] + end + end class Harvest def initialize(opt,env,data,filename,name,idx_array,lang) @opt,@env,@data,@filename,@name,@idx_array,@lang=opt,env,data,filename,name,idx_array,lang @@ -160,7 +165,7 @@ module SiSU_HarvestTopics idx_array end end - class Index + class Index < Mix def initialize(opt,env,idx_array,the_idx) @opt,@env,@idx_array,@the_idx=opt,env,idx_array,the_idx @@the_idx_topics=@the_idx @@ -313,7 +318,7 @@ module SiSU_HarvestTopics else @the_h[x0] ||={} end - #puts ' '*0 + x0 + #puts spaces*0 + x0 if extract >= 1 y0.each_pair do |x1,y1| if extract == 1 @@ -322,7 +327,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1] ||={} end - #puts ' '*1 + x1 + #puts spaces*1 + x1 if extract >= 2 y1.each_pair do |x2,y2| if extract == 2 @@ -331,7 +336,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2] ||={} end - #puts ' '*2 + x2 + #puts spaces*2 + x2 if extract >= 3 y2.each_pair do |x3,y3| if extract == 3 @@ -340,7 +345,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2][x3] ||={} end - #puts ' '*3 + x3 + #puts spaces*3 + x3 if extract == 4 y3.each_pair do |x4,y4| if extract == 4 @@ -349,14 +354,14 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2][x3][x4] ||={} end - #puts ' '*4 + x4 + #puts spaces*4 + x4 if extract == 5 y4.each_pair do |x5,y5| if extract == 5 @the_h[x0][x1][x2][x3][x4][x5] ||={ md: [] } @the_h[x0][x1][x2][x3][x4][x5][:md] << y5 end - #puts ' '*5 + x5 + #puts spaces*5 + x5 end end end @@ -375,22 +380,22 @@ module SiSU_HarvestTopics end def traverse_base @the_h.each_pair do |x0,y0| - puts ' '*0 + x0 if x0.is_a?(String) + puts spaces*0 + x0 if x0.is_a?(String) if y0.is_a?(Hash) y0.each_pair do |x1,y1| - puts ' '*1 + x1 if x1.is_a?(String) + puts spaces*1 + x1 if x1.is_a?(String) if y1.is_a?(Hash) y1.each_pair do |x2,y2| - puts ' '*2 + x2 if x2.is_a?(String) + puts spaces*2 + x2 if x2.is_a?(String) if y2.is_a?(Hash) y2.each_pair do |x3,y3| - puts ' '*3 + x3 if x3.is_a?(String) + puts spaces*3 + x3 if x3.is_a?(String) if y3.is_a?(Hash) y3.each_pair do |x4,y4| - puts ' '*4 + x4 if x4.is_a?(String) + puts spaces*4 + x4 if x4.is_a?(String) if y4.is_a?(Hash) y4.each_pair do |x5,y5| - puts ' '*5 + x5 if x5.is_a?(String) + puts spaces*5 + x5 if x5.is_a?(String) end end end @@ -405,37 +410,37 @@ module SiSU_HarvestTopics end def traverse @the_h.each_pair do |x0,y0| - puts ' '*0 + x0 if x0.is_a?(String) + puts spaces*0 + x0 if x0.is_a?(String) if y0.is_a?(Hash) if y0.has_key?(:md) - y0[:md].each { |x| puts ' '*5 + x[:title] } + y0[:md].each { |x| puts spaces*5 + x[:title] } end y0.each_pair do |x1,y1| - puts ' '*1 + x1 if x1.is_a?(String) + puts spaces*1 + x1 if x1.is_a?(String) if y1.is_a?(Hash) if y1.has_key?(:md) - y1[:md].each { |x| puts ' '*5 + x[:title] } + y1[:md].each { |x| puts spaces*5 + x[:title] } end y1.each_pair do |x2,y2| - puts ' '*2 + x2 if x2.is_a?(String) + puts spaces*2 + x2 if x2.is_a?(String) if y2.is_a?(Hash) if y2.has_key?(:md) - y2[:md].each { |x| puts ' '*5 + x[:title] } + y2[:md].each { |x| puts spaces*5 + x[:title] } end y2.each_pair do |x3,y3| - puts ' '*3 + x3 if x3.is_a?(String) + puts spaces*3 + x3 if x3.is_a?(String) if y3.is_a?(Hash) if y3.has_key?(:md) - y3[:md].each { |x| puts ' '*5 + x[:title] } + y3[:md].each { |x| puts spaces*5 + x[:title] } end y3.each_pair do |x4,y4| - puts ' '*4 + x4 if x4.is_a?(String) + puts spaces*4 + x4 if x4.is_a?(String) if y4.is_a?(Hash) if y4.has_key?(:md) - y4[:md].each { |x| puts ' '*5 + x[:title] } + y4[:md].each { |x| puts spaces*5 + x[:title] } end y4.each_pair do |x5,y5| - puts ' '*5 + x4 if x4.is_a?(String) + puts spaces*5 + x4 if x4.is_a?(String) end end end @@ -449,7 +454,7 @@ module SiSU_HarvestTopics end end end - class OutputIndex + class OutputIndex < Mix require_relative 'i18n' # i18n.rb def initialize(opt,the_idx) @opt,@the_idx=opt,the_idx @@ -509,67 +514,67 @@ module SiSU_HarvestTopics lng=x0 if x0.is_a?(String) #do_string_name(lng,'lev0',x0) - #puts ' '*0 + x0 + #puts spaces*0 + x0 end if y0.is_a?(Hash) if y0.has_key?(:md) y0[:md].each do |x| #do_hash(lng,attrib,x) #lv==0 ? - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y0.each_pair do |x1,y1| if x1.is_a?(String) do_string_name(lng,'lev0',x1) - #puts ' '*1 + x1 + #puts spaces*1 + x1 end if y1.is_a?(Hash) if y1.has_key?(:md) y1[:md].each do |x| do_hash(lng,0,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y1.each_pair do |x2,y2| if x2.is_a?(String) do_string(lng,'lev1',x2) - #puts ' '*2 + x2 + #puts spaces*2 + x2 end if y2.is_a?(Hash) if y2.has_key?(:md) y2[:md].each do |x| do_hash(lng,1,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y2.each_pair do |x3,y3| if x3.is_a?(String) do_string(lng,'lev2',x3) - #puts ' '*3 + x3 + #puts spaces*3 + x3 end if y3.is_a?(Hash) if y3.has_key?(:md) y3[:md].each do |x| do_hash(lng,2,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y3.each_pair do |x4,y4| if x4.is_a?(String) do_string(lng,'lev3',x4) - #puts ' '*4 + x4 + #puts spaces*4 + x4 end if y4.is_a?(Hash) if y4.has_key?(:md) y4[:md].each do |x| do_hash(lng,3,x) - #puts ' '*5 + x[:title] + #puts spaces*5 + x[:title] end end y4.each_pair do |x5,y5| if x5.is_a?(String) do_string(lng,'lev4',x5) - #puts ' '*5 + x5 + #puts spaces*5 + x5 end end end diff --git a/lib/sisu/v5/qrcode.rb b/lib/sisu/v5/qrcode.rb index 66584198..e17b1d86 100644 --- a/lib/sisu/v5/qrcode.rb +++ b/lib/sisu/v5/qrcode.rb @@ -124,6 +124,9 @@ module SiSU_QRcode @brace_url=SiSU_Viz::Defaults.new.url_decoration @f.make_path(@f.output_path.qrcode.dir) end + def spaces + Ax[:spaces] + end def output_metadata fn=@f.base_filename.manifest_txt mn='' @@ -666,14 +669,13 @@ WOK if defined? @md.topic_register_array \ and @md.topic_register_array.length > 0 @manifest[:txt] << %{#{@translate.topic_register}:\n} -@sp=' ' @md.topic_register_array.each do |t| t.each_with_index do |st,i| if st.is_a?(Array) st.each do |v| - @manifest[:txt] << %{#{@sp*i}#{v}\n} + @manifest[:txt] << %{#{spaces*i}#{v}\n} end - else @manifest[:txt] << %{#{@sp*i}#{st}\n} + else @manifest[:txt] << %{#{spaces*i}#{st}\n} end end end diff --git a/lib/sisu/v5/xml_docbook5.rb b/lib/sisu/v5/xml_docbook5.rb index 45e6f0cf..98450520 100644 --- a/lib/sisu/v5/xml_docbook5.rb +++ b/lib/sisu/v5/xml_docbook5.rb @@ -127,8 +127,8 @@ module SiSU_XML_Docbook_Book structure_build_collapsed(data) #tail end - def space - ' ' + def spaces + Ax[:spaces] end def tags # collapsed --> @@ -176,7 +176,7 @@ module SiSU_XML_Docbook_Book end def output(o,comment='') puts o.lc == (0..6) \ - ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" + ? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" end def structure_collapsed(data) @@ -213,21 +213,21 @@ module SiSU_XML_Docbook_Book @splv=o.lc tag_id=o.tags[0] ? %{ id="#{o.tags[0]}" } : '' if doc_position ==:head - filename_docbook.puts %{#{space*o.lc}<title#{id}>} + filename_docbook.puts %{#{spaces*o.lc}<title#{id}>} doc_position=:body_and_tail else filename_docbook.puts structure_build_tag_close(o.lc,h) - filename_docbook.puts %{#{space*(o.lc)}<#{tags.docbook(o.lc,chlv)}#{tag_id}> -#{space*o.lc}<title#{id}> + filename_docbook.puts %{#{spaces*(o.lc)}<#{tags.docbook(o.lc,chlv)}#{tag_id}> +#{spaces*o.lc}<title#{id}> } end filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap - filename_docbook.puts %{#{space*o.lc}</title>} + filename_docbook.puts %{#{spaces*o.lc}</title>} h=o.lc elsif (o.of ==:para or o.of ==:block) - filename_docbook.puts "#{space*(@splv)}<para#{id}>" + filename_docbook.puts "#{spaces*(@splv)}<para#{id}>" filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj + ocn,80,(@splv*2+2)).line_wrap - filename_docbook.puts "#{space*(@splv)}</para>" + filename_docbook.puts "#{spaces*(@splv)}</para>" end end filename_docbook.puts structure_build_tag_close(0,h) @@ -237,40 +237,40 @@ module SiSU_XML_Docbook_Book x=[] case h when 0 - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 1 - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 2 - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 3 - x << "#{space*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 4 - x << "#{space*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) - x << "#{space*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 5 - x << "#{space*5}</#{tags.docbook(5)}>" if (lc <= 5) - x << "#{space*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) - x << "#{space*5}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*5}</#{tags.docbook(5)}>" if (lc <= 5) + x << "#{spaces*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) + x << "#{spaces*5}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) when 6 - x << "#{space*6}</#{tags.docbook(6)}>" if (lc <= 6) - x << "#{space*5}</#{tags.docbook(5)}>" if (lc <= 5) - x << "#{space*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) - x << "#{space*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) - x << "#{space*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) - x << "#{space*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) - x << "#{space*0}</#{tags.docbook(0)}>" if (lc <= 0) + x << "#{spaces*6}</#{tags.docbook(6)}>" if (lc <= 6) + x << "#{spaces*5}</#{tags.docbook(5)}>" if (lc <= 5) + x << "#{spaces*4}</#{tags.docbook(4,@chlv)}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.docbook(3,@chlv)}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.docbook(2,@chlv)}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.docbook(1,@chlv)}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.docbook(0)}>" if (lc <= 0) end x.join("\n") end diff --git a/lib/sisu/v5/xml_fictionbook2.rb b/lib/sisu/v5/xml_fictionbook2.rb index 32a7bc76..f890b329 100644 --- a/lib/sisu/v5/xml_fictionbook2.rb +++ b/lib/sisu/v5/xml_fictionbook2.rb @@ -126,8 +126,8 @@ module SiSU_XML_Fictionbook data=markup_text(data) structure_build_collapsed(data,endnotes,images_base64) end - def space - ' ' + def spaces + Ax[:spaces] end def tags # collapsed --> @@ -278,7 +278,7 @@ module SiSU_XML_Fictionbook end def output(o,comment='') puts o.lc == (0..6) \ - ? "#{space*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" + ? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" end def structure_collapsed(data) @@ -315,11 +315,11 @@ module SiSU_XML_Fictionbook filename_fictionbook.puts structure_build_tag_close(o.lc,h) end doc_position=:body_and_tail - filename_fictionbook.puts %{#{space*o.lc}<#{tags.fictionbook[o.lc]}> -#{space*o.lc}<title> + filename_fictionbook.puts %{#{spaces*o.lc}<#{tags.fictionbook[o.lc]}> +#{spaces*o.lc}<title> } filename_fictionbook.puts SiSU_TextUtils::Wrap.new("<p>#{o.obj}#{ocn}</p>",80,(o.lc*2+2)).line_wrap - filename_fictionbook.puts %{#{space*o.lc}</title>} + filename_fictionbook.puts %{#{spaces*o.lc}</title>} h=o.lc elsif o.is ==:heading_insert \ and o.obj =~/Endnotes/ \ @@ -338,40 +338,40 @@ module SiSU_XML_Fictionbook x=[] case h when 0 - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 1 - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 2 - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 3 - x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 4 - x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4) - x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*4}</#{tags.fictionbook[4]}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 5 - x << "#{space*5}</#{tags.fictionbook[5]}>" if (lc <= 5) - x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4) - x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*5}</#{tags.fictionbook[5]}>" if (lc <= 5) + x << "#{spaces*4}</#{tags.fictionbook[4]}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) when 6 - x << "#{space*6}</#{tags.fictionbook[6]}>" if (lc <= 6) - x << "#{space*5}</#{tags.fictionbook[5]}>" if (lc <= 5) - x << "#{space*4}</#{tags.fictionbook[4]}>" if (lc <= 4) - x << "#{space*3}</#{tags.fictionbook[3]}>" if (lc <= 3) - x << "#{space*2}</#{tags.fictionbook[2]}>" if (lc <= 2) - x << "#{space*1}</#{tags.fictionbook[1]}>" if (lc <= 1) - x << "#{space*0}</#{tags.fictionbook[0]}>" if (lc <= 0) + x << "#{spaces*6}</#{tags.fictionbook[6]}>" if (lc <= 6) + x << "#{spaces*5}</#{tags.fictionbook[5]}>" if (lc <= 5) + x << "#{spaces*4}</#{tags.fictionbook[4]}>" if (lc <= 4) + x << "#{spaces*3}</#{tags.fictionbook[3]}>" if (lc <= 3) + x << "#{spaces*2}</#{tags.fictionbook[2]}>" if (lc <= 2) + x << "#{spaces*1}</#{tags.fictionbook[1]}>" if (lc <= 1) + x << "#{spaces*0}</#{tags.fictionbook[0]}>" if (lc <= 0) end x.join("\n") end diff --git a/lib/sisu/v5/xml_scaffold_structure_collapsed.rb b/lib/sisu/v5/xml_scaffold_structure_collapsed.rb index b6430159..0395d090 100644 --- a/lib/sisu/v5/xml_scaffold_structure_collapsed.rb +++ b/lib/sisu/v5/xml_scaffold_structure_collapsed.rb @@ -70,7 +70,9 @@ module SiSU_XML_Scaffold_Structure_Collapse def initialize(opt) @opt=opt @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - @sp=' ' + end + def spaces + Ax[:spaces] end def read begin @@ -87,7 +89,6 @@ module SiSU_XML_Scaffold_Structure_Collapse class Scroll <Source def initialize(data='',md='') @data,@md=data,md - @sp=' ' end def songsheet @t='sisu' @@ -116,8 +117,8 @@ module SiSU_XML_Scaffold_Structure_Collapse self end def output(o,lev=nil,comment='') - puts lev == 0..6 \ - ? "#{@sp*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" + puts lev == (0..6) \ + ? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" end def structure_collapsed(data) @@ -137,7 +138,7 @@ module SiSU_XML_Scaffold_Structure_Collapse if (o.is ==:heading || o.is ==:heading_insert) lev=o.lc structure_build_tag_close(lev,h) - puts "#{@sp*lev}<#{@s[lev]}>\n#{@sp*lev} [#{o.ocn}] #{lev} {#{o.node}}" + puts "#{spaces*lev}<#{@s[lev]}>\n#{spaces*lev} [#{o.ocn}] #{lev} {#{o.node}}" h[0]=lev end end @@ -146,37 +147,37 @@ module SiSU_XML_Scaffold_Structure_Collapse def structure_build_tag_close(lev,h) case h[0] when 1 - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 2 - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 3 - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 4 - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 5 - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) when 6 - puts "#{@sp*6}</#{@s[6]}>" if (lev <= 6) - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) + puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6) + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) puts "</#{@s[0]}>" if (lev==0) end end diff --git a/lib/sisu/v5/xml_scaffold_structure_sisu.rb b/lib/sisu/v5/xml_scaffold_structure_sisu.rb index 5e2afa4d..39ca1e6a 100644 --- a/lib/sisu/v5/xml_scaffold_structure_sisu.rb +++ b/lib/sisu/v5/xml_scaffold_structure_sisu.rb @@ -70,7 +70,9 @@ module SiSU_XML_Scaffold_Structure_Sisu def initialize(opt) @opt=opt @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - @sp=' ' + end + def spaces + Ax[:spaces] end def read begin @@ -87,7 +89,6 @@ module SiSU_XML_Scaffold_Structure_Sisu class Scroll <Source def initialize(data='',md='') @data,@md=data,md - @sp=' ' end def songsheet @t='sisu' @@ -114,13 +115,13 @@ module SiSU_XML_Scaffold_Structure_Sisu puts "\nsisu structure, heading outline --->\n\n" data.each_with_index do |o,i| if (o.is ==:heading || o.is ==:heading_insert) - puts "#{@sp*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}</#{tags.sisu[o.ln]}>" + puts "#{spaces*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}</#{tags.sisu[o.ln]}>" end end end def output(o,lev=nil,comment='') - puts lev == 0..6 \ - ? "#{@sp*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" + puts lev == (0..6) \ + ? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" : "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}" end def structure_build_sisu(data) @@ -131,7 +132,7 @@ module SiSU_XML_Scaffold_Structure_Sisu data.each_with_index do |o,i| if (o.is ==:heading || o.is ==:heading_insert) structure_build_tag_close(o.ln,h) - puts "#{@sp*o.ln}<#{@s[o.ln]}>\n#{@sp*o.ln} [#{o.ocn}] #{o.ln} {#{o.node}}" + puts "#{spaces*o.ln}<#{@s[o.ln]}>\n#{spaces*o.ln} [#{o.ocn}] #{o.ln} {#{o.node}}" case o.ln when 1 h=[o.ln,true,false,false] @@ -149,37 +150,37 @@ module SiSU_XML_Scaffold_Structure_Sisu def structure_build_tag_close(lev,h) case h[0] when 1 - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 2 - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 3 - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 4 - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 5 - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) when 6 - puts "#{@sp*6}</#{@s[6]}>" if (lev <= 6) - puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) - puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) - puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) && h[3] - puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) && h[2] - puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) && h[1] + puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6) + puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5) + puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4) + puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3] + puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2] + puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1] puts "</#{@s[0]}>" if (lev==0) end end |