/ #endnote- note-
txt_obj={:txt =>para}
format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)
para=format_seg.no_paranum
end
end
if @sto and @sto.format=~/4:\S+/
para.gsub!(/^\s*4:\S+\s*|<:[-_\w\d]?(-.+?-)?>|4~!.+/m,'') #sort seg headers
@@seg[:main] << %{\n\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::Head_seg.new(@md)
if @md.flag_auto_endnotes and @@seg_endnotes[@@get_hash_fn]
@@seg[:tail] << format_head_seg.endnote_section_open
if @@seg_endnotes[@@get_hash_fn].flatten.length > 0
@@seg[:tail] << format_head_seg.endnote_mark
@@seg[:tail] << @@seg_endnotes[@@get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES|
end
end
#@@seg[:tail] << '
'
ads=SiSU_HTML_promo::Ad.new(@md)
@@seg[:credits] << format_head_seg.credit << ads.div.close << ads.display << format_head_seg.html_close
end
def output(type='')
if @@seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or...
filename_seg=[]
filename_seg << @@seg[:title] << @@seg[:tocband_banner]
if type !~/endnote/
filename_seg << @@minitoc << @@seg[:headers] << @@seg[:main]
else
filename_seg << @@seg[:header_endnotes] << @@minitoc << @@seg[:headers] << %{\n\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
txt_obj={:txt =>$1.strip,:ocn =>$2}
format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)
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]}$/
txt_obj={:txt =>$1.strip,:ocn =>$2}
format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)
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|
txt_obj={:txt =>e}
format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)
note_match=if e =~/#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}/
format_seg.endnote_body_indent
else format_seg.endnote_body
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
endnote_part_a=note_match_seg[m,1]
endnote_part_b=note_match_seg[m,2]
txt_obj={:endnote_part_a =>endnote_part_a,:endnote_part_b =>endnote_part_b}
format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)
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__