diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-01-23 21:52:37 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-01-23 21:52:37 -0500 |
commit | dc5c01b1033cfc9e09fd4fc29666e826e67cd7bb (patch) | |
tree | e53a389c4f669d79b5b82ce6fd1853da6b25f85d /lib/sisu/v3dv/odf.rb | |
parent | debian/changelog (3.1.11-1) (diff) | |
parent | v3dv: replace use of most ruby exclamation (!) method actions (diff) |
Merge commit 'sisu_3.1.12' into debian/sid
Diffstat (limited to 'lib/sisu/v3dv/odf.rb')
-rw-r--r-- | lib/sisu/v3dv/odf.rb | 227 |
1 files changed, 114 insertions, 113 deletions
diff --git a/lib/sisu/v3dv/odf.rb b/lib/sisu/v3dv/odf.rb index 4b90c543..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!(/&nbsp;| |#{Mx[:nbsp]}/,' ') - str.gsub!(/</,'<'); str.gsub!(/>/,'>') - str.gsub!(/<(text:span text:style-name="Span_\S+?"|\/text:span)>/,'<\1>') #works, not ideal - str.gsub!(/#{Mx[:br_line]}/,'<br />') - str.gsub!(/<br(?:\s+\/)?>/,'<br />') - str + str=str.gsub(/&nbsp;| |#{Mx[:nbsp]}/,' '). + gsub(/</,'<').gsub(/>/,'>'). + gsub(/<(text:span text:style-name="Span_\S+?"|\/text:span)>/,'<\1>'). #works, not ideal + gsub(/#{Mx[:br_line]}/,'<br />'). + gsub(/<br(?:\s+\/)?>/,'<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!(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">') - parablock.gsub!(/<(\/text:a)>/,'<\1>') - parablock.gsub!(/<(text:note text:id=.+?)>/,'<\1>') - parablock.gsub!(/<(text:p text:style-name="Footnote")>/,'<\1>') - parablock.gsub!(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') + parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">'). + gsub(/<(\/text:a)>/,'<\1>'). + gsub(/<(text:note text:id=.+?)>/,'<\1>'). + gsub(/<(text:p text:style-name="Footnote")>/,'<\1>'). + gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\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!(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">') - parablock.gsub!(/<(\/text:a)>/,'<\1>') - parablock.gsub!(/<(text:note text:id=.+?)>/,'<\1>') - parablock.gsub!(/<(text:p text:style-name="Footnote")>/,'<\1>') - parablock.gsub!(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') + parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">'). + gsub(/<(\/text:a)>/,'<\1>'). + gsub(/<(text:note text:id=.+?)>/,'<\1>'). + gsub(/<(text:p text:style-name="Footnote")>/,'<\1>'). + gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\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/,'  ') + dob.obj=dob.obj.gsub(/\s\s/,'  ') 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!(/</,'<'); dob.obj.gsub!(/>/,'>') + dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>') 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!(/ /,' ') + w=w.gsub(/&#(?:126|152);/,'~'). #126 usual + gsub(/ /,' ') if w !~/(?:&\S{2,7}?;)+/ - w.gsub!(/&/,'&') + w=w.gsub(/&/,'&') end if w !~/&\S{1,7}?;(?:&\S{1,7}?;)+/ #imperfect - w.gsub!(/(&\S{1,7};)+&/,'\1&') + w=w.gsub(/(&\S{1,7};)+&/,'\1&') 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!(/(^|[^}])_(?:<|<)/m,'\1<'); dob.obj.gsub!(/(^|[^}])_(?:>|>)/m,'\1>') - dob.obj.gsub!(/(^|[^}])_(?:<|<)/m,'\1<'); dob.obj.gsub!(/(^|[^}])_(?:>|>)/m,'\1>') + dob.obj=dob.obj.gsub(/(^|[^}])_(?:<|<)/m,'\1<').gsub(/(^|[^}])_(?:>|>)/m,'\1>'). + gsub(/(^|[^}])_(?:<|<)/m,'\1<').gsub(/(^|[^}])_(?:>|>)/m,'\1>') 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!(/©/,'©') #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,'<') - dob.obj.gsub!(/\\copy(?:right)?\b/,'©') - dob.obj.gsub!(/\\trademark\b|\\tm\b/,'®') - dob.obj.gsub!(/\44/,'$') #$ 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(/©/,'©'). #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,'<'). + gsub(/\\copy(?:right)?\b/,'©'). + gsub(/\\trademark\b|\\tm\b/,'®'). + gsub(/\44/,'$'). #$ 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 @@ -675,7 +676,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 |