aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/xml.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/xml.rb')
-rw-r--r--lib/sisu/v3/xml.rb127
1 files changed, 63 insertions, 64 deletions
diff --git a/lib/sisu/v3/xml.rb b/lib/sisu/v3/xml.rb
index 9ed3e871..aa75e139 100644
--- a/lib/sisu/v3/xml.rb
+++ b/lib/sisu/v3/xml.rb
@@ -64,9 +64,9 @@ module SiSU_XML_SAX
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_XML_SAX
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
@@ -93,7 +93,7 @@ module SiSU_XML_SAX
SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}").flow if @opt.cmd =~/[MV]/
end
SiSU_XML_SAX::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
#file closed in songsheet
end
@@ -102,29 +102,29 @@ module SiSU_XML_SAX
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_XML_SAX::Source::Scroll.new(@particulars).songsheet
SiSU_XML_SAX::Source::Tidy.new(@md,@file.place_file.xml_sax.dir).xml if @md.opt.cmd =~/[vVM]/ # test wellformedness, comment out when not in use
SiSU_Rexml::Rexml.new(@md,@file.place_file.xml_sax.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
end
class Scroll
require_relative 'shared_txt' # shared_txt.rb
- include SiSU_text_utils
+ include SiSU_TextUtils
require_relative 'css' # css.rb
require_relative 'shared_xhtml' # decide use, whether xml rather than xhtml
@@xml={ body: [], open: [], close: [], head: [] }
def initialize(particulars)
@env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array
- @vz=SiSU_Env::Get_init.instance.skin
- @trans=SiSU_XML_munge::Trans.new(@md)
- @sys=SiSU_Env::System_call.new
+ @vz=SiSU_Env::GetInit.instance.skin
+ @trans=SiSU_XML_Munge::Trans.new(@md)
+ @sys=SiSU_Env::SystemCall.new
end
def songsheet
pre
@@ -134,20 +134,20 @@ module SiSU_XML_SAX
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}<number>\\1</number>
#{Ax[:tab]*2}<note>
@@ -155,8 +155,8 @@ module SiSU_XML_SAX
#{Ax[:tab]*2}</note>
#{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}<symbol>\\1</symbol>
#{Ax[:tab]*2}<note>
@@ -164,8 +164,8 @@ WOK
#{Ax[:tab]*2}</note>
#{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}<symbol>\\1</symbol>
#{Ax[:tab]*2}<note>
@@ -178,7 +178,7 @@ WOK
end
end
def xml_head
- metadata=Metadata::Summary.new(@md).xml_sax.metadata
+ metadata=SiSU_Metadata::Summary.new(@md).xml_sax.metadata
@@xml[:head] << metadata
end
def xml_sc(md='')
@@ -204,18 +204,18 @@ WOK
@@xml[:sc]=sc
end
def xml_structure(dob,type='norm')
- 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
+ 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
#if defined? dob.obj
#t_ograph="#{dob.obj}"
- util=SiSU_text_utils::Wrap.new(dob.obj,70)
+ util=SiSU_TextUtils::Wrap.new(dob.obj,70)
wrapped=util.line_wrap
#end
@@xml[:body] << if defined? dob.ocn; %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
@@ -232,10 +232,10 @@ WOK
end
def block_structure(dob='')
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
+ 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
dob=@trans.markup_block(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="block">#{Ax[:tab]*1}}
@@ -247,10 +247,10 @@ WOK
end
def group_structure(dob='')
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
+ 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
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="group">#{Ax[:tab]*1}}
@@ -262,8 +262,8 @@ WOK
end
def poem_structure(dob='')
dob=@trans.markup_group(dob)
- #dob.obj.gsub!(/\s\s/,'&#160;&#160;')
- dob.obj.strip!
+ #dob.obj.gsub(/\s\s/,'&#160;&#160;')
+ 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">#{Ax[:tab]*1}}
@@ -273,8 +273,7 @@ WOK
end
def code_structure(dob='')
dob=@trans.markup_group(dob)
- dob.obj.gsub!(/\s\s/,'&#160;&#160;')
- dob.obj.strip!
+ dob.obj=dob.obj.gsub(/\s\s/,'&#160;&#160;').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">#{Ax[:tab]*1}}
@@ -283,7 +282,7 @@ WOK
@@xml[:body] << "#{Ax[:tab]*0}</object>"
end
def table_structure(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]*1}<text class="table">#{Ax[:tab]*1}}
@@ -307,20 +306,20 @@ WOK
@trans.char_enc.utf8(dob) if @sys.locale =~/utf-?8/i #% utf8
dob=@trans.markup(dob)
if @rcdc==false \
- and (dob.is =~/^meta/ \
+ and (dob.is ==:meta \
and dob.obj =~/Document Information/)
@rcdc=true
end
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
if defined? dob.ocn \
and dob.ocn.to_s =~/\d+/
- 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
@@ -331,25 +330,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' # FIX, check css, will need to modify
+ elsif dob.is==:table # FIX, check css, will need to modify
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}")
@@ -359,11 +358,11 @@ WOK
elsif dob.obj =~/(#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
elsif dob.obj =~/MetaData/
txt_obj={ txt: '<br /><a name="metadata">MetaData</a>' }
- format_scroll=Format_scroll.new(@md,txt_obj)
+ format_scroll=FormatScroll.new(@md,txt_obj)
dob.obj=format_scroll.bold_para
elsif dob.obj =~/(Owner Details)/
# txt_obj={ txt: '<br /><a name="owner.details">Owner Details</a>' }
-# format_scroll=Format_scroll.new(@md,txt_obj)
+# format_scroll=FormatScroll.new(@md,txt_obj)
# @@xml[:owner_details]=format_scroll.bold_para
dob.obj=''
end
@@ -374,13 +373,13 @@ 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
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|
@@ -394,16 +393,16 @@ WOK
#6.downto(1) { |x| y=x - 1; @@xml[:body] << "#{Ax[:tab]*y}</level #{x}>" if @level[x]==true }
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,'xml_sax').stylesheet
encoding=if @sys.locale =~/utf-?8/i; '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>'
end
@@xml[:open] =<<WOK
#{encoding}
-#{css.xml_sax}
+#{stylesheet.css_head_xml}
#{rdf.comment_xml}
<document>
WOK
@@ -421,7 +420,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).xml
@@xml={}
end
@@ -429,13 +428,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 xml
- SiSU_Env::SiSU_file.new(@md).mkdir
+ SiSU_Env::FileOp.new(@md).mkdir
filename_xml=@file.write_file.xml_sax
@data.each do |str|
- str.gsub!(/\A\s+\Z/m,'') #str.gsub!(/^\s+$/,'')
+ str=str.gsub(/\A\s+\Z/m,'')
filename_xml.puts str unless str.empty?
end
filename_xml.close
@@ -444,7 +443,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 #note values can be other than true
@@ -455,7 +454,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