aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/html_segments.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-08-08 00:34:25 -0400
committerRalph Amissah <ralph@amissah.com>2014-08-08 00:36:15 -0400
commit6bc3b814011e829db684ec96bb3abd1e4abb29c3 (patch)
tree72d759c1d89a72c4fc5e3c46f6917f69e72699e6 /lib/sisu/v5/html_segments.rb
parentv5: merged v6 libraries (diff)
v5 v6: extend document structure, headings A - D, 1 - 4
* sql db table structure changed (needs to be rebuilt)
Diffstat (limited to 'lib/sisu/v5/html_segments.rb')
-rw-r--r--lib/sisu/v5/html_segments.rb145
1 files changed, 109 insertions, 36 deletions
diff --git a/lib/sisu/v5/html_segments.rb b/lib/sisu/v5/html_segments.rb
index f58bae6a..9b0cc1c7 100644
--- a/lib/sisu/v5/html_segments.rb
+++ b/lib/sisu/v5/html_segments.rb
@@ -67,7 +67,8 @@ module SiSU_HTML_Seg
require_relative 'shared_metadata' # shared_metadata.rb
class Output
def initialize(md,outputfile,seg,minitoc,type='')
- @md,@output_seg_file,@seg,@minitoc,@type=md,outputfile,seg,minitoc,type
+ @md, @output_seg_file,@seg,@minitoc,@type=
+ md,outputfile, seg,minitoc, type
@title_banner_=SiSU_Env::CreateSite.new(@md.opt).html_seg_title_banner?
@file=SiSU_Env::FileOp.new(@md)
@make=SiSU_Env::ProcessingSettings.new(@md)
@@ -79,59 +80,97 @@ module SiSU_HTML_Seg
if @seg[:title] =~/\S/
filename_seg=[]
if @make.build.html_top_band?
- filename_seg << @seg[:title] << @seg[:tocband_banner]
+ filename_seg \
+ << @seg[:title] \
+ << @seg[:tocband_banner]
else
- filename_seg << @seg[:title]
+ filename_seg \
+ << @seg[:title]
end
if @type=='endnotes'
@seg[:headings]=[]
format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
if @title_banner_
- @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author)
+ @seg[:headings] \
+ << format_head_seg.
+ title_banner(@md.title.main,@md.title.sub,@author)
end
txt_obj={ txt: 'Endnotes', ocn_display: '' }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @seg[:headings] << format_seg.title_heading1
- filename_seg << @seg[:heading_endnotes] << @minitoc << @seg[:headings] << %{\n<div class="#{@cl}">\n} << @seg[:endnote_all] << '</div>' # << '</div>'
+ @seg[:headings] \
+ << format_seg.title_heading1
+ filename_seg \
+ << @seg[:heading_endnotes] \
+ << @minitoc << @seg[:headings] \
+ << %{\n<div class="#{@cl}">\n} \
+ << @seg[:endnote_all] \
+ << '</div>' # << '</div>'
elsif @type=='idx'
@seg[:headings]=[]
format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
if @title_banner_
- @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author)
+ @seg[:headings] \
+ << format_head_seg.
+ title_banner(@md.title.main,@md.title.sub,@author)
end
txt_obj={ txt: 'Index', ocn_display: '' }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
@seg[:headings] << format_seg.title_heading1
- filename_seg << @seg[:heading_idx] << @minitoc << @seg[:headings] << %{\n<div class="#{@cl}">\n} << @seg[:idx] << '</div>' # << '</div>'
+ filename_seg \
+ << @seg[:heading_idx] \
+ << @minitoc << @seg[:headings] \
+ << %{\n<div class="#{@cl}">\n} \
+ << @seg[:idx] \
+ << '</div>' # << '</div>'
elsif @type=='metadata'
metadata=SiSU_Metadata::Summary.new(@md).xhtml_display.metadata
@seg[:headings]=[]
format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
if @title_banner_
- @seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author)
+ @seg[:headings] \
+ << format_head_seg.
+ title_banner(@md.title.main,@md.title.sub,@author)
end
txt_obj={ txt: 'Metadata', ocn_display: '' }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
@seg[:headings] << format_seg.title_heading1
- filename_seg << @seg[:heading_idx] << @minitoc << @seg[:headings] << %{\n<div class="#{@cl}">\n} << metadata << '</div>' # << '</div>'
+ filename_seg \
+ << @seg[:heading_idx] \
+ << @minitoc \
+ << @seg[:headings] \
+ << %{\n<div class="#{@cl}">\n} \
+ << metadata \
+ << '</div>' # << '</div>'
else
if @make.build.html_top_band?
- filename_seg << @minitoc << @seg[:headings] << @seg[:main] << "\n</div>\n"
+ filename_seg \
+ << @minitoc \
+ << @seg[:headings] \
+ << @seg[:main] \
+ << "\n</div>\n"
else
- filename_seg << @minitoc << @seg[:main] << "\n</div>\n"
+ filename_seg \
+ << @minitoc \
+ << @seg[:main] \
+ << "\n</div>\n"
end
end
filename_seg <<=if @make.build.html_top_band?
- @seg[:tail] << @seg[:tocband_bannerless] << @seg[:credits]
+ @seg[:tail] \
+ << @seg[:tocband_bannerless] \
+ << @seg[:credits]
else
- @seg[:tail] << @seg[:credits]
+ @seg[:tail] \
+ << @seg[:credits]
end
filename_seg=filename_seg.flatten.compact #watch
filename_seg.each do |str|
unless str =~/\A\s*\Z/
str=str.strip.
- gsub(Xx[:html_relative2],@file.path_rel_links.html_seg_2).
- gsub(Xx[:html_relative1],@file.path_rel_links.html_seg_1)
+ gsub(Xx[:html_relative2],
+ @file.path_rel_links.html_seg_2).
+ gsub(Xx[:html_relative1],
+ @file.path_rel_links.html_seg_1)
@output_seg_file << str
end
end
@@ -146,7 +185,17 @@ module SiSU_HTML_Seg
@@loop_count=@@seg_total=@@tracker=0
@@is4=@@is3=@@is2=@@is1=@@is0=0
@@heading0=@@heading1=@@heading2=@@heading3=@@heading4=0
- @@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:title],@@seg[:headings],@@seg[:main],@@seg[:idx],@@seg[:tail],@@seg[:credits],@@seg_subtoc_array,@@seg_endnotes_array,@@seg[:endnote_all]=Array.new(11){[]}
+ @@seg[:tocband_banner],
+ @@seg[:tocband_bannerless],
+ @@seg[:title],@@seg[:headings],
+ @@seg[:main],
+ @@seg[:idx],
+ @@seg[:tail],
+ @@seg[:credits],
+ @@seg_subtoc_array,
+ @@seg_endnotes_array,
+ @@seg[:endnote_all]=
+ Array.new(11){[]}
@@seg[:heading_endnotes]=''
@@tablehead,@@number_of_cols=0,0
@@dp,@@segtocband=nil,nil
@@ -192,7 +241,8 @@ module SiSU_HTML_Seg
idx_html=nil
if @md.book_idx
#my_make_source_file=SiSU_Env::CreateFile.new(@md.fns)
- idx_html=SiSU_Particulars::CombinedSingleton.instance.get_idx_html(@md.opt).html_idx
+ idx_html=SiSU_Particulars::CombinedSingleton.
+ instance.get_idx_html(@md.opt).html_idx
idx_html.each {|x| @@seg[:idx] << x }
@@seg[:heading_idx]=''
end
@@ -215,7 +265,8 @@ module SiSU_HTML_Seg
@@seg_name.length
).segmented
end
- map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags
+ map_nametags=SiSU_Particulars::CombinedSingleton.
+ instance.get_map_nametags(@md).nametags_map #p map_nametags
data.each do |dob|
if defined? dob.obj \
and dob.obj =~/href="#{Xx[:segment]}#+\S+?"/
@@ -227,10 +278,12 @@ module SiSU_HTML_Seg
lng=(inf.output_dir_structure.by_language_code?) \
? ''
: '.' + @md.opt.lng
- dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{lng}#{Sfx[:html]}#\\1"})
+ dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,
+ %{href="#{map_nametags[m][:segname]}#{lng}#{Sfx[:html]}#\\1"})
else
p "NOT FOUND name_tags: #{m}"
- dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#\\1"}) # not satisfactory
+ dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,
+ %{href="#\\1"}) # not satisfactory
end
end
end
@@ -281,7 +334,8 @@ module SiSU_HTML_Seg
if tracking != 0
@file=SiSU_Env::FileOp.new(@md)
unless FileTest.directory?(@file.output_path.html_seg.dir)
- FileUtils::mkdir_p(@file.output_path.html_seg.dir) if File.writable?("#{@file.output_path.base.dir}/.")
+ FileUtils::mkdir_p(@file.output_path.html_seg.dir) \
+ if File.writable?("#{@file.output_path.base.dir}/.")
end
SiSU_HTML_Seg::Seg.new(@md).tail
fnh={
@@ -357,7 +411,7 @@ module SiSU_HTML_Seg
&& (@make.build.html_navigation_bar?)
x=if (dob.is==:heading \
|| dob.is==:heading_insert) \
- && (dob.ln.to_s =~/^[0-6]/)
+ && (dob.ln.to_s =~/^[0-7]/)
x=if @@tracker < @@seg_total-1
format_head_seg.dot_control_pre_next
else
@@ -387,10 +441,14 @@ module SiSU_HTML_Seg
@p_num ||= ''
if @@is0==1
@author=%{<b>#{@md.author}</b>\n} if @md.author.to_s =~/\S/
- @@seg[:tocband_banner] << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav])
- @@seg[:tocband_bannerless] << '<br />' << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav])
+ @@seg[:tocband_banner] \
+ << format_head_seg.navigation_band(@@segtocband,@@seg[:dot_nav])
+ @@seg[:tocband_bannerless] \
+ << '<br />' \
+ << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav])
if @title_banner_
- @@seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'')
+ @@seg[:headings] \
+ << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'')
end
ocn=(@@heading0[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \
? $1
@@ -398,8 +456,10 @@ module SiSU_HTML_Seg
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
txt_obj={ txt: @@heading0, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading0.gsub(clean,'')
- @@heading0=@@heading0.gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
+ @@seg[:headings] \
+ << format_seg.title_heading0.gsub(clean,'')
+ @@heading0=@@heading0.
+ gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
end
if @@is1==1
heading1=@@heading1
@@ -409,8 +469,10 @@ module SiSU_HTML_Seg
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
txt_obj={ txt: heading1, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading1.gsub(clean,'')
- @@heading1=@@heading1.gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
+ @@seg[:headings] \
+ << format_seg.title_heading1.gsub(clean,'')
+ @@heading1=@@heading1.
+ gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
end
if @@is2==1
heading2=@@heading2
@@ -420,8 +482,10 @@ module SiSU_HTML_Seg
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading2.gsub(clean,'')
- @@heading2=@@heading2.gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
+ @@seg[:headings] \
+ << format_seg.title_heading2.gsub(clean,'')
+ @@heading2=@@heading2.
+ gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
end
if @@is3==1
heading3=@@heading3
@@ -431,8 +495,10 @@ module SiSU_HTML_Seg
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading3.gsub(clean,'')
- @@heading3=@@heading3.gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
+ @@seg[:headings] \
+ << format_seg.title_heading3.gsub(clean,'')
+ @@heading3=@@heading3.
+ gsub(/&nbsp;<a name="-[\d*+]+" href="#_[\d*+]+">&nbsp;<sup>[\d*+]+<\/sup>&nbsp;<\/a>/,'')
end
if @@is4==1
heading4=@@heading4
@@ -442,7 +508,8 @@ module SiSU_HTML_Seg
@p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
txt_obj={ txt: heading4, ocn_display: @p_num.ocn_display }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
- @@seg[:headings] << format_seg.title_heading4.gsub(clean,'')
+ @@seg[:headings] \
+ << format_seg.title_heading4.gsub(clean,'')
end
@@tracker=@@tracker+1
end
@@ -467,6 +534,8 @@ module SiSU_HTML_Seg
sto.seg_heading5
elsif dob.ln==6
sto.seg_heading6
+ elsif dob.ln==7
+ sto.seg_heading6
end
elsif dob.is==:para
if dob.indent \
@@ -589,7 +658,7 @@ module SiSU_HTML_Seg
end
end
if dob.is==:heading \
- && (dob.ln.to_s =~/^[56]/)
+ && (dob.ln.to_s =~/^[5-7]/)
case dob.ln
when 5
txt_obj={ txt: dob.obj.strip, ocn: dob.ocn }
@@ -599,6 +668,10 @@ module SiSU_HTML_Seg
txt_obj={ txt: dob.obj.strip, ocn: dob.ocn }
format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
subtoc=format_seg.subtoc_lev6 #keep and make available, this is the subtoc
+ when 7
+ txt_obj={ txt: dob.obj.strip, ocn: dob.ocn }
+ format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
+ subtoc=format_seg.subtoc_lev7 #keep and make available, this is the subtoc
end
@@seg_subtoc_array << subtoc
end