From 90051a7ea55acb043434b1c2483b878d602246ba Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 2 Apr 2021 19:37:00 -0400 Subject: org mode (ruby code within) --- org/html.org | 5971 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 5971 insertions(+) create mode 100644 org/html.org (limited to 'org/html.org') diff --git a/org/html.org b/org/html.org new file mode 100644 index 00000000..1454226d --- /dev/null +++ b/org/html.org @@ -0,0 +1,5971 @@ +-*- mode: org -*- +#+TITLE: sisu html +#+DESCRIPTION: documents - structuring, various output representations & search +#+FILETAGS: :sisu:html: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2021 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :eval no +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no + +* html +** part +*** html.rb + +#+BEGIN_SRC ruby :tangle "../lib/sisu/html.rb" +# <> +module SiSU_HTML + begin + require 'pstore' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('pstore NOT FOUND (LoadError)') + end + require_relative 'se_hub_particulars' # se_hub_particulars.rb + include SiSU_Particulars + require_relative 'html_table' # html_table.rb + require_relative 'html_parts' # html_parts.rb + require_relative 'html_format' # html_format.rb + include SiSU_HTML_Format + require_relative 'html_segments' # html_segments.rb + include SiSU_HTML_Seg + require_relative 'html_scroll' # html_scroll.rb + require_relative 'html_promo' # html_promo.rb + include SiSU_HTML_Promo + require_relative 'html_tune' # html_tune.rb + include SiSU_HTML_Tune + class Source + def initialize(opt) + @opt=opt + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + end + def read + begin + songsheet + ensure + SiSU_Env::CreateSite.new(@opt).cp_css + SiSU_Env::CreateSite.new(@opt).cp_base_images + Dir.chdir(@opt.f_pth[:pth]) + end + end + def songsheet + begin + @md=@particulars.md + @fnb=@md.fnb + @env=@particulars.env + primary_output_file=(@opt.act[:html_seg][:set]==:on) \ + ? (@md.file.output_path.html_seg.dir + '/' + @md.file.base_filename.html_segtoc) + : (@md.file.output_path.html_scroll.dir + '/' + @md.file.base_filename.html_scroll) + unless @opt.act[:quiet][:set]==:on + tool=(@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? ("#{@env.program.web_browser} file://#{primary_output_file}") + : ("[#{@opt.f_pth[:lng_is]}] #{@opt.fno}") + (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'HTML', + tool + ).green_hi_blue + : SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'HTML', + tool + ).green_title_hi + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + @opt.fns, + "file://#{primary_output_file}" + ).flow + end + end + data=nil + tuned_file_array=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions + data=tuned_file_array + if @opt.act[:html_scroll][:set]==:on + scr_endnotes=SiSU_HTML::Source::Endnotes.new(data,@md).scroll + end + toc=SiSU_HTML::Source::Toc.new(@md,data).songsheet + links_guide=SiSU_HTML::Source::LinksGuide.new(data,@md).toc + data=tuned_file_array + scr_toc=SiSU_HTML::Source::ScrollHeadAndSegToc.new(@md,toc,links_guide).in_common #watch + if @opt.act[:html_seg][:set]==:on + SiSU_HTML::Source::Seg.new(@md,data).songsheet + end + data=tuned_file_array + if @opt.act[:html_scroll][:set]==:on + scr=SiSU_HTML::Source::Scroll.new(@md,data,scr_endnotes).songsheet + scroll=SiSU_HTML::Source::ScrollOutput.new( + scr_toc, + scr[:body], + scr[:metadata], + scr[:owner_details], + scr[:tails], + @md + ).publish + SiSU_HTML::Source::Output.new(scroll,@md).scroll + end + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + unless (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + texfiles=Dir["#{@env.processing_path.tune}/#{@opt.fns}*"] + texfiles.each do |f| + if FileTest.file?(f) + File.unlink(f) + end + end + end + SiSU_Env::Clear.new(@opt.selections.str,@opt.fns,@md).param_instantiate + @@flag,@@scr,@@seg,@@seg_endnotes,@@seg_subtoc={},{},{},{},{} + @@tracker=0 + @@seg_name,@@seg_name_x,@@seg_subtoc_array,@@seg_endnotes_array,@@tablefoot=Array.new(5){[]} + @@filename_seg,@@seg_url,@@to_lev4,@@get_hash_to,@@get_hash_fn='','','','','' + end + end + private + class HTML_Environment + def initialize(particulars) + @particulars=particulars + @md,@env=particulars.md,particulars.env + @env,@css=particulars.env,SiSU_Style::CSS.new + end + def tuned_file_instructions + @tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) + ao_array=@particulars.ao_array # ao file drawn here + tuned_file_array=SiSU_HTML_Tune::Tune.new(ao_array,@md).songsheet + tuned_file_array + end + end + class LinksGuide + @links_guide_toc=[] + def initialize(data,md) + @data,@md=data,md + @links_guide_=SiSU_Env::CreateSite.new(@md.opt).html_quick_ref? + end + def toc + @links_guide_toc=[] + if @links_guide_ + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) + guide_type='horzontal' #values: horizontal or vertical + @links_guide_toc << format_head_toc.links_guide_open(guide_type) + if defined? @md.lnk \ + and @md.lnk + @md.lnk.each do |l| + if defined? l[:say] + target=(l[:url] !~/^\.(\.)?\//) \ + ? 'external' + : '_top' + s_lnk_url,s_lnk_lnk=l[:url],l[:say] + txt_obj={ + lnk_url: s_lnk_url, + lnk_txt: s_lnk_lnk, + target: target, + } + lev_dob_ocn=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + @links_guide_toc << lev_dob_ocn.links_guide if s_lnk_lnk + end + end + end + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) + @links_guide_toc << format_head_toc.links_guide_close #(guide_type) + @links_guide_toc + else '' + end + end + end + class Endnotes + include SiSU_HTML_Format + def initialize(data,md) + @data,@md=data,md + end + def scroll + @scr_endnotes=[] + SiSU_HTML_Format::HeadScroll.new(@md) + @data.each do |dob| + pg=dob.dup + unless pg.is ==:code + if pg.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ / + endnote_array=[] + if pg.obj=~/#{Mx[:en_a_o]}[\d*+].+?#{Mx[:en_a_c]}/m + endnote_array = pg.obj.scan(/#{Mx[:en_a_o]}[\d*+]+(.+?)#{Mx[:en_a_c]}/m) + end + if pg.obj=~/#{Mx[:en_b_o]}[\d*]+\s.+?#{Mx[:en_b_c]}/m + endnote_array = pg.obj.scan(/#{Mx[:en_b_o]}[\d*]+(.+?)#{Mx[:en_b_c]}/m) + end + if pg.obj=~/#{Mx[:en_b_o]}[\d+]+\s.+?#{Mx[:en_b_c]}/m + endnote_array = pg.obj.scan(/#{Mx[:en_b_o]}[\d+]+(.+?)#{Mx[:en_b_c]}/m) + end + endnote_array.flatten.each do |note| + txt_obj={ txt: note } + format_scroll=SiSU_HTML_Format::FormatScroll.new(@md,txt_obj) + @scr_endnotes << format_scroll.endnote_body + end + end + end + end + @scr_endnotes + end + end + class Toc ' + minitoc + '' + end + protected + def rss #sort all wrong, disabled but kept + @@toc[:seg] <<< +
+

+(relatively static) RSS feeds for DOCUMENTS:
+RSS feed http://www.jus.uio.no/lm/rssfeed/documents.xml
+RSS feed http://www.jus.uio.no/lm/rssfeed/tradelaw.xml
+RSS feed http://www.jus.uio.no/lm/rssfeed/environmental.xml
+

info@address.com
+

+
+WOK + end +#not used --> + def level_endnotes + if @md.flag_endnotes + format_head_scroll=SiSU_HTML_Format::HeadScroll.new(@md) + @@toc[:scr] << format_head_scroll.toc_endnote + end + end + def level_concordance + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) + @@toc[:seg_mini] << format_head_toc.mini_seg_concordance + end + def level_metadata + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) + @@toc[:scr] << format_head_toc.metadata + @@toc[:seg] << format_head_toc.seg_metadata + @@toc[:seg_mini] << format_head_toc.mini_seg_metadata + end + def level_word_index + format_head_toc=SiSU_HTML_Format::HeadToc.new(@d0c) + @@toc[:scr] << format_head_toc.concordance + @@toc[:seg] << format_head_toc.concordance + @@toc[:seg_mini] << format_head_toc.mini_concordance + end +# <-- not used + def level_0 + dob=@data + linkname,link=dob.obj.strip,dob.ocn + if link \ + and link.to_s !~/#/ #% keep eye on link + SiSU_HTML_Format::ParagraphNumber.new(@md,link) + end + title=linkname + toc={} + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:seg]=format_toc.lev0 + toc[:seg_mini]=format_toc.mini_lev0 + title=if dob.ocn ==0 then linkname + else + @@toc[:scr] << '
' + %{#{linkname}} + end + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:scr]=format_toc.lev0 + toc + end + def level_1 + dob=@data + linkname,link=dob.obj.strip,dob.ocn + if link \ + and link.to_s !~/#/ #% keep eye on link + SiSU_HTML_Format::ParagraphNumber.new(@md,link) + end + title=if dob.obj !~/^Metadata$/ then linkname + else + link='metadata' + %{#{linkname}} + end + toc={} + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:seg]=if dob.name =~/^meta/ \ + and dob.obj =~/Document Information/ + format_toc.lev0 + else format_toc.lev1 + end + toc[:seg_mini]=if dob.name =~/^meta/ \ + and dob.obj =~/Document Information/ + @md.concord_make \ + ? format_toc.mini_concord_tail + : format_toc.mini_tail + else format_toc.mini_lev1 + end + title=if dob.ocn ==0 + if dob.name =~/^meta/ \ + and dob.obj =~/Document Information/ + %{#{linkname}} + else linkname + end + else + @@toc[:scr] << '
' + %{#{linkname}} + end + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:scr]=if dob.obj =~/^Metadata$/ then '' + elsif txt_obj[:txt] =~// + format_toc.lev1.gsub(/|<\/a>/,'') + else format_toc.lev1 + end + toc + end + def level_2 + dob=@data + linkname,ocn=dob.obj.strip,dob.ocn + p_num=if ocn \ + and ocn.to_s !~/#/ + SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) + else nil + end + txt_obj={ txt: linkname } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc={} + toc[:seg]=format_toc.lev2 + toc[:seg_mini]=format_toc.mini_lev2 + if p_num + title=%{#{p_num.goto}#{linkname}} + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:scr]=if txt_obj[:txt] =~// + format_toc.lev2.gsub(/|<\/a>/,'') + else format_toc.lev2 + end + end + toc + end + def level_3 + dob=@data + linkname,ocn=dob.obj.strip,dob.ocn + p_num=if ocn \ + and ocn.to_s !~/#/ + SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) + else nil + end + txt_obj={ txt: linkname } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc={} + toc[:seg]=format_toc.lev3 + toc[:seg_mini]=format_toc.mini_lev3 + if p_num + title=%{#{p_num.goto}#{linkname}} + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:scr]=if txt_obj[:txt] =~// + format_toc.lev3.gsub(/|<\/a>/,'') + else format_toc.lev3 + end + end + toc + end + def level_4 + dob=@data + linkname,ocn=dob.obj.strip,dob.ocn + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn + if dob.ln ==4 + fnh={ + fn: dob.name, + } + f=@md.file.base_filename.html_seg(fnh) + seg_link=%{ + #{dob.obj} + } + @@seg_url=dob.name + elsif dob.obj =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/ + fn,hd=/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/.match(dob.obj)[1,2] + fnh={ + fn: fn, + } + f=@md.file.base_filename.html_seg(fnh) + seg_link=%{#{fn} #{hd} } + end + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn + @file=SiSU_Env::FileOp.new(@md) if @md + txt_obj=if seg_link=~/sisu_manifest\.html/ + man_link=if @file.output_dir_structure.by_language_code? \ + or @file.output_dir_structure.by_filetype? + seg_link.gsub(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") + else seg_link + end + { txt: man_link } + else { txt: seg_link } + end + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc={} + toc[:seg]=format_toc.lev4 + toc[:seg_mini]=format_toc.mini_lev4 + title=%{#{p_num.goto}#{linkname}} if p_num + txt_obj=if title=~/sisu_manifest.html/ + man_link=title.gsub(/sisu_manifest.html/,"../manifest/#{@file.base_filename.manifest}") + { txt: man_link } + else { txt: title } + end + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:scr]=format_toc.lev4 + toc + #end + end + def level_5 + dob=@data + linkname,ocn=dob.obj.strip,dob.ocn + toc={} + if ocn \ + and ocn.to_s !~/#/ + fnh={ + fn: @@seg_url, + } + f=@md.file.base_filename.html_seg(fnh) + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) + lnk_n_txt=%{ + #{linkname} + } + txt_obj={ txt: lnk_n_txt } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:seg]=format_toc.lev5 + toc[:seg_mini]=format_toc.mini_lev5 + title=%{#{p_num.goto}#{linkname}} + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:scr]=format_toc.lev5 + end + toc + end + def level_6 + dob=@data + linkname,ocn=dob.obj.strip,dob.ocn + toc={} + if ocn \ + and ocn.to_s !~/#/ + fnh={ + fn: @@seg_url, + } + f=@md.file.base_filename.html_seg(fnh) + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) + lnk_n_txt=%{ + #{linkname} +} + txt_obj={ txt: lnk_n_txt } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:seg]=format_toc.lev6 + toc[:seg_mini]=format_toc.mini_lev6 + title=%{#{p_num.goto}#{linkname}} + txt_obj={ txt: title } + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) + toc[:scr]=format_toc.lev6 + end + toc + end + def level_crosslink + dob=@data + dob=if dob !~/^4~!/ + dob.gsub(/^4~!\s+(\S+)\s+(.+)/, + %{ +
+ #{@png.crosslink_ext} +   \\2 + <\/a> +
+}) + else + dob.gsub(/^4~!\s+(\S+)\s+(.+)/, + %{
+ + + #{@png.crosslink} +   \\2 + <\/a> +
+}) + end + end + end + class ScrollHeadAndSegToc < Toc + include SiSU_Parts_HTML + def initialize(md='',toc='',links_guide_toc='') + @md,@toc,@links_guide_toc=md,toc,links_guide_toc + @make=SiSU_Env::ProcessingSettings.new(@md) + end + def in_common + toc_shared=[] + @segtoc=[] + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + 'Scroll & Segtoc' + ).txt_grey + end + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) + dochead=format_head_toc.head + dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge + toc_shared << dochead + @segtoc << format_head_toc.head + if @make.build.html_top_band? + toc_shared << format_head_toc.scroll_head_navigation_band + end + if defined? @md.rights.all + rights=format_head_toc.rights.all + rights=SiSU_HTML_Tune::CleanHTML.new(rights).clean + end + if @md.prefix_b + prefix_b=format_head_toc.notes.prefix_b + prefix_b=SiSU_HTML_Tune::CleanHTML.new(prefix_b).clean + end + if @make.build.html_top_band? + @segtoc << format_head_toc.seg_head_navigation_band + end + toc_shared << format_head_toc.scroll_head_title_banner_open + @segtoc << format_head_toc.seg_head_title_banner_open + tmp_head=nil + doc_title_endnote=@md.title.full.gsub(/(\*+)/, + '\1') + tmp_head=doc_title_endnote + "\n" + txt_obj={ txt: tmp_head } + format_txt_obj=SiSU_HTML_Format::FormatTextObject.new(@md,txt_obj) + toc_shared << format_txt_obj.center_bold + @segtoc << format_txt_obj.center_bold + if defined? @md.creator.author + creator=SiSU_HTML_Tune::CleanHTML.new(@md.creator.author).clean_for_html + creator_endnote=creator.gsub(/(\*+)/, + %{ \\1}) + tmp_head=creator_endnote + "\n" + txt_obj={ txt: tmp_head } + format_txt_obj=SiSU_HTML_Format::FormatTextObject.new(@md,txt_obj) + toc_shared << format_txt_obj.center_bold + @segtoc << format_txt_obj.center_bold + end + toc_shared << "#{the_table_close*1}\n" + @segtoc << "#{the_table_close*1}\n" + tmp_head=nil + if @md.prefix_a + tmp_head ||= %{

#{@md.prefix_a}\n} + toc_shared << tmp_head.dup + @segtoc << tmp_head.dup + end + tmp_head=nil + toc_shared << @links_guide_toc + if defined? @md.rights.all #and ? @md.rights.all + toc_shared << rights + end + if defined? @md.prefix_b + toc_shared << prefix_b + end + if @make.build.toc? #Table of Contents added/appended here + toc_shared << @toc[:scr] + end + @segtoc << @links_guide_toc + @segtoc << @toc[:seg] + if defined? @md.rights.all \ + and not @md.rights.all.empty? + @segtoc << rights + end + @segtoc << prefix_b if @md.prefix_b + #Segtoc tail added here + @segtoc << "

\n" #bugfix sort later DEBUGNOW + @segtoc << @seg_toc_band_bottom + @segtoc << format_head_toc.seg_navigation_tail << format_head_toc.html_close + @segtoc=@segtoc.flatten.compact #watch + if @md.opt.act[:html_seg][:set]==:on + SiSU_HTML::Source::Output.new(@segtoc,@md).segtoc + end + @segtoc=[] + @toc[:scr],@toc[:seg]=[],[] + toc_shared + end + end + class Table < SiSU_HTML_Table::TableHTML + end + class Scroll < SiSU_HTML_Scroll::Scroll + end + class ScrollOutput + def initialize(scr_toc,scr_body,scr_metadata,scr_owner_details,scr_tails,md) + @scr_toc,@scr_body,@scr_metadata,@scr_owner_details,@scr_tails,@md=scr_toc,scr_body,scr_metadata,scr_owner_details,scr_tails,md + end + def publish + scroll=[] + scroll << @scr_toc << '
' << @scr_body << @scr_endnotes << @scr_owner_details << '
' << @scr_tails + scroll=scroll.flatten.compact #watch + end + end + class Seg < SiSU_HTML_Seg::Seg + end + class Output + def initialize(data='',md='') + @data,@md=data,md + @file=SiSU_Env::FileOp.new(md) + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + end + def scroll + if @md.opt.act[:html_scroll][:set]==:on + begin + @filename_html_scroll=@file.write_file.html_scroll + @data.each do |para| + para=para.strip. + gsub(/<:.+?>/,''). + gsub(Xx[:html_relative2],@file.path_rel_links.html_scroll_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_scroll_1). + #gsub(/#{Xx[:html_relative]}/,@file.path_rel_links.html_scroll). + gsub(/#{Rx[:mx_fa_clean]}/,'') + unless para =~/\A\s*\Z/ + @filename_html_scroll.puts para,"\n" + end + end + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + @filename_html_scroll.close + end + end + end + def segtoc + if @md.opt.act[:html_seg][:set]==:on + begin + @filename_html_segtoc=@file.write_file.html_segtoc + @data.each do |para| + para=para.strip. + gsub(//,''). + gsub(Xx[:html_relative2],@file.path_rel_links.html_seg_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_seg_1) + unless para =~/\A\s*\Z/ + @filename_html_segtoc.puts para,"\n" + end + end + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + @filename_html_segtoc.close + pwd_set=Dir.pwd + idx_lnk=(@o_str.dump_or_redirect?) \ + ? @file.base_filename.manifest + : @file.base_filename.html_segtoc + mlnk=@file.base_filename.html_seg_index + Dir.chdir(@file.output_path.html_seg.dir) + FileUtils::rm_f(mlnk) + FileUtils::ln_s(idx_lnk,mlnk) + Dir.chdir(pwd_set) + end + end + end + end + end +end +__END__ +#+END_SRC + +*** html_parts.rb + +#+BEGIN_SRC ruby :tangle "../lib/sisu/html_parts.rb" +# <> +module SiSU_Parts_HTML + require_relative 'generic_parts' # generic_parts.rb + include SiSU_Parts_Generic + def the_line_break + '
' + end + def the_table_close + ' +' + end + def the_table_cellpad_box + '"20"' + end + def the_color + def white + '#ffffff' + end + def black + '#000000' + end + def grey_pale + '#eeeeee' + end + def grey_medium + '#cccccc' + end + def grey + '#999999' + end + def blue_ink + '#003399' + end + def blue_tinge + '#e3ecef' + end + def yellow_light + '#fff3b6' + end + def table1 + 'ffffcc' + end + def table2 + 'c0d0f0' + end + def band1 + %{"#{white}"} + end + def band2 + %{"#{white}"} + end + self + end + def the_url_decoration + #def tex_open #'{\UseTextSymbol{OML}{<}}' + # Dx[:url_o] + #end + #def tex_close #'{\UseTextSymbol{OML}{>}}' + # Dx[:url_c] + #end + def xml_open #'<' + Dx[:url_o] + end + def xml_close #'>' + Dx[:url_c] + end + def txt_open + '<' + end + def txt_close + '>' + end + self + end + def the_width + def table1 + '"100%"' + end + def table2 + '"99%"' + end + def table_txt + '"94%"' + end + def table_txt_r + '"96%"' + end + self + end + def the_png + def _url_path_image_base #used for html image display + "#{Xx[:html_relative2]}_sisu/image" + end + def ico + %{ } + end + def png_home + %{#{the_text.home} -->} + end + def png_home_button + rel=@dir.path_rel_links.html_scroll_2 + %{#{the_text.home} -->} + end + self + end + def the_font + def set_fonts + 'verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman' + #'verdana, arial, georgia, tahoma, sans-serif, helvetica, "times new roman", times, roman' + end + def set_face + %{face="#{set_fonts}"} + end + def set_color + 'color="#000000"' + end + def set_size_endnote + 'size="3"' + end + def set_small + 'size="3"' + end + def set_tiny + 'size="2"' + end + def paragraph_font_tiny + %{} + end + def paragraph_font_small + %{} + end + self + end + def the_nav + def txt_homepage + %{ +  home  + } + end + def txt_toc_link + %{ +   toc  + } + end + def txt_doc_link + %{ +  scroll  + } + end + def txt_manifest + #{png_manifest} document manifest + %{ + [ document manifest ] + } + end + def txt_concordance + %{ +   A-Z  + } + end + self + end + def the_banner + def home_button_only + %{ + #{the_png.png_home_button} + } + end + def banner_band + %{ + +
+ + #{the_png.png_home} + + +#{the_table_close}} + end + def instrument_cover_band_scr + ' +
' + end + def instrument_cover_band_seg + ' +
' + end + self + end + def the_margin + def txt_0 + %{ +
+} + end + def txt_1 + %{ +
} + end + def txt_2 + %{ + +
+} + end + def txt_3 + %{ + + +} + end + def scroll(text) + if @md.fns =~ /\.(?:-|ssm\.)?sst$/ + %{ +} + end + end + def seg(text) + %{ +} + end + def search + if @make.build.html_search_form? + env=SiSU_Env::InfoEnv.new(@md.fns,@md) + env.widget.search_form('sisusearch',nil,nil,true) + else '' + end + end + def manifest(page=:seg) + if @make.build.links_to_manifest? \ + and not @o_str.dump_or_redirect? + manifest_lnk=if @file.output_dir_structure.by_language_code? \ + or @file.output_dir_structure.by_filetype? + "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}" + else @file.base_filename.manifest + end + if page==:manifest + manifest_lnk="#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}" + %{} + else + %{} + end + else '' + end + end + end + class XML + end + class HeadToc < HeadInformation + def initialize(md) + super(md) + @md=md + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @make=SiSU_Env::ProcessingSettings.new(@md) + @file=SiSU_Env::FileOp.new(@md) + end + def scroll_head_navigation_band + if @make.build.html_top_band? + < + #{make_scroll_search_form_and_manifest_link} + +WOK + %{
+} + end + def css + ' + + +WOK + end + def credits_sisu + %{
+
' + end + def num + '

' + end + def numless + '' + end + def num_css + ' ' + end + self + end +end +module SiSU_Proj_HTML + require_relative 'se' # se.rb + include SiSU_Env + #require_relative 'css' # css.rb + # include SiSU_Style + class Bits + include SiSU_Parts_HTML + def initialize + @v=SiSU_Env::InfoVersion.instance.get_version + #@dir=SiSU_Env::InfoEnv.new + #@date=SiSU_Env::InfoDate.new #{@date.year} + end + def txt_generator + %{ + } + end + def widget_sisu_text +< + Output generated by + + #{@v.project} + + #{@v.version} #{@v.date} (#{@v.date_stamp}) +

+WOK + end + def credits_sisu_manifest + widget_sisu_text + end + def widget_sisu +< +
+ +#{widget_sisu_text} +
+
+ #{widget_sisu} +
} + '' + end + def widget_promo # Array used to build promo from list.yml and promo.yml + # ['sisu_icon','sisu','sisu_search_libre','open_society','fsf','ruby'] + end + end + class Home + def initialize + @v=SiSU_Env::InfoVersion.instance.get_version + @dir=SiSU_Env::InfoEnv.new + @date=SiSU_Env::InfoDate.new #{@date.year} + end + def redirect + < +SiSU + + + +SiSU informtion provided at www.sisudoc.org/sisu/SiSU

+If your browser supports redirection, you will be escorted there shortly. + + +WOK + end + def homepage + < + + +SiSU information Structuring Universe - Structured information, Serialized Units - software for electronic texts, documents, books, digital libraries in plaintext, HTML, EPUB, XHTML, XML, ODF (OpenDocument), LaTeX, PDF, SQL (PostgreSQL and SQLite), and for search + + + + + + + + + + + + + + + + + +

SiSU

+

+[Manual] +

+

+[Source] +[List Info (sisu@lists.sisudoc.org)] +

+ +

SiSU Markup Samples

+

+[Source] +[Output] +

+ +
+ +

+ Structured information, Serialized Units +    + + <www.sisudoc.org> + +   or   + + <www.jus.uio.no/sisu/> + +software for electronic texts, document collections, books, digital libraries & search, with "atomic search" & text locating system (shared object citation numbering: "ocn"). +Outputs include: plaintext, HTML, EPUB, ODT (OpenDocumentText), (XHTML, XML,) LaTeX, PDF, SQL (PostgreSQL and SQLite). +

+

+ +<sisu@lists.sisudoc.org> + + +<http://lists.sisudoc.org/listinfo/sisu> + +

+

+ +<ralph@amissah.com> + + +<ralph.amissah@gmail.com> + +

+

+#{@v.project} #{@v.version} of #{@v.date_stamp} (#{@v.date}) (n*x and Ruby!), #{@date.year_static}. +

+

+w3 since October 3 1993. +

+ + +WOK + end + def home_toc + ' ' + end + end +end +__END__ +#+END_SRC + +*** html_tune.rb + +#+BEGIN_SRC ruby :tangle "../lib/sisu/html_tune.rb" +# <> +require_relative 'dp' # dp.rb +module SiSU_HTML_Tune + require_relative 'se' # se.rb + include SiSU_Env; include SiSU_Screen + require_relative 'html_parts' # html_parts.rb + require_relative 'html_format' # html_format.rb #watch + @@line_mode='' + @@endnote_array=[] + @@endnote_call_counter=1 + @@table_align=' + + +
+ \;' + @@table_align_close=' + +   
' + @@counter,@@column,@columns=0,0,0 + class Output + def initialize(data,md) + @data,@md=data,md + @file=SiSU_Env::InfoFile.new(@md.fns) + @cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX + end + def hard_output + @filename_tune=@file.write_file_processing.html_tune + data=[] + @data.each do |x| + unless x.obj.empty? + x.obj=x.obj.strip + data << x + end + end + data.each do |dob| + @filename_tune.puts dob, "\n" + end + end + def marshal + File.open(@file.marshal.html_tune,'w') {|f| Marshal.dump(@data.to_a,f)} + end + end + class CleanHTML + def initialize(html='') + @html=html + end + def clean_for_html + html=@html + str=if html.is_a?(String) + html + else html.obj + end + str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/[<]/m,'<').gsub(/[>]/m,'>') + end + def clean + html=@html + str=if html.is_a?(String) + html + else html.obj + end + str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/[\\]{2}/m,'
') + end + end + class Tune + include SiSU_Parts_HTML + def initialize(data,md) + @data,@md=data,md + @sys=SiSU_Env::SystemCall.new + @env=SiSU_Env::InfoEnv.new(@md.fns,@md) + end + def songsheet + begin + @cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],'Tune').txt_grey + end + songsheet_array(@data) + #data=songsheet_array(@data) + if @md.opt.act[:maintenance][:set]==:on #Hard Output Tune Optional on/off here + SiSU_HTML_Tune::Output.new(@data,@md).hard_output + SiSU_HTML_Tune::Output.new(@data,@md).marshal + end + SiSU_HTML_Tune::Tune.new(@data,@md).output + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def songsheet_array(data) + data_tuned=[] + data.each do |dob| + dob=amp_angle_brackets(dob) + dob=endnotes_html(dob) + dob=url_markup(dob) + dob=markup(dob) + data_tuned << dob + end + data_tuned + end + def urls(data) + @words=data.each.map do |word| + if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ + http_=true + if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ + m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/.match(word).captures + elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}:\S+?#{Mx[:rel_c]}/ + #http_=false + m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/.match(word).captures + u="#{Xx[:html_relative2]}/" + u + elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ + http_=false + m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/.match(word).captures + elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image/ + m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(image)/.match(word).captures + end + case m + when /\.png|\.jpg|\.gif|c=|\s\d+x\d+/ + w,h=/\s(\d+)x(\d+)/.match(m).captures if m =~/\s\d+x\d+/ + w=%{width="#{w}"} if w + h=%{height="#{h}"} if h + c=m[/"(.+?)"/m,1] + caption=%{

#{c}

} if c + png=m.scan(/\S+/)[0] + image_path=@md.file.output_path.html_seg.rel_image + #image_path=(@md.fns =~/\.-ss[tm]$/) \ + #? @env.url.images_external + #: @env.url.images_local + ins=if u \ + and u.strip !~/^image$/ + %{#{caption}} + else %{#{caption}} + end + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) + else + link=m[/(.+)/m] + png=m.scan(/\S+/)[0].strip + link=link.strip + u=u.gsub(/(\S+)/,"#{Xx[:segment]}#\\1") if u !~/\// unless http_ #marker: in scroll remove; in seg replace + ins=%{#{link}} + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins). + gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) + end + word + else word + end + end.join(' ') + end + def url_markup(dob) + unless dob.is==:code + if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ + @word_mode=dob.obj.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)[()\[\]]*[,.;:!?'"]{0,2}|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+/mu) + words=urls(@word_mode) + dob.obj=dob.obj.gsub(/.+/m,words) + end #consider change, do a while loop + dob.obj=dob.obj.gsub(/\\copyright/i,%{©}) + if (dob.obj !~/\<:ad\s+\.\.\//) + dob.obj=dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, + %{\n
\\3
\n}) + else + dob.obj=dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, + %{\n
\\3
\n}) + end + dob.obj=dob.obj.gsub(/!pick/,%{stellar}). + gsub(/!new/,%{ new}). + gsub(/<:h(.{1,7}?)>/,'\1'). + gsub(/<:to(\d{1,7}?)>/,'to { \1 } '). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). #http ftp matches escaped, no decoration + gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{the_url_decoration.xml_open}\\1#{the_url_decoration.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{the_url_decoration.xml_open}\\1#{the_url_decoration.xml_close}}) #http ftp matches with decoration + if dob.obj =~/#{Xx[:html_relative2]}\/\S+/ \ + and dob.obj !~/(\"#{Xx[:html_relative2]}\/\S+?\"|>\s*#{Xx[:html_relative2]}\/\S+<)/ + dob.obj=dob.obj.gsub(/(#{Xx[:html_relative2]}\/\S+)/,'\1') + end + if dob.obj =~/..\/\S+/ \ + and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ + dob.obj=dob.obj.gsub(/\.\.(\/\S+)/,%{\1}) + end + dob.obj=dob.obj.gsub(//m,'>') + end + dob + end + def amp_angle_brackets(dob) + dob.obj=dob.obj. + gsub(/&/u,'&'). + gsub(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}"). + gsub(//u,'>') + dob + end + def endnotes_html(dob) + unless dob.is ==:code + dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/, + %{  \\2  } + + %{\\1\\2  \\2. \\3 \\4}). + gsub(/(#{Mx[:en_b_o]})([*+]\d+)\s+(.+?)(#{Mx[:en_b_c]})/, + %{  \\2  } + + %{\\1\\2  \\2. \\3 \\4}). + gsub(/(#{Mx[:en_a_o]})([*+]+)\s+(.+?)(#{Mx[:en_a_c]})/, + %{  \\2  } + + %{\\1\\2  \\2 \\3 \\4}) + end + dob + end + def markup(dob) + dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is==:table + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). + gsub(/#{Mx[:gl_bullet]}/m,'●  '). + gsub(/#{Mx[:nbsp]}/,' '). + gsub(/<(p|br) \/>/,'<\1>') + dob=SiSU_HTML_Tune::CleanHTML.new(dob).clean + dob + end + def output + data=@data + @tuned_file=data.each.map do |dob| + dob.obj=dob.obj.strip.chomp + dob + end + @tuned_file << "\n" if (@md.fns =~/\.sst0/) #remove + @tuned_file + end + end +end +__END__ +#+END_SRC + +*** html_scroll.rb + +#+BEGIN_SRC ruby :tangle "../lib/sisu/html_scroll.rb" +# <> +module SiSU_HTML_Scroll + require_relative 'html_shared' # html_shared.rb + require_relative 'html' # html.rb + require_relative 'shared_metadata' # shared_metadata.rb + require_relative 'html_promo' # html_promo.rb + class Scroll + def initialize(md='',data='',endnotes='') + @md,@data,@endnotes=md,data,endnotes + end + def songsheet + begin + scr=SiSU_HTML_Scroll::Scroll.new(@md,@data,@endnotes).markup + scr[:tails]=SiSU_HTML_Scroll::Scroll.new(@md).tails + scr + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + protected + def markup + data=@data + @rcdc=false + @scr={ body: [], metadata: [], owner_details: [] } + data.each do |dob| + dob.obj=dob.obj.gsub(/#{@md.file.output_path.html_seg.rel_image}/m, + @md.file.output_path.html_scroll.rel_image) + if defined? dob.name and dob.name =~/^meta/ \ + and dob.obj =~/Document Information/ + dob.obj=dob.obj. + gsub(/(Document Information(?: \(metadata\))?)/, + '\1') + end + if dob.obj =~/^Metadata$/ \ + and dob.lv =='B' + dob.obj=dob.obj.gsub(/Metadata/,'') #dob.obj='' + end + if defined? dob.name \ + and dob.name =~/^metadata/ \ + and dob.lv =='1' \ + and dob.obj =~/SiSU Metadata, document information/ + @rcdc=true + end + dob.obj=dob.obj.gsub(/href="[a-z0-9._-]+(#\S+?")/m,'href="\1'). # internal document links + gsub(/href="#{Xx[:segment]}/m,'href="') + if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]})/ + unless dob.is ==:code + dob.obj=dob.obj. + gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + end + if defined? dob.ocn + @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,dob.ocn) + end + sto=SiSU_HTML_Format::FormatTextObject.new(@md,dob) + para_html=if dob.is==:heading + x=if dob.ln==0 + sto.heading_body0 + elsif dob.ln==1 + sto.heading_body1 + elsif dob.ln==2 + sto.heading_body2 + elsif dob.ln==3 + sto.heading_body3 + elsif dob.ln==4 + sto.heading_body4 + elsif dob.ln==5 + sto.heading_body5 + elsif dob.ln==6 + sto.heading_body6 + elsif dob.ln==7 + sto.heading_body7 + end + elsif dob.is==:break \ + and dob.from==:markup + '


' + elsif dob.is==:heading_insert + x=if dob.ln==0 + unless dob.obj.empty? + sto.heading_body0 + end + elsif dob.ln==1 + unless dob.obj.empty? + sto.heading_body1 + end + elsif dob.ln==2 + unless dob.obj.empty? + sto.heading_body2 + end + elsif dob.ln==3 + unless dob.obj.empty? + sto.heading_body3 + end + elsif dob.ln==4 \ + and dob.obj !~/^(?:Endnotes|Index|Metadata|Manifest)$/ + unless dob.obj.empty? + sto.heading_body4 + end + elsif dob.ln==4 \ + and dob.obj=='Endnotes' + sto.heading_body4 + @endnotes.join("\n") + elsif dob.ln==4 \ + and dob.obj=='Index' + sto.heading_body4 + book_idx=SiSU_Particulars::CombinedSingleton. + instance.get_idx_html(@md.opt).html_idx + book_idx.each do |y| #takes book index prepared for segments & strips segment identifying info + y.gsub!(/(\1(?:-\d+)?)<\/a>/, + '\2') + end + book_idx.join("\n") + elsif dob.ln==5 + unless dob.obj.empty? + sto.heading_body5 + end + elsif dob.ln==6 + unless dob.obj.empty? + sto.heading_body6 + end + elsif dob.ln==7 + unless dob.obj.empty? + sto.heading_body7 + end + end + elsif dob.is==:para + if dob.indent \ + and dob.hang \ + and dob.indent =~/[0-9]/ \ + and dob.hang =~/[0-9]/ + if dob.bullet_ + (dob.indent =~/[1-9]/) \ + ? sto.format('li',"i#{dob.indent}") + : sto.format('li','bullet') + elsif dob.indent == dob.hang + sto.format('p',"i#{dob.indent}") + elsif dob.indent != dob.hang + sto.format('p',"h#{dob.hang}i#{dob.indent}") + else sto.para + end + else sto.para + end + elsif dob.is==:block + sto.block + elsif dob.is==:group + sto.group + elsif dob.is==:alt + sto.alt + elsif dob.is==:verse + sto.verse + elsif dob.is==:code + sto.code + elsif dob.is==:table + sto.table + elsif dob.is==:break + end + if dob.obj =~// \ + and dob.obj =~/^(?:\^~\d+\s|)/ # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though + dob.obj='' + end + unless @rcdc + @scr[:body] << para_html unless para_html =~/\A\s*\Z/ + end + end + end + @scr + end + def tails + scr_tail=[] + format_head_scroll=SiSU_HTML_Format::HeadToc.new(@md) + scr_tail \ + << format_head_scroll.scroll_tail \ + << format_head_scroll.html_close + scr_tail + end + end +end +__END__ +#+END_SRC + +*** html_segments.rb + +#+BEGIN_SRC ruby :tangle "../lib/sisu/html_segments.rb" +# <> +module SiSU_HTML_Seg + require_relative 'html_shared' # html_shared.rb + require_relative 'html' # html.rb + require_relative 'html_persist' # html_persist.rb + require_relative 'html_promo' # html_promo.rb + require_relative 'shared_metadata' # shared_metadata.rb + class Output + def initialize(md,outputfile,per,minitoc,type='') + @md, @output_seg_file,@per,@minitoc,@type= + md,outputfile, per,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) + @cl=(@make.build.html_minitoc?) \ + ? 'content' + : 'content0' + end + def output + if @per.title =~/\S/ + filename_seg=[] + if @make.build.html_top_band? + filename_seg \ + << @per.title \ + << @per.tocband_banner + else + filename_seg \ + << @per.title + end + if @type=='endnotes' + @per.headings=[] + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) + if @title_banner_ + @per.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) + @per.headings \ + << format_seg.title_heading1 + filename_seg \ + << @per.heading_endnotes \ + << @minitoc << @per.headings \ + << %{\n
\n} \ + << @per.endnote_all \ + << '
' # << '' + elsif @type=='idx' + @per.headings=[] + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) + if @title_banner_ + @per.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) + @per.headings << format_seg.title_heading1 + filename_seg \ + << @per.heading_idx \ + << @minitoc << @per.headings \ + << %{\n
\n} \ + << @per.idx \ + << '
' # << '' + elsif @type=='metadata' + metadata=SiSU_Metadata::Summary.new(@md).html_display.metadata + @per.headings=[] + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) + if @title_banner_ + @per.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) + @per.headings \ + << format_seg.title_heading1 + filename_seg \ + << @per.heading_idx \ + << @minitoc \ + << @per.headings \ + << %{\n
\n} \ + << metadata \ + << '
' # << '' + else + if @make.build.html_top_band? + filename_seg \ + << @minitoc \ + << @per.headings \ + << @per.main \ + << "\n\n" + else + filename_seg \ + << @minitoc \ + << @per.main \ + << "\n\n" + end + end + filename_seg <<=if @make.build.html_top_band? + @per.tail \ + << @per.tocband_bannerless \ + << @per.credits + else + @per.tail \ + << @per.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) + @output_seg_file << str + end + end + @output_seg_file.close + end + end + end + class Seg + @@seg_url='' + @@tracker=0 + @@seg_name=[] + attr_reader :seg_name_x,:seg_name_x_tracker + def initialize(md=nil,data='') + @md,@data=md,data + @per=SiSU_HTML_Persist::Persist.new + @seg_name_x=@per.seg_name_x=(@@seg_name || []) + @seg_name_x_tracker=@per.seg_name_x_tracker=(@@tracker || 0) + @env=SiSU_Env::InfoEnv.new(@md.fns) if @md + if @md + @make=SiSU_Env::ProcessingSettings.new(@md) + @cl=(@make.build.html_minitoc?) \ + ? 'content' + : 'content0' + else @cl='content' + end + if @md + @title_banner_=SiSU_Env::CreateSite.new(@md.opt).html_seg_title_banner? + end + end + def songsheet + begin + @minitoc=SiSU_HTML::Source::Toc.new(@md,@data).minitoc + @per=SiSU_HTML_Persist::Persist.new + data=get_subtoc_endnotes(@data,@per) + data=articles(data,@per) + cleanup(@md,@per) # (((( added )))) + #### (((( END )))) #### + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + SiSU_HTML_Persist::Persist.new.persist_init + @@seg_name=@per.seg_name=[] + end + end + protected + def articles(data,per) + @per=per + tracking,newfile=0,0 + printed_endnote_seg='n' + 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.each do |x| + @per.idx << x + end + @per.heading_idx='' + end + data.each do |dob| + if (dob.is == :heading \ + || dob.is == :heading_insert) \ + && dob.ln == 4 + @@seg_name << dob.name + @per.seg_name = @@seg_name + dob.name + end + end + @per.seg_name_x=@per.seg_name + @per.seg_name.length + testforartnum=@per.seg_name_x + if (@md.opt.act[:verbose][:set]==:on \ + || @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + @per.seg_name.length + ).segmented + end + 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+?"/ + while dob.obj =~/href="#{Xx[:segment]}#+(\S+?)"/ + m=$1 + if map_nametags[m] \ + and map_nametags[m][:segname] + inf=SiSU_Env::FileOp.new(@md) if @md + 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"}) + else + p "NOT FOUND name_tags: #{m}" + dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/, + %{href="#\\1"}) # not satisfactory + end + end + end + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 + @per.heading4=dob.obj + @per.is4=newfile=1 + end + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==3 + @per.heading3=dob.obj + @per.is4,@per.is3=0,1 + end + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==2 + @per.heading2=dob.obj + @per.is4,@per.is3,@per.is2=0,0,1 + end + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==1 + @per.heading1=dob.obj + @per.is4,@per.is3,@per.is2,@per.is1=0,0,0,1 + end + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==0 + @per.heading0=dob.obj + @per.is4,@per.is3,@per.is2,@per.is1,@per.is0=0,0,0,0,1 + end + if (@per.is1 && !@per.is2 && !@per.is3 && !@per.is4) + if not (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==0 + $_ #; check + end + end + if @per.is4==1 + if newfile==1 \ + or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ + newfile=0 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 + 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}/.") + end + tail(@md,@per) + #SiSU_HTML_Seg::Seg.new(@md,@per).tail + fnh={ + fn: @per.seg_name_x[tracking-1], + } + fn=@md.file.base_filename.html_seg(fnh) + segfilename="#{@file.output_path.html_seg.dir}/#{fn}" + output_seg_file=File.new(segfilename,'w') if @per.seg_name_x[tracking-1] + minitoc=(@make.build.html_minitoc?) ? @minitoc : '' + if dob.is==:heading \ + || (@per.seg_name_x[tracking-1] !~/endnotes|book_index|metadata/) + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc).output + elsif dob.is==:heading_insert + if @per.seg_name_x[tracking-1]=='endnotes' + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'endnotes').output + elsif @per.seg_name_x[tracking-1]=='book_index' + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'idx').output + @per.idx=[] + elsif @per.seg_name_x[tracking-1]=='metadata' + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'metadata').output + else puts "#{__FILE__}::#{__LINE__}" + end + else puts "#{__FILE__}::#{__LINE__}" + end + SiSU_HTML_Seg::Seg.new.reinitialise(per) + #per=persist_init + heading_art(dob) + head(dob) + #keep use for last segment, eg if metadata is last segment + if @per.seg_name_x[tracking] =='metadata' # this is for metadata + fnh={ + fn: @per.seg_name_x[tracking], + } + fn=@md.file.base_filename.html_seg(fnh) + segfilename="#{@file.output_path.html_seg.dir}/#{fn}" + output_seg_file=File.new(segfilename,'w') + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@per,minitoc,'metadata').output + #per=persist_init + Seg.new.reinitialise(per) + end + end + if tracking==0 + heading_art(dob) + head(dob) + end + end + tracking=tracking+1 + end + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 \ + && dob.name + @per.get_hash_to=dob.name + @per.get_hash_fn=dob.name + end + if dob.obj.is_a?(String) + markup(dob) + elsif dob.obj.is_a?(Array) + dob.obj.each do |pg| + markup(pg) + end + end + if testforartnum[tracking-1] =~/endnote/ + if printed_endnote_seg=='n' + printed_endnote_seg='y' + end + end + end + end + data + end + def heading_art(dob) + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) + @per.dot_nav=if (@make.build.html_navigation?) \ + && (@make.build.html_navigation_bar?) + x=if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && (dob.ln.to_s =~/^[0-7]/) + x=if @@tracker < @per.seg_name.length-1 + format_head_seg.dot_control_pre_next + else + format_head_seg.dot_control_pre + end + else @per.dot_nav + end + else @per.dot_nav='' + end + ads=SiSU_HTML_Promo::Ad.new(@md) + @per.title=format_head_seg.head_seg << ads.div.major + end + def head(dob) + clean=/|<:.*?>/ + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) + if @make.build.html_navigation? + if @@tracker < @per.seg_name.length-1 + @per.segtocband=if @@tracker==0 + format_head_seg.toc_next2 + else + format_head_seg.toc_pre_next2 + end + else @per.segtocband=format_head_seg.toc_pre2 + end + else @per.segtocband='' + end + @p_num ||= '' + if @per.is0==1 + @author=%{#{@md.author}\n} if @md.author.to_s =~/\S/ + @per.tocband_banner \ + << format_head_seg.navigation_band(@per.segtocband,@per.dot_nav) + @per.tocband_bannerless \ + << '
' \ + << format_head_seg.navigation_band_bottom(@per.segtocband,@per.dot_nav) + if @title_banner_ + @per.headings \ + << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'') + end + ocn=(@per.heading0[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' + @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) + txt_obj={ txt: @per.heading0, ocn_display: @p_num.ocn_display } + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) + @per.headings \ + << format_seg.title_heading0.gsub(clean,'') + @per.heading0=@per.heading0. + gsub(/ 
 [\d*+]+<\/sup> <\/a>/,'') + end + if @per.is1==1 + heading1=@per.heading1 + ocn=(heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' + @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) + @per.headings \ + << format_seg.title_heading1.gsub(clean,'') + @per.heading1=@per.heading1. + gsub(/  [\d*+]+<\/sup> <\/a>/,'') + end + if @per.is2==1 + heading2=@per.heading2 + ocn=(heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' + @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) + @per.headings \ + << format_seg.title_heading2.gsub(clean,'') + @per.heading2=@per.heading2. + gsub(/  [\d*+]+<\/sup> <\/a>/,'') + end + if @per.is3==1 + heading3=@per.heading3 + ocn=(heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' + @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) + @per.headings \ + << format_seg.title_heading3.gsub(clean,'') + @per.heading3=@per.heading3. + gsub(/  [\d*+]+<\/sup> <\/a>/,'') + end + if @per.is4==1 + heading4=@per.heading4 + ocn=(heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' + @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) + @per.headings \ + << format_seg.title_heading4.gsub(clean,'') + end + @@tracker=@@tracker+1 + end + def markup(dob) + @debug=[] + SiSU_HTML_Format::HeadSeg.new(@md) + if dob.is !=:meta + if dob.is==:heading \ + || dob.is==:heading_insert \ + || dob.is == :para + @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,dob.ocn) + end + sto=SiSU_HTML_Format::FormatTextObject.new(@md,dob) + dob_html=if dob.is == :heading \ + || dob.is==:heading_insert \ + || dob.is==:para + dob_html=if dob.is==:heading \ + || dob.is==:heading_insert + if dob.ln==4 + sto.seg_heading4 + elsif dob.ln==5 + 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 \ + and dob.hang \ + and dob.indent =~/[0-9]/ \ + and dob.hang =~/[0-9]/ + if dob.bullet_ + if dob.indent =~/[1-9]/ + sto.format('li',"i#{dob.indent}") + else + sto.format('li','bullet') + end + elsif dob.indent == dob.hang + sto.format('p',"i#{dob.indent}") + elsif dob.indent != dob.hang + sto.format('p',"h#{dob.hang}i#{dob.indent}") + else sto.para + end + else sto.para + end + end + elsif dob.is==:block + sto.block + elsif dob.is==:group + sto.group + elsif dob.is==:alt + sto.alt + elsif dob.is==:verse + sto.verse + elsif dob.is==:code + sto.code + elsif dob.is==:table + sto.table + elsif dob.is==:break \ + and dob.from==:markup + '


' + end + if @md.flag_separate_endnotes + dob.obj=dob.obj.gsub(/"\s+href="#(#{Mx[:note]}\d+)">/,%{" href=\"endnotes#{Sfx[:html]}#\\1">}) #endnote- twice #removed file type + end + if (dob.is==:heading \ + || dob.is==:heading_insert \ + || dob.is==:para) \ + && (not dob.ocn \ + || (dob.ocn.to_s.empty?)) + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,dob) + end + dob.obj=dob.obj.gsub(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with #?? workpoint + if dob.obj =~/
 / #endnote- note- + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,dob) + dob=format_seg.no_paranum + end + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 + @per.main << %{\n
\n} + @per.main << dob_html + if @make.build.segsubtoc? + @per.main << @per.seg_subtoc[@per.get_hash_fn] #% insertion of sub-toc + end + else + @per.main << dob_html #unless @@flag_alt==true + end + end + end + def tail(md,per) + @md,@per=md,per + format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) + if @md.flag_auto_endnotes \ + and @per.seg_endnotes[@per.get_hash_fn] + @per.tail << %{\n
\n
\n} + if @per.seg_endnotes[@per.get_hash_fn].flatten.length > 0 + @per.tail << format_head_seg.endnote_mark + @per.tail << @per.seg_endnotes[@per.get_hash_fn].flatten #endnotes deposited at end of individual segments ||@|EXTRACTION OF ENDNOTES| + end + @per.tail << '
' + @per.tail << '
' #this div closes div class content + end + ads=SiSU_HTML_Promo::Ad.new(@md) + @per.credits \ + << format_head_seg.credit \ + << ads.div.close \ + << ads.display \ + << format_head_seg.html_close + end + def reinitialise(per) + per.title,per.dot_nav,per.tocband_banner,per.tocband_bannerless,per.headings,per.main,per.tail,per.credits=Array.new(8){[]} + @per.segtocband=nil + end + def cleanup(md,per) + #per=persist_init + reinitialise(per) + @@tracker=0 + @per.seg_endnotes,@per.seg_subtoc={},{} + @per.seg_endnotes_array,@per.seg_subtoc_array=[],[] + per.endnote_all=[] + end + def get_subtoc_endnotes(data,per) #get endnotes & sub-table of contents subtoc + @per=per + data.each do |dob| + dob.obj=dob.obj.gsub(/
(.+?)<\/a>/mi,'\1') + if @md.flag_auto_endnotes + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && (dob.ln.to_s =~/^[0-4]/) \ + and not @per.fn.to_s.empty? + @per.seg_endnotes[@per.fn]=[] + @per.seg_endnotes[@per.fn] << @per.seg_endnotes_array + @per.seg_endnotes_array=[] if dob.ln==4 + end + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs + @per.seg_subtoc[@per.fn]=@per.seg_subtoc_array + @per.seg_subtoc_array=[] + if dob.name \ + and dob.obj + @per.fn=dob.name + else + if dob.name =~/\S+/ + @per.fn=dob.name + else @per.fn='' + end + end + end + end + if dob.is==:heading \ + && (dob.ln.to_s =~/^[5-7]/) + case dob.ln + when 5 + txt_obj={ txt: dob.obj.strip, ocn: dob.ocn } + format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) + subtoc=format_seg.subtoc_lev5 #keep and make available, this is the subtoc + when 6 + 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 + @per.seg_subtoc_array << subtoc + end + if @md.flag_auto_endnotes + if (dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+\s*/) + try.each do |e| + txt_obj={ txt: e } + format_seg=SiSU_HTML_Format::FormatSeg.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 + @per.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=")(##{Mx[:note_ref]}[\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::FormatSeg.new(@md,txt_obj) + note_match_all_seg=format_seg.endnote_seg_body(@per.fn) #BUG WATCH 200408 + @per.endnote_all << note_match_all_seg + end + dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + end + end + end + end + end +end +__END__ +#+END_SRC + +*** html_format.rb + +#+BEGIN_SRC ruby :tangle "../lib/sisu/html_format.rb" +# <> +module SiSU_HTML_Format + require_relative 'html_parts' # html_parts.rb + class ParagraphNumber + def initialize(md,ocn) + @md,@ocn=md,ocn.to_s + @ocn ||='' + @make=SiSU_Env::ProcessingSettings.new(@md) + end + def ocn_display + if @make.build.ocn? + if @ocn.to_i==0 \ + or @ocn.empty? + '' + else + %{
#{@ocn}} + end + else + '' + end + end + def name + if @make.build.html_strict? \ + or @ocn==(nil || @ocn.empty?) + '' + else + %{} + end + end + def id #w3c? "tidy" complains about numbers as identifiers ! annoying + (@ocn==nil || @ocn.empty?) \ + ? '' : %{id="#{Mx[:ocn_id_char]}#{@ocn}"} + end + def goto + (@ocn==nil || @ocn.empty?) \ + ? '' : %{} + end + end + class HeadInformation + require_relative 'css' # css.rb + include SiSU_Parts_HTML + require_relative 'xml_shared' # xml_shared.rb + attr_reader :md,:rdf + def initialize(md) + @md=md + # DublinCore 1 - title + @bits=SiSU_Proj_HTML::Bits.new + @per=SiSU_HTML_Persist::Persist.new + @per.seg_name_x=SiSU_HTML::Seg.new.seg_name_x + @per.seg_name_x_tracker=SiSU_HTML::Seg.new.seg_name_x_tracker + @tocband_scroll,@tocband_segtoc=nil,nil + @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @index,@metalink='index','#metadata' + @toc=@md.file.base_filename.html_segtoc + end + def url_path_image_sys + (@o_str.dump_or_redirect?) \ + ? './image' + : "#{Xx[:html_relative2]}_sisu/image_sys" + end + def icon + def up + 'arrow_up_red.png' + end + def next + 'arrow_next_red.png' + end + def previous + 'arrow_prev_red.png' + end + def dot_clear + 'dot_clear.png' + end + def dot_white + 'dot_white.png' + end + def dot + dot_white + end + self + end + def png_nav + def toc + %{toc} + end + def pre + %{<< previous} + end + def nxt + %{next >>} + end + def dot_toc + %{^} + end + def dot_pre + %{<} + end + def dot_nxt + %{>} + end + self + end + def doc_types(page=:seg) #used in toc & seg_nav_band + wgt=SiSU_HTML_Format::Widget.new(@md) + %{ + + +
+ #{wgt.manifest(page)} + #{wgt.search} +
} + end + def rdf + SiSU_XML_Tags::RDF.new(md) + end + def button_home(page=:seg) + button=%{ \n \n
\n} + if @md.make.home_button_image.is_a?(Hash) + image_path=if page==:manifest + @md.file.output_path.manifest.rel_image + elsif page==:scroll + @md.file.output_path.html_scroll.rel_image + else + @md.file.output_path.html_seg.rel_image + end + SiSU_Env::FileOp.new(@md) + button +=%{

home icon -->

\n} + elsif @md.home_button_links.is_a?(Array) + @md.home_button_links.each do |links| + button +=%{

\n #{links[:say]}\n

\n} + end + end + button +=%{
} + button + end + def html_close #moved + %{ +} + end + end + class Widget < HeadInformation + include SiSU_Parts_HTML + def initialize(md) + super(md) + @md=md + @cf_defaults=SiSU_Env::InfoProcessingFlag.new + @env=SiSU_Env::InfoEnv.new(md.fns) + @file=SiSU_Env::FileOp.new(md) + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @make=SiSU_Env::ProcessingSettings.new(md) + end + def home + %{
+ + #{the_nav.txt_homepage} + + + #{text} + + + + #{text} + + + + #{the_url_decoration.xml_open}#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}#{the_url_decoration.xml_close} + + + + #{the_nav.txt_manifest} + +
+ + + +
+ #{button_home(:scroll)} + + #{doc_types} + +   +#{the_table_close} +

} + else '' + end + end + def concordance_navigation_band + up_button=if @make.build.html_navigation? + %{

+   + #{png_nav.toc} +   +} + else '' + end + if @make.build.html_top_band? + %{ + + +} + %{
+ #{button_home} + + #{doc_types} +#{up_button} +#{the_table_close} +

} + else '' + end + end + def seg_head_navigation_band(page=:seg) + if @make.build.html_navigation? + if page==:manifest + nxt=(@file.output_dir_structure.by_language_code? \ + || @file.output_dir_structure.by_filetype?) \ + ? "../html/#{@md.fnb}/toc#{@md.lang_code_insert}#{Sfx[:html]}" + : "toc#{@md.lang_code_insert}#{Sfx[:html]}" + firstseg=%{ + #{png_nav.nxt}} + elsif @md.firstseg =~/\S+/ + firstseg=%{ + #{png_nav.nxt}} + end + else '' + end + if @make.build.html_top_band? + %{ + + + +} + %{
+#{button_home(page)} + + #{doc_types(page)} + +  #{firstseg}  +#{the_table_close} +

} + else '' + end + end + def manifest_link(text) +# @file=SiSU_Env::FileOp.new(@md) if @md + %{ + #{text} + } + end + def concordance_link(text) + if @md.concord_make + %{ + + #{text} + + } + else '' + end + end + def make_scroll_search_form_and_manifest_link + wgt=SiSU_HTML_Format::Widget.new(@md) + %{

+ #{the_nav.txt_doc_link} +
+ + #{wgt.manifest} + #{wgt.search} +
} + end + def make_scroll_seg_pdf + seg='' + wgt=SiSU_HTML_Format::Widget.new(@md) + seg=%{

+ #{the_nav.txt_toc_link} +
+ +
+ #{wgt.manifest} + #{wgt.search} +
} + end + def make_concordance + wgt=SiSU_HTML_Format::Widget.new(@md) + %{ + +
+ #{wgt.manifest} + #{wgt.search} +
} + end + def head + rdf=SiSU_XML_Tags::RDF.new(@md) + %{ + + + + + #{@md.title.full} + + +#{rdf.metatag_html} +#{@stylesheet.css_head} + + +} + end + def concordance + if @md.concord_make + %{#{the_margin.css} +

+ + Concordance + +

+#{table_close}} + else + %{#{the_margin.css} +#{table_close}} + end + end + def links_guide_vertical_open +# @file=SiSU_Env::FileOp.new(@md) if @md + %{ +