aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/odf.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2012-03-19 22:07:29 -0400
committerRalph Amissah <ralph@amissah.com>2012-03-19 22:07:33 -0400
commit6811ac91f21a434fc7d967c11e1b20f33918c6ea (patch)
tree30f39674ca96a79f8a604a9f02d571f24320e221 /lib/sisu/v3/odf.rb
parentv3: 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/odf.rb')
-rw-r--r--lib/sisu/v3/odf.rb297
1 files changed, 152 insertions, 145 deletions
diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb
index 6cdbd57b..68aa6e40 100644
--- a/lib/sisu/v3/odf.rb
+++ b/lib/sisu/v3/odf.rb
@@ -64,7 +64,7 @@ module SiSU_ODF
include SiSU_Env
include SiSU_Viz
require_relative 'odf_format' # odf_format.rb
- include SiSU_ODF_format
+ include SiSU_ODF_Format
require_relative 'shared_metadata' # shared_metadata.rb
require_relative 'shared_txt' # shared_txt.rb
@@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
@@ -73,7 +73,7 @@ module SiSU_ODF
require 'find'
def initialize(opt)
@opt=opt
- @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt)
+ @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
@@endnotes_para=[]
end
def read
@@ -89,8 +89,8 @@ module SiSU_ODF
SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}").flow if @opt.cmd =~/[MV]/
end
SiSU_ODF::Source::Scroll.new(@particulars).songsheet
- SiSU_Env::Info_skin.new(@md).select
- rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ SiSU_Env::InfoSkin.new(@md).select
+ rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error
ensure
end
end
@@ -104,7 +104,7 @@ module SiSU_ODF
@@fns=nil
def initialize(particulars)
@md,@env,@dal_array=particulars.md,particulars.env,particulars.dal_array
- @vz=SiSU_Env::Get_init.instance.skin
+ @vz=SiSU_Env::GetInit.instance.skin
@tab="\t"
@brace_url=SiSU_Viz::Skin.new.url_decoration
@br=(@md.opt.cmd =~/M/) ? '' : ''
@@ -143,7 +143,7 @@ module SiSU_ODF
end
end
def odf_metadata
- @@odf[:metadata]=Metadata::Summary.new(@md).odf.metadata
+ @@odf[:metadata]=SiSU_Metadata::Summary.new(@md).odf.metadata
end
def odf_tail
generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version]
@@ -161,7 +161,7 @@ module SiSU_ODF
@@odf[:tail] << "\n</office:text></office:body></office:document-content>"
end
def heading(dob,p_num='')
- dob.obj.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check
+ dob.obj=dob.obj.gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check
m=/#{$1}/
breakpage=''
if @md.fns \
@@ -232,29 +232,29 @@ module SiSU_ODF
end
if m; m.each do |i|
cont,url=i[1],i[2]
- cont.gsub!(/([)(\]\[])/,"\\\\\\1")
- cont.gsub!(/([+?])/,"\\\\\\1") # incorrect handling of +
- url.gsub!(/([+?])/,"\\\\\\1")
- dob.obj.sub!(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}image/m,image_odf(i))
- dob.obj.sub!(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,image_odf(i))
- dob.obj.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix
+ cont=cont.gsub(/([)(\]\[])/,"\\\\\\1").
+ gsub(/([+?])/,"\\\\\\1") # incorrect handling of +
+ url=url.gsub(/([+?])/,"\\\\\\1")
+ dob.obj=dob.obj.sub(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}image/m,image_odf(i)).
+ sub(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,image_odf(i)).
+ sub(/\\([)(\]\[?])/,'\1') #clumsy fix
end
m=nil
end
dob
end
def text_link_odf(txt,url,trail)
- txt.gsub!(/(\\\+)/,'+') #this is convoluted, and risky :-(
- url.gsub!(/(\\\+)/,'+') #this is convoluted, and risky :-(
- map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map
+ txt=txt.gsub(/(\\\+)/,'+') #this is convoluted, and risky :-(
+ url=url.gsub(/(\\\+)/,'+') #this is convoluted, and risky :-(
+ map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map
t=case url
when /^https?:/
%{<text:a xlink:type="simple" xlink:href="#{url}">#{txt.strip}</text:a>#{trail}}
when /^:/ # site same document collection html link
- url.gsub!(/^:/,"#{@env.url.root}/")
+ url=url.gsub(/^:/,"#{@env.url.root}/")
%{<text:a xlink:type="simple" xlink:href="#{url}">#{txt.strip}</text:a>#{trail}}
when /^\.\.\// # site same document collection html link
- url.gsub!(/^\.\.\//,"#{@env.url.root}/")
+ url=url.gsub(/^\.\.\//,"#{@env.url.root}/")
%{<text:a xlink:type="simple" xlink:href="#{url}">#{txt.strip}</text:a>#{trail}}
else # document internal link
if map_nametags[url] \
@@ -273,11 +273,11 @@ module SiSU_ODF
if m
m.each do |i|
txt,url,trail=i[1],i[2]
- txt.gsub!(/([)(\]\[])/,"\\\\\\1")
- txt.gsub!(/([+?*])/,"\\\\\\1") # problems with +
- url.gsub!(/([+?])/,"\\\\\\1") # problems with +
- dob.obj.gsub!(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url
- dob.obj.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix
+ txt=txt.gsub(/([)(\]\[])/,"\\\\\\1").
+ gsub(/([+?*])/,"\\\\\\1") # problems with +
+ url=url.gsub(/([+?])/,"\\\\\\1") # problems with +
+ dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url
+ gsub(/\\([)(\]\[?])/,'\1') #clumsy fix
end
m=nil
end
@@ -288,28 +288,28 @@ module SiSU_ODF
if m
m.each do |i|
txt,url,trail=i[1],i[2]
- txt.gsub!(/([)(\]\[])/,"\\\\\\1")
- txt.gsub!(/([+?*])/,"\\\\\\1") # problems with +
- url.gsub!(/([+?])/,"\\\\\\1") # problems with +
- dob.obj.gsub!(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url
- dob.obj.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix
+ txt=txt.gsub(/([)(\]\[])/,"\\\\\\1").
+ gsub(/([+?*])/,"\\\\\\1") # problems with +
+ url=url.gsub(/([+?])/,"\\\\\\1") # problems with +
+ dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url
+ gsub(/\\([)(\]\[?])/,'\1') #clumsy fix
end
m=nil
end
dob
end
def normal(dob,p_num='') #P1 - P3
- dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
- '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration
- dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
- %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}})
- dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
- %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration
- dob.obj= if dob.is=='para' \
+ dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
+ '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration
+ gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
+ %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}).
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
+ %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration
+ dob.obj= if dob.is==:para \
and dob.indent.to_s =~/[0-9]/ \
and dob.indent == dob.hang
%{<text:p text:style-name="P_indent_#{dob.indent}">#{dob.obj}#{p_num}</text:p>}
- elsif dob.is=='para' \
+ elsif dob.is==:para \
and dob.hang.to_s =~/[0-9]/ \
and dob.indent != dob.hang
%{<text:p text:style-name="P_h#{dob.hang}_i#{dob.indent}">#{dob.obj}#{p_num}</text:p>}
@@ -320,7 +320,7 @@ module SiSU_ODF
def fontface(dob)
end
def footnote_urls(str)
- str.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
+ str=str.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
%{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}})
str=text_link(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
str=text_link_relative(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
@@ -334,11 +334,11 @@ module SiSU_ODF
@astx||=10000
@astxs||=20000
if str =~/#{Mx[:en_a_o]}\d+\s+/
- str.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,'<text:note text:id="ftn\1" text:note-class="footnote"><text:note-citation>\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>')
+ str=str.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,'<text:note text:id="ftn\1" text:note-class="footnote"><text:note-citation>\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>')
end
if str =~/#{Mx[:en_a_o]}([*]+)\s+/
a=$1.gsub(/([*])/,"\\\\\\1")
- str.gsub!(/#{Mx[:en_a_o]}([*]+)\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
+ str=str.gsub(/#{Mx[:en_a_o]}([*]+)\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
@astxs+=1
end
if str=~/#{Mx[:en_a_o]}[*+]+\s/
@@ -347,7 +347,7 @@ module SiSU_ODF
a=x[0].gsub(/([*+])/,"\\\\\\1")
str=group_clean(str)
str=footnote_urls(str)
- str.gsub!(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
+ str=str.gsub(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
@astx+=1
end
end
@@ -357,7 +357,7 @@ module SiSU_ODF
a=x[0].gsub(/([*+])/,"\\\\\\1")
str=group_clean(str)
str=footnote_urls(str)
- str.gsub!(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
+ str=str.gsub(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
@astx+=1
end
end
@@ -368,12 +368,11 @@ module SiSU_ODF
t_o
end
def group_clean(str)
- str.gsub!(/&amp;nbsp;|&nbsp;|#{Mx[:nbsp]}/,'&#160;')
- str.gsub!(/</,'&lt;'); str.gsub!(/>/,'&gt;')
- str.gsub!(/&lt;(text:span text:style-name="Span_\S+?"|\/text:span)&gt;/,'<\1>') #works, not ideal
- str.gsub!(/#{Mx[:br_line]}/,'<br />')
- str.gsub!(/&lt;br(?:\s+\/)?&gt;/,'<br />')
- str
+ str=str.gsub(/&amp;nbsp;|&nbsp;|#{Mx[:nbsp]}/,'&#160;').
+ gsub(/</,'&lt;').gsub(/>/,'&gt;').
+ gsub(/&lt;(text:span text:style-name="Span_\S+?"|\/text:span)&gt;/,'<\1>'). #works, not ideal
+ gsub(/#{Mx[:br_line]}/,'<br />').
+ gsub(/&lt;br(?:\s+\/)?&gt;/,'<br />')
end
def poem(dob,p_num) #P4 #same as group
parray=[]
@@ -388,19 +387,19 @@ module SiSU_ODF
end
def group(dob,p_num) #P4 #same as verse
parray=[]
- dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
- '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration
- dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
- %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}})
- dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
- %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration
+ dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
+ '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration
+ gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
+ %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}).
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
+ %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration
dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock|
parablock=group_clean(parablock)
- parablock.gsub!(/&lt;text:a xlink:type="simple" xlink:href="(.+?)"&gt;/m,'<text:a xlink:type="simple" xlink:href="\1">')
- parablock.gsub!(/&lt;(\/text:a)&gt;/,'<\1>')
- parablock.gsub!(/&lt;(text:note text:id=.+?)&gt;/,'<\1>')
- parablock.gsub!(/&lt;(text:p text:style-name="Footnote")&gt;/,'<\1>')
- parablock.gsub!(/&lt;(\/?text:(?:note-citation|note-body|note|p))&gt;/,'<\1>')
+ parablock=parablock.gsub(/&lt;text:a xlink:type="simple" xlink:href="(.+?)"&gt;/m,'<text:a xlink:type="simple" xlink:href="\1">').
+ gsub(/&lt;(\/text:a)&gt;/,'<\1>').
+ gsub(/&lt;(text:note text:id=.+?)&gt;/,'<\1>').
+ gsub(/&lt;(text:p text:style-name="Footnote")&gt;/,'<\1>').
+ gsub(/&lt;(\/?text:(?:note-citation|note-body|note|p))&gt;/,'<\1>')
parablock=footnote(parablock)
parray << %{<text:p text:style-name="P_group">#{parablock}</text:p>} if parablock =~/\S+/
end
@@ -411,19 +410,19 @@ module SiSU_ODF
end
def block(dob,p_num) #P4 #same as verse
parray=[]
- dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
- '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration
- dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
- %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}})
- dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
- %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration
+ dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
+ '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration
+ gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
+ %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}).
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
+ %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration
dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock|
parablock=group_clean(parablock)
- parablock.gsub!(/&lt;text:a xlink:type="simple" xlink:href="(.+?)"&gt;/m,'<text:a xlink:type="simple" xlink:href="\1">')
- parablock.gsub!(/&lt;(\/text:a)&gt;/,'<\1>')
- parablock.gsub!(/&lt;(text:note text:id=.+?)&gt;/,'<\1>')
- parablock.gsub!(/&lt;(text:p text:style-name="Footnote")&gt;/,'<\1>')
- parablock.gsub!(/&lt;(\/?text:(?:note-citation|note-body|note|p))&gt;/,'<\1>')
+ parablock=parablock.gsub(/&lt;text:a xlink:type="simple" xlink:href="(.+?)"&gt;/m,'<text:a xlink:type="simple" xlink:href="\1">').
+ gsub(/&lt;(\/text:a)&gt;/,'<\1>').
+ gsub(/&lt;(text:note text:id=.+?)&gt;/,'<\1>').
+ gsub(/&lt;(text:p text:style-name="Footnote")&gt;/,'<\1>').
+ gsub(/&lt;(\/?text:(?:note-citation|note-body|note|p))&gt;/,'<\1>')
parablock=footnote(parablock)
parray << %{<text:p text:style-name="P_group">#{parablock}</text:p>} if parablock =~/\S+/
end
@@ -433,14 +432,14 @@ module SiSU_ODF
dob
end
def code(dob,p_num) #P5
- if dob.is=='code'
- dob.obj.gsub!(/\s\s/,'&#160;&#160;')
+ if dob.is==:code
+ dob.obj=dob.obj.gsub(/\s\s/,'&#160;&#160;')
parray=[]
dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock|
parablock=group_clean(parablock)
- parablock.gsub!(/^\s*$/,'<br />')
- parablock.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
- '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration
+ parablock=parablock.gsub(/^\s*$/,'<br />').
+ gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
+ '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration
parray << %{<text:p text:style-name="P_code">#{parablock}</text:p>} if parablock =~/\S+/
end
dob.obj=parray.join \
@@ -450,15 +449,15 @@ module SiSU_ODF
dob
end
def table(dob,p_num) #
- if dob.is =='table'
- table=SiSU_ODF_format::Table.new(@md,dob,p_num)
+ if dob.is ==:table
+ table=SiSU_ODF_Format::Table.new(@md,dob,p_num)
dob=table.table
end
dob
end
def obj_break(dob)
- if dob.is =='break'
- br=SiSU_ODF_format::Format_obj_break.new(@md,dob)
+ if dob.is ==:break
+ br=SiSU_ODF_Format::FormatObjBreak.new(@md,dob)
if dob.obj==Mx[:br_page] \
or dob.obj==Mx[:br_page_new]
dob=br.br_page
@@ -470,7 +469,7 @@ module SiSU_ODF
end
def odf_structure(md,dob)
@md,@dob=md,dob
- dob=if dob.is !='code'
+ dob=if dob.is !=:code
dob=image(dob) if dob.obj =~/#{Mx[:lnk_o]}[ ]*\S+?\.(?:png|jpg|gif)\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
dob=text_link(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
dob=text_link_relative(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
@@ -482,24 +481,24 @@ module SiSU_ODF
if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
if defined? dob.ocn \
and not dob.ocn.nil?
- p_num=SiSU_ODF_format::Paragraph_number.new(dob.ocn).display
+ p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).display
end
end
end
dob=footnote(dob)
- if dob.is=='heading'
+ if dob.is==:heading
@@odf[:body] << heading(dob,p_num).obj << @br*2
- elsif dob.is =='verse'
+ elsif dob.is ==:verse
@@odf[:body] << poem(dob,p_num).obj << @br*2
- elsif dob.is=='group'
+ elsif dob.is==:group
@@odf[:body] << group(dob,p_num).obj << @br*2
- elsif dob.is=='block'
+ elsif dob.is==:block
@@odf[:body] << block(dob,p_num).obj << @br*2
- elsif dob.is=='code'
+ elsif dob.is==:code
@@odf[:body] << code(dob,p_num).obj << @br*2
- elsif dob.is=='table' #elsif dob.obj =~ /<!Th?¡/u
+ elsif dob.is==:table #elsif dob.obj =~ /<!Th?¡/u
@@odf[:body] << table(dob,p_num).obj << @br*2
- elsif dob.is=='break'
+ elsif dob.is==:break
@@odf[:body] << obj_break(dob).obj << @br*2
else
@@odf[:body] << normal(dob,p_num).obj << @br*2 # main text, contents, body KEEP
@@ -511,7 +510,7 @@ module SiSU_ODF
end
def markup(data) # Used for major markup instructions
safe_characters=/[^a-zA-Z0-9}{\/?,."';:)(><\-_&!@%~#\]\[*=$| \n+`#{Mx[:tc_p]}]/u
- dir=SiSU_Env::Info_env.new(@md.fns)
+ dir=SiSU_Env::InfoEnv.new(@md.fns)
dir.path.odt_bld
@data_mod,@endnotes,@level,@cont,@copen,@odf_contents_close=Array.new(6){[]}
@rcdc=false
@@ -528,18 +527,18 @@ module SiSU_ODF
#p dob.obj if dob.obj =~safe_characters and @md.opt.cmd =~/V/ #KEEP
dob.obj='' if dob.obj =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ #fix Mx[:lv_o]
para_array=[]
- dob.obj.gsub!(/</,'&lt;'); dob.obj.gsub!(/>/,'&gt;')
+ dob.obj=dob.obj.gsub(/</,'&lt;').gsub(/>/,'&gt;')
word=dob.obj.scan(/\S+|\n/)
if word
word.each do |w| # _ - / # | : ! ^ ~
unless dob =~/^(?:#{Rx[:meta]}|%+ )/m
- w.gsub!(/&#(?:126|152);/,'~') #126 usual
- w.gsub!(/&nbsp;/,'&#160;')
+ w=w.gsub(/&#(?:126|152);/,'~'). #126 usual
+ gsub(/&nbsp;/,'&#160;')
if w !~/(?:&\S{2,7}?;)+/
- w.gsub!(/&/,'&amp;')
+ w=w.gsub(/&/,'&amp;')
end
if w !~/&\S{1,7}?;(?:&\S{1,7}?;)+/ #imperfect
- w.gsub!(/(&\S{1,7};)+&/,'\1&amp;')
+ w=w.gsub(/(&\S{1,7};)+&/,'\1&amp;')
end
end
para_array << w
@@ -547,65 +546,73 @@ module SiSU_ODF
dob.obj=para_array.join(' ')
dob.obj=dob.obj.strip
end
- if dob.is=='code' #{Mx[:gr_o]}code#{Mx[:gr_c]}/ #fix #code-block: angle brackets special characters #fix
- dob.obj.gsub!(/(^|[^}])_(?:<|&lt;)/m,'\1&lt;'); dob.obj.gsub!(/(^|[^}])_(?:>|&gt;)/m,'\1&gt;')
- dob.obj.gsub!(/(^|[^}])_(?:<|&lt;)/m,'\1&lt;'); dob.obj.gsub!(/(^|[^}])_(?:>|&gt;)/m,'\1&gt;')
+ if dob.is==:code #{Mx[:gr_o]}code#{Mx[:gr_c]}/ #fix #code-block: angle brackets special characters #fix
+ dob.obj=dob.obj.gsub(/(^|[^}])_(?:<|&lt;)/m,'\1&lt;').gsub(/(^|[^}])_(?:>|&gt;)/m,'\1&gt;').
+ gsub(/(^|[^}])_(?:<|&lt;)/m,'\1&lt;').gsub(/(^|[^}])_(?:>|&gt;)/m,'\1&gt;')
end
- if dob.of=='block'
- dob.obj.gsub!(/#{Mx[:gl_bullet]}/,'● ')
+ if dob.of==:block
+ dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ')
end
- dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>')
- dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>')
- dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>')
- dob.obj.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check
- dob.obj.gsub!(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;')
- dob.obj.gsub!(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
- dob.obj.gsub!(/#{Mx[:mk_o]}[~-]##{Mx[:mk_c]}/,'')
- if dob.is=='para' \
+ dob.obj=dob.obj.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
+ gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,''). #check
+ gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
+ gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;').
+ gsub(/#{Mx[:mk_o]}[~-]##{Mx[:mk_c]}/,'')
+ if dob.is==:para \
and dob.bullet_
dob.obj='<draw:frame draw:style-name="gr1" text:anchor-type="as-char" svg:width="0.22cm" svg:height="0.22cm" draw:z-index="2"><draw:image xlink:href="Pictures/bullet_09.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> ' +
dob.obj
end
- dob.obj.gsub!(/#{Mx[:br_line]}/,'<br />')
- dob.obj.gsub!(/&#169;/,'©') #too arbitrary
- dob.obj.gsub!(/.+?<-#>/,'') # remove dummy headings (used by html) #check
- dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
- '<text:span text:style-name="Span_bold">\1</text:span>')
- dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
- '<text:span text:style-name="Span_italic">\1</text:span>')
- dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
- '<text:span text:style-name="Span_underscore">\1</text:span>')
- dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
- '<text:span text:style-name="Span_superscript">\1</text:span>')
- dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
- '<text:span text:style-name="Span_subscript">\1</text:span>')
- dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
- '<text:span text:style-name="Span_monospace">\1</text:span>')
- dob.obj.gsub!(/­/u,'-')
- dob.obj.gsub!(/ /u, ' ') # space identify
- dob.obj.gsub!(/ /u, ' ') # space identify
- dob.obj.gsub!(/·/u,'*')
- dob.obj.gsub!(/[­–—]/u,'-') #— – chk
- dob.obj.gsub!(/ < /i,'&#060;')
- dob.obj.gsub!(/\\copy(?:right)?\b/,'&#169;')
- dob.obj.gsub!(/\\trademark\b|\\tm\b/,'&#174;')
- dob.obj.gsub!(/\44/,'&#36;') #$ watch
- dob.obj.gsub!(/<a href=".+?">(.+?)<\/a>/,'\1')
- dob.obj.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links
+ dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/,'<br />').
+ gsub(/&#169;/,'©'). #too arbitrary
+ gsub(/.+?<-#>/,''). # remove dummy headings (used by html) #check
+ gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
+ '<text:span text:style-name="Span_bold">\1</text:span>').
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
+ '<text:span text:style-name="Span_italic">\1</text:span>').
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
+ '<text:span text:style-name="Span_underscore">\1</text:span>').
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
+ '<text:span text:style-name="Span_superscript">\1</text:span>').
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
+ '<text:span text:style-name="Span_subscript">\1</text:span>').
+ gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
+ '<text:span text:style-name="Span_monospace">\1</text:span>').
+ gsub(/­/u,'-').
+ gsub(/ /u, ' '). # space identify
+ gsub(/ /u, ' '). # space identify
+ gsub(/·/u,'*').
+ gsub(/[­–—]/u,'-'). #— – chk
+ gsub(/ < /i,'&#060;').
+ gsub(/\\copy(?:right)?\b/,'&#169;').
+ gsub(/\\trademark\b|\\tm\b/,'&#174;').
+ gsub(/\44/,'&#36;'). #$ watch
+ gsub(/<a href=".+?">(.+?)<\/a>/,'\1').
+ gsub(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links
wordlist=dob.obj.scan(/\S+/)
dob.obj=tidywords(wordlist).join(' ').strip
@rcdc=true if @rcdc==false \
and (dob.obj =~/~metadata/ or dob =~/#{Mx[:lv_o]}1:meta#{Mx[:lv_x]}\s*Document Information/) #fix Mx[:lv_o]
- if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
+ if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ #check
if defined? dob.ocn and dob.ocn =~/\d+/
- @p_num=SiSU_ODF_format::Paragraph_number.new(dob.ocn)
+ @p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn)
end
- if dob.is=~/heading|para|group|verse|code|table|break/ # extend, include other types
+ if dob.is ==:heading \
+ || dob.is ==:para \
+ || dob.is ==:group \
+ || dob.is ==:verse \
+ || dob.is ==:code \
+ || dob.is ==:table \
+ || dob.is ==:break
odf_structure(@md,dob)
end
- dob.obj.gsub!(/<!.+!>/,' ') if dob.obj ## Clean Prepared Text
- dob.obj.gsub!(/#{Mx[:tc_o]}.+?#{Mx[:tc_c]}/,' ') if dob.obj ## CHECK Clean Prepared Text
- dob.obj.gsub!(/<:\S+>/,' ') if dob.obj ## Clean Prepared Text
+ if dob.obj ## Clean Prepared Text
+ dob.obj=dob.obj.gsub(/<!.+!>/,' ').
+ gsub(/#{Mx[:tc_o]}.+?#{Mx[:tc_c]}/,' ').
+ gsub(/<:\S+>/,' ')
+ end
end
end
end
@@ -637,8 +644,8 @@ module SiSU_ODF
<style:style style:name="Table2.M" style:family="table-column"><style:table-column-properties style:column-width="1.307" style:rel-column-width="5041*"/></style:style>
<style:style style:name="Table2.N" style:family="table-column"><style:table-column-properties style:column-width="1.214cm" style:rel-column-width="4681*"/></style:style>
WOK
- x.strip!
- x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/
+ x=x.strip
+ x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/
x
else ''
end
@@ -660,8 +667,8 @@ WOK
<office:forms form:automatic-focus="false" form:apply-design-mode="false"/>
<text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls>
WOK
- x.strip!
- x.gsub!(/\n+/m,'') unless @md.opt.cmd=~/M/
+ x=x.strip
+ x=x.gsub(/\n+/m,'') unless @md.opt.cmd=~/M/
@@odf[:head] << x
end
def post
@@ -675,7 +682,7 @@ WOK
content << @@odf[:body]
content << @@odf[:metadata]
content << @@odf[:tail]
- Output.new(content,@md,@env).odf
+ SiSU_ODF::Source::Output.new(content,@md,@env).odf
@@odf[:head],@@odf[:body],@@odf[:tail],@@odf[:metadata]=[],[],[],[]
end
end
@@ -684,9 +691,9 @@ WOK
@content,@md,@env=content,md,env
end
def odf #%odf output
- env=SiSU_Env::SiSU_file.new(@md)
+ env=SiSU_Env::FileOp.new(@md)
env.mkdir
- header=SiSU_ODF_format::ODT_head_1_2.new(@md)
+ header=SiSU_ODF_Format::ODT_Head_1_2.new(@md)
filename="#{@env.processing_path.odt}/manifest.rdf"
od=File.new(filename,'w+')
od << header.manifest_rdf