\n}
@@seg[:main] << para
@@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc
else
para.gsub!(/<:[-_\w\d]?(-.+?-)?>|4~!.+/,'')
@@seg[:main] << para unless @@flag_alt==true
end
end
end
def tail
format_head_seg=SiSU_HTML_Format_type::Head_seg.new(@md)
if @md.flag_auto_endnotes
@@seg[:tail] << format_head_seg.endnote_mark
@@seg[:tail] << @@seg_endnotes[@@get_hash_fn] #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES|
end
#@@seg[:tail] << '
\n} << @@seg[:endnote_all]
end
filename_seg << @@seg[:tail] << @@seg[:tocband_bannerless] << @@seg[:credits]
filename_seg.flatten!.compact!
filename_seg.each do |para|
unless para =~/\A\s*\Z/
para.strip!
@@filename_seg << para
end
end
@@filename_seg.close
end
end
def reinitialise
@@seg[:title],@@seg[:dot_nav],@@seg[:tocband_banner],@@seg[:tocband_bannerless],@@seg[:headers],@@seg[:main],@@seg[:tail],@@seg[:credits]=Array.new(8){[]}
@@segtocband=nil
end
def cleanup
reinitialise
@@seg_total,@@tracker=0,0
@@seg_endnotes,@@seg_subtoc={},{}
@@seg_endnotes_array,@@seg_subtoc_array=[],[]
@@seg[:endnote_all]=[]
end
def get_subtoc_endnotes(data) #get endnotes & sub-table of contents subtoc
data.each do |para|
para.gsub!(/
(.+?)<\/a>/mi,'\1')
if @md.flag_auto_endnotes
if para =~/^#{Mx[:lv_o]}[1234]:/ \
and not @@fn.empty?
@@seg_endnotes[@@fn]=[]
@@seg_endnotes[@@fn] << @@seg_endnotes_array
@@seg_endnotes_array=[] if para=~/^#{Mx[:lv_o]}4:/
@@fns_previous=@md.fns if para=~/^#{Mx[:lv_o]}1:meta#{Mx[:lv_c]}/
end
if para =~/^#{Mx[:lv_o]}4:/ #% EXTRACTION OF SUB-TOCs
@@seg_subtoc[@@fn]=@@seg_subtoc_array
@@seg_subtoc_array=[]
end
if para =~/^#{Mx[:lv_o]}4:/ #% SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs
if para !~/^#{Mx[:lv_o]}4:metadata#{Mx[:lv_c]}/
m=para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}.+?#{Mx[:id_o]}~(\d+);(?:[oh]|4:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]
end
if m; @@fn,@@to_lev4=$1,$2 if m # changed 2004w07 #endnotes and sub-tocs
else
if para !~/^#{Mx[:lv_o]}4:metadata#{Mx[:lv_c]}/
m=para[/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/]
@@fn,@@to_lev4=$1,'nonum' if m # changed 2005w13
else @@fn=''
end
end
end
end
if para =~/^#{Mx[:lv_o]}[56]:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/
para.gsub!(/ <\/a>/,' ')
case para # series changed 2002w42
when /^#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #remove [u]? req by pg texts, revist
one,two=$1,$2
format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two)
para=format_seg.subtoc_lev5
when /^#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/
one,two=$1,$2
format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two)
para=format_seg.subtoc_lev6
end
@@seg_subtoc_array << para
end
if @md.flag_auto_endnotes
if para =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ /)
try.each do |e|
format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,e)
note_match=if e =~/#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}/
format_seg.endnote_body_seg_tail_indent
else format_seg.endnote_body_seg_tail
end
@@seg_endnotes_array << note_match
end
try.join('
')
#% creation of separate end segment/page of all endnotes referenced back to reference segment
m=/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?href=")(#-[\d*+]+".+)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/mi
one=note_match_seg[m,1] #note~ [a name]
two=note_match_seg[m,2] #note-
format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two)
note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408
@@seg[:endnote_all] << note_match_all_seg
end
para.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ')
end
end
end
end
end
end
__END__