diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-03-19 22:07:29 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-03-19 22:07:33 -0400 |
commit | 6811ac91f21a434fc7d967c11e1b20f33918c6ea (patch) | |
tree | 30f39674ca96a79f8a604a9f02d571f24320e221 /lib/sisu/v3/xhtml.rb | |
parent | v3: 3.2.0 version & changelog "opened" (diff) |
v3: 3.2 branch is main (v3dv --> v3); dev (v3dv) branch directories removed
* v3dv (3.2) "merged" into v3 (previously 3.1) (& removed)
* conf/sisu/v3dv --> conf/sisu/v3
* data/sisu/v3dv --> data/sisu/v3
* lib/sisu/v3dv --> lib/sisu/v3
* bin/sisu* (v3dv references changed to v3)
* (--dev modifier (superfluous for the time being) runs main v3 branch)
Diffstat (limited to 'lib/sisu/v3/xhtml.rb')
-rw-r--r-- | lib/sisu/v3/xhtml.rb | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/lib/sisu/v3/xhtml.rb b/lib/sisu/v3/xhtml.rb index 6f8c6da5..c537275c 100644 --- a/lib/sisu/v3/xhtml.rb +++ b/lib/sisu/v3/xhtml.rb @@ -64,9 +64,9 @@ module SiSU_XHTML require_relative 'sysenv' # sysenv.rb include SiSU_Env require_relative 'shared_xml' # shared_xml.rb - include SiSU_XML_munge + include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb - include SiSU_XML_format + include SiSU_XML_Format require_relative 'rexml' # rexml.rb include SiSU_Rexml require_relative 'shared_metadata' # shared_metadata.rb @@ -75,7 +75,7 @@ module SiSU_XHTML class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read begin @@ -95,7 +95,7 @@ module SiSU_XHTML SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"/#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}").flow if @opt.cmd =~/[MV]/ end SiSU_XHTML::Source::Songsheet.new(@particulars).song - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end end @@ -103,14 +103,14 @@ module SiSU_XHTML class Songsheet def initialize(particulars) @env,@md,@dal_array,@particulars=particulars.env,particulars.md,particulars.dal_array,particulars - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) end def song begin SiSU_XHTML::Source::Scroll.new(@particulars).songsheet SiSU_XHTML::Source::Tidy.new(@md,@file.place_file.xhtml.dir).xml if @md.opt.cmd =~/[vVM]/ # test wellformedness, comment out when not in use SiSU_Rexml::Rexml.new(@md,@file.place_file.xhtml.dir).xml if @md.opt.cmd =~/M/ # test rexml parsing, comment out when not in use #debug - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure end end @@ -118,15 +118,15 @@ module SiSU_XHTML class Scroll require_relative 'shared_xhtml' # shared_xhtml.rb #check already called require_relative 'shared_txt' # shared_txt.rb - include SiSU_text_utils + include SiSU_TextUtils require_relative 'css' # css.rb @@xml={ body: [], sisu: [], open: [], close: [], head: [] } def initialize(particulars) @env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin @tab="\t" - @trans=SiSU_XML_munge::Trans.new(@md) - @sys=SiSU_Env::System_call.new + @trans=SiSU_XML_Munge::Trans.new(@md) + @sys=SiSU_Env::SystemCall.new end def songsheet pre @@ -136,39 +136,39 @@ module SiSU_XHTML end protected def embedded_endnotes(dob='') - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, - '<endnote><number>\1</number><note>\2</note></endnote> ') - dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, - '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') - dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, - '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, + '<endnote><number>\1</number><note>\2</note></endnote> '). + gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, + '<endnote><symbol>\1</symbol><note>\2</note></endnote> '). + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, + '<endnote><symbol>\1</symbol><note>\2</note></endnote> ') end def extract_endnotes(dob='') notes=dob.obj.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) notes.flatten.each do |e| s=e.to_s - util=SiSU_text_utils::Wrap.new(s,70) + util=SiSU_TextUtils::Wrap.new(s,70) wrap=util.line_wrap - wrap.gsub!(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK + wrap=wrap.gsub(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK #{Ax[:tab]*1}<endnote notenumber="\\1"> #{Ax[:tab]*2}\\1. \\2 #{Ax[:tab]*1}</endnote> WOK -) - wrap.gsub!(/^([*+]\d+)\s+(.+?)\s*\Z/m, <<WOK +). + gsub(/^([*+]\d+)\s+(.+?)\s*\Z/m, <<WOK #{Ax[:tab]*1}<endnote symbol="\\1"> #{Ax[:tab]*2}\\1 \\2 #{Ax[:tab]*1}</endnote> WOK -) - wrap.gsub!(/^([*+]+)\s+(.+?)\s*\Z/m, <<WOK +). + gsub(/^([*+]+)\s+(.+?)\s*\Z/m, <<WOK #{Ax[:tab]*1}<endnote symbol="\\1.length"> #{Ax[:tab]*2}\\1 \\2 #{Ax[:tab]*1}</endnote> WOK ) #KEEP alternative presentation of endnotes -# wrap.gsub!(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK +# wrap=wrap.gsub(/^(\d+)\s+(.+?)\s*\Z/m, <<WOK ##{Ax[:tab]*1}<p class="endnote" notenumber="\\1"> ##{Ax[:tab]*2}\\1. \\2 ##{Ax[:tab]*1}</p> @@ -178,7 +178,7 @@ WOK end end def xml_head - metadata=Metadata::Summary.new(@md).xhtml_scroll.metadata + metadata=SiSU_Metadata::Summary.new(@md).xhtml_scroll.metadata @@xml[:head] << metadata end def name_tags(dob) @@ -192,18 +192,19 @@ WOK tags end def xml_structure(dob,type='norm') - if dob.is =~/para|heading/ + if dob.is ==:para \ + || dob.is ==:heading named=name_tags(dob) - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n3=dob.ln + 2 else lv=nil end extract_endnotes(dob) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean - util=SiSU_text_utils::Wrap.new(dob.obj,70) + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean + util=SiSU_TextUtils::Wrap.new(dob.obj,70) wrapped=util.line_wrap @@xml[:body] << if defined? dob.ocn %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@ -220,9 +221,9 @@ WOK def block_structure(dob) named=name_tags(dob) dob=@trans.markup_block(dob) - dob.obj.strip! - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean + dob.obj=dob.obj.strip. + gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="block">#{named}#{Ax[:tab]*1}} @@ -233,9 +234,9 @@ WOK def group_structure(dob) named=name_tags(dob) dob=@trans.markup_group(dob) - dob.obj.strip! - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean + dob.obj=dob.obj.strip. + gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'<en>\1</en>'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'<en>\1</en>') #footnote/endnote clean @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="group">#{named}#{Ax[:tab]*1}} @@ -246,7 +247,7 @@ WOK def poem_structure(dob) named=name_tags(dob) dob=@trans.markup_group(dob) - dob.obj.strip! + dob.obj=dob.obj.strip @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="verse">#{named}#{Ax[:tab]*1}} @@ -257,8 +258,7 @@ WOK def code_structure(dob) named=name_tags(dob) dob=@trans.markup_group(dob) - dob.obj.gsub!(/\s\s/,'  ') - dob.obj.strip! + dob.obj=dob.obj.gsub(/\s\s/,'  ').strip @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*1}<text class="code">#{named}#{Ax[:tab]*1}} @@ -268,7 +268,7 @@ WOK end def table_structure(dob) named=name_tags(dob) - table=SiSU_XHTML_shared::Table_xhtml.new(dob) + table=SiSU_XHTML_Shared::TableXHTML.new(dob) @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">} @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>} @@xml[:body] << %{#{Ax[:tab]*2}#{named}#{table.table.obj}} @@ -292,11 +292,11 @@ WOK if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ if defined? dob.ocn #look to move to format section ocn=(dob.ocn.to_s =~/\d+/) ? dob.ocn : nil - @p_num=SiSU_XML_format::Paragraph_number.new(@md,ocn) + @p_num=SiSU_XML_Format::ParagraphNumber.new(@md,ocn) end if not @rcdc - x=SiSU_XML_format::Format_seg.new(@md,dob) - if dob.is=='heading' + x=SiSU_XML_Format::FormatSeg.new(@md,dob) + if dob.is==:heading xml_structure(dob) dob.obj=case dob.ln when 1; x.heading_body1 @@ -307,25 +307,25 @@ WOK when 6; x.heading_body6 end else - if dob.is =='verse' + if dob.is ==:verse poem_structure(dob) - elsif dob.is =='group' + elsif dob.is ==:group group_structure(dob) - elsif dob.is =='block' + elsif dob.is ==:block block_structure(dob) - elsif dob.is =='code' + elsif dob.is ==:code code_structure(dob) - elsif dob.is =='table' + elsif dob.is ==:table table_structure(dob) - elsif dob.is =='para' \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.bullet_==true xml_structure(dob,"indent_bullet#{dob.indent}") - elsif dob.is =='para' \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.indent == dob.hang xml_structure(dob,"indent#{dob.indent}") - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang xml_structure(dob,"hang#{dob.hang.to_s}_indent#{dob.indent.to_s}") @@ -335,7 +335,7 @@ WOK if dob.obj =~/.*<:#>.*$/ #investigate removal dob.obj=if dob.obj =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ txt_obj={ txt: dob } - format_text=Format_text_object.new(@md,txt_obj) + format_text=FormatTextObject.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end end @@ -343,7 +343,7 @@ WOK end else # end - dob.obj.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj + dob.obj=dob.obj.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj end end 6.downto(4) do |x| @@ -356,14 +356,14 @@ WOK end end def pre - rdf=SiSU_XML_tags::RDF.new(@md) - dir=SiSU_Env::Info_env.new + rdf=SiSU_XML_Tags::RDF.new(@md) + dir=SiSU_Env::InfoEnv.new @@xml[:head],@@xml[:body]=[],[] - css=SiSU_Env::CSS_stylesheet.new(@md) + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xhtml').stylesheet encoding=(@sys.locale =~/utf-?8/i) ? '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' : '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' @@xml[:open] =<<WOK #{encoding} -#{css.xhtml} +#{stylesheet.css_head_xml} #{rdf.comment_xml} <document> WOK @@ -380,7 +380,7 @@ WOK content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] content << @@xml[:owner_details] if @md.stmp =~/\w\w/ content << @@xml[:tail] << @@xml[:close] - content.flatten!.compact! + content=content.flatten.compact Output.new(content,@md).xhtml @@xml={} end @@ -388,13 +388,13 @@ WOK class Output def initialize(data,md) @data,@md=data,md - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) end def xhtml - SiSU_Env::SiSU_file.new(@md).mkdir + SiSU_Env::FileOp.new(@md).mkdir filename_xml=@file.write_file.xhtml @data.each do |str| - str.gsub!(/\A\s+\Z/m,'') #str.gsub!(/^\s+$/,'') + str=str.gsub(/\A\s+\Z/m,'') #str.gsub(/^\s+$/,'') filename_xml.puts str unless str.empty? end filename_xml.close @@ -403,7 +403,7 @@ WOK class Tidy def initialize(md,file) @md,@file=md,file - @prog=SiSU_Env::Info_program.new + @prog=SiSU_Env::InfoProgram.new end def xml if @prog.tidy !=false @@ -414,7 +414,7 @@ WOK tell.grey_open end tidyfile='/dev/null' #don't want one or screen output, check for alternative flags - tidy=SiSU_Env::System_call.new(@file,tidyfile) + tidy=SiSU_Env::SystemCall.new(@file,tidyfile) tidy.well_formed? tell.p_off unless @md.opt.cmd =~/q/ end |