aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3dv/odf.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3dv/odf.rb')
-rw-r--r--lib/sisu/v3dv/odf.rb225
1 files changed, 113 insertions, 112 deletions
diff --git a/lib/sisu/v3dv/odf.rb b/lib/sisu/v3dv/odf.rb
index 8f1f60b4..d58da74e 100644
--- a/lib/sisu/v3dv/odf.rb
+++ b/lib/sisu/v3dv/odf.rb
@@ -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 :-(
+ 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,23 +288,23 @@ 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=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
@@ -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
@@ -434,13 +433,13 @@ module SiSU_ODF
end
def code(dob,p_num) #P5
if dob.is=='code'
- dob.obj.gsub!(/\s\s/,'&#160;&#160;')
+ 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 \
@@ -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
@@ -548,50 +547,50 @@ module SiSU_ODF
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;')
+ 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]}/,'● ')
+ 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]}/,'')
+ 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 \
@@ -603,9 +602,11 @@ module SiSU_ODF
if dob.is=~/heading|para|group|verse|code|table|break/ # extend, include other types
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 +638,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 +661,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