From 21f5e220b738add01c19c2b15a76f2d240b2c0d5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 23 Jan 2012 21:42:25 -0500 Subject: v3dv: replace use of most ruby exclamation (!) method actions --- lib/sisu/v3dv/author_format.rb | 6 +- lib/sisu/v3dv/cgi_pgsql.rb | 20 +- lib/sisu/v3dv/cgi_sql_common.rb | 24 +- lib/sisu/v3dv/cgi_sqlite.rb | 14 +- lib/sisu/v3dv/composite.rb | 19 +- lib/sisu/v3dv/concordance.rb | 71 +-- lib/sisu/v3dv/dal_character_check.rb | 29 +- lib/sisu/v3dv/dal_doc_str.rb | 137 +++-- lib/sisu/v3dv/dal_endnotes.rb | 6 +- lib/sisu/v3dv/dal_expand_insertions.rb | 2 +- lib/sisu/v3dv/dal_hash_digest.rb | 17 +- lib/sisu/v3dv/dal_idx.rb | 23 +- lib/sisu/v3dv/dal_images.rb | 10 +- lib/sisu/v3dv/dal_numbering.rb | 73 ++- lib/sisu/v3dv/dal_substitutions_and_insertions.rb | 22 +- lib/sisu/v3dv/dal_syntax.rb | 410 +++++++------ lib/sisu/v3dv/db_columns.rb | 180 +++--- lib/sisu/v3dv/db_import.rb | 38 +- lib/sisu/v3dv/db_sqltxt.rb | 60 +- lib/sisu/v3dv/defaults.rb | 8 +- lib/sisu/v3dv/digests.rb | 6 +- lib/sisu/v3dv/epub.rb | 6 +- lib/sisu/v3dv/epub_concordance.rb | 60 +- lib/sisu/v3dv/epub_format.rb | 128 ++-- lib/sisu/v3dv/epub_segments.rb | 23 +- lib/sisu/v3dv/epub_tune.rb | 328 +++++------ lib/sisu/v3dv/harvest_authors.rb | 4 +- lib/sisu/v3dv/harvest_topics.rb | 4 +- lib/sisu/v3dv/html.rb | 32 +- lib/sisu/v3dv/html_format.rb | 47 +- lib/sisu/v3dv/html_minitoc.rb | 16 +- lib/sisu/v3dv/html_scroll.rb | 16 +- lib/sisu/v3dv/html_segments.rb | 24 +- lib/sisu/v3dv/html_tune.rb | 274 +++++---- lib/sisu/v3dv/manifest.rb | 13 +- lib/sisu/v3dv/manpage.rb | 134 ++--- lib/sisu/v3dv/odf.rb | 225 +++---- lib/sisu/v3dv/odf_format.rb | 28 +- lib/sisu/v3dv/options.rb | 15 +- lib/sisu/v3dv/param.rb | 54 +- lib/sisu/v3dv/plaintext.rb | 122 ++-- lib/sisu/v3dv/plaintext_format.rb | 4 +- lib/sisu/v3dv/po4a.rb | 136 ++--- lib/sisu/v3dv/po4a_set.rb | 8 +- lib/sisu/v3dv/qrcode.rb | 6 +- lib/sisu/v3dv/remote.rb | 5 +- lib/sisu/v3dv/shared_html_lite.rb | 94 +-- lib/sisu/v3dv/shared_markup_alt.rb | 128 ++-- lib/sisu/v3dv/shared_metadata.rb | 242 ++++---- lib/sisu/v3dv/shared_txt.rb | 4 +- lib/sisu/v3dv/shared_xml.rb | 683 +++++++++++----------- lib/sisu/v3dv/sisupod_make.rb | 7 +- lib/sisu/v3dv/spell.rb | 28 +- lib/sisu/v3dv/sysenv.rb | 12 +- lib/sisu/v3dv/texinfo.rb | 40 +- lib/sisu/v3dv/texinfo_format.rb | 212 ++++--- lib/sisu/v3dv/texpdf.rb | 90 +-- lib/sisu/v3dv/texpdf_format.rb | 424 +++++++------- lib/sisu/v3dv/xhtml.rb | 51 +- lib/sisu/v3dv/xhtml_table.rb | 4 +- lib/sisu/v3dv/xml.rb | 51 +- lib/sisu/v3dv/xml_dom.rb | 33 +- lib/sisu/v3dv/xml_fictionbook.rb | 6 +- lib/sisu/v3dv/xml_format.rb | 27 +- lib/sisu/v3dv/xml_md_oai_pmh_dc.rb | 2 +- lib/sisu/v3dv/xml_tables.rb | 42 +- 66 files changed, 2535 insertions(+), 2532 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3dv/author_format.rb b/lib/sisu/v3dv/author_format.rb index 8d219c93..cfc485f3 100644 --- a/lib/sisu/v3dv/author_format.rb +++ b/lib/sisu/v3dv/author_format.rb @@ -65,14 +65,14 @@ module SiSU_FormatAuthor @authors,@author_array=[],[] authors=@author_param.scan(/[^;]+/) authors.each do |a| - a.strip! + a=a.strip if a =~/"(.+?)"/ @authors << { the: $1 } @author_array << $1.upcase else #if a =~/,/ x=a.scan(/[^,]+/) - x[0].strip! - x[1].strip! if x[1] + x[0]=x[0].strip + x[1]=x[1].strip if x[1] if x.length==1 @authors << { the: x[0] } @author_array << x[0].upcase diff --git a/lib/sisu/v3dv/cgi_pgsql.rb b/lib/sisu/v3dv/cgi_pgsql.rb index 48d49774..26a85874 100644 --- a/lib/sisu/v3dv/cgi_pgsql.rb +++ b/lib/sisu/v3dv/cgi_pgsql.rb @@ -82,7 +82,7 @@ module SiSU_CGI_PgSQL end else put "WARNING: no postgresql database available, (have you created one?)" end - serve.sort! + serve=serve.sort f1,f2,f3='','','' serve.each do |x| f1 << %{ \n} unless x =~/apache|sisu\/image/ #check @@ -151,12 +151,12 @@ module SiSU_CGI_PgSQL elsif @q =~/\S+/; unescaped_search=CGI.unescape(@q) end search_construct=[] - if @c - unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~\( '") - unescaped_search.gsub!(/(.+)/,"#{@l}~\( '\\1' \)") + unescaped_search=if @c + unescaped_search.gsub(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~\( '"). + gsub(/(.+)/,"#{@l}~\( '\\1' \)") else - unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~*\( '") - unescaped_search.gsub!(/(.+)/,"#{@l}~*\( '\\1' \)") + unescaped_search.gsub(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~*\( '"). + gsub(/(.+)/,"#{@l}~*\( '\\1' \)") end search_construct << unescaped_search search_construct=search_construct.join(' ') @@ -173,11 +173,11 @@ module SiSU_CGI_PgSQL <<-'WOK_SQL' @search_text,@search_endnotes='','' search[:text].flatten.each {|x| @search_text << "#{x} AND " } - @search_text=@search_text.gsub!(/AND\s+$/m,'') #watch - @search_text.gsub!(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') + @search_text=@search_text.gsub(/AND\s+$/m,''). #watch + gsub(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.gsub!(/AND\s+$/m,'') #watch - @search_endnotes.gsub!(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)') + @search_endnotes=@search_endnotes.gsub(/AND\s+$/m,''). #watch + gsub(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)') end WOK_SQL end diff --git a/lib/sisu/v3dv/cgi_sql_common.rb b/lib/sisu/v3dv/cgi_sql_common.rb index 59844d2b..0f17bb79 100644 --- a/lib/sisu/v3dv/cgi_sql_common.rb +++ b/lib/sisu/v3dv/cgi_sql_common.rb @@ -311,12 +311,10 @@ module SiSU_CGI_SQL elsif @search_field =~m[:string]; m[:string].match(@search_field)[1] else str=m[:word].match(@search_field)[1] - str.gsub!(/[()]/,'') + str=str.gsub(/[()]/,'') str end - search_string.strip! - search_string.gsub!(/\s+/,'+') - search_string + search_string=search_string.strip.search_string.gsub(/\s+/,'+') #else # "__" end @@ -756,13 +754,13 @@ module SiSU_CGI_SQL elsif checked_all =~/checked/ or checked_url =~/checked/ canned_search=@@canned_search_url.scan(/(?:s1|ft|au|ti|fns|tr)=[^&]+/) af=canned_search.join('; ') - af.gsub!(/s1=/,'text: ') - af.gsub!(/ft=/,'fulltxt: ') - af.gsub!(/au=/,'author: ') - af.gsub!(/ti=/,'title: ') - af.gsub!(/fns=/,'filename: ') - af.gsub!(/tr=/,'topic_register: ') - af.gsub!(/%2B/,' ') + af=af.gsub(/s1=/,'text: '). + gsub(/ft=/,'fulltxt: '). + gsub(/au=/,'author: '). + gsub(/ti=/,'title: '). + gsub(/fns=/,'filename: '). + gsub(/tr=/,'topic_register: '). + gsub(/%2B/,' ') analyze_format=af st=af.split(/\s*;\s*/) search_field=st.join("\n") @@ -916,7 +914,7 @@ module SiSU_CGI_SQL file_suffix=c['src_filename'][/.+?\.(_?sst|ssm)$/,1] lang=if location =~ /\S+?~(\S\S\S?)$/ l=location[/\S+?~(\S\S\S?)$/,1] - location.gsub!(/(\S+?)~\S\S\S?/,'\1') + location=location.gsub(/(\S+?)~\S\S\S?/,'\1') l=".#{l}" else '' end @@ -1008,7 +1006,7 @@ module SiSU_CGI_SQL file_suffix=e['src_filename'][/.+?\.(_?sst|ssm)$/,1] lang=if location =~ /\S+?~(\S\S\S?)$/ l=location[/\S+?~(\S\S\S?)$/,1] - location.gsub!(/(\S+?)~\S\S\S?/,'\1') + location=location.gsub(/(\S+?)~\S\S\S?/,'\1') l=".#{l}" else '' end diff --git a/lib/sisu/v3dv/cgi_sqlite.rb b/lib/sisu/v3dv/cgi_sqlite.rb index 166bda77..31ba44c4 100644 --- a/lib/sisu/v3dv/cgi_sqlite.rb +++ b/lib/sisu/v3dv/cgi_sqlite.rb @@ -78,7 +78,7 @@ module SiSU_CGI_SQLite end end end - serve.sort! + serve=serve.sort f1,f2,f3='','','' serve.each do |x| f1 << %{ \n} @@ -148,8 +148,8 @@ module SiSU_CGI_SQLite elsif @q =~/\S+/; unescaped_search=CGI.unescape(@q) end search_construct=[] - unescaped_search.gsub!(/\s*(AND|OR)\s*/,"%' \) \\1 #{@l} LIKE \( '%") - unescaped_search.gsub!(/(.+)/,"#{@l} LIKE \( '%\\1%' \)") + unescaped_search=unescaped_search.gsub(/\s*(AND|OR)\s*/,"%' \) \\1 #{@l} LIKE \( '%"). + gsub(/(.+)/,"#{@l} LIKE \( '%\\1%' \)") search_construct << unescaped_search search_construct=search_construct.join(' ') search[:search] << search_construct @@ -165,11 +165,11 @@ module SiSU_CGI_SQLite <<-'WOK_SQL' @search_text,@search_endnotes='','' search[:text].flatten.each {|x| @search_text << "#{x} AND " } - @search_text=@search_text.gsub!(/AND\s+$/m,'') - @search_text.gsub!(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') + @search_text=@search_text.gsub(/AND\s+$/m,''). + gsub(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.gsub!(/AND\s+$/m,'') - @search_endnotes.gsub!(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') + @search_endnotes=@search_endnotes.gsub(/AND\s+$/m,''). + gsub(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') end WOK_SQL end diff --git a/lib/sisu/v3dv/composite.rb b/lib/sisu/v3dv/composite.rb index abfba7a2..21adb030 100644 --- a/lib/sisu/v3dv/composite.rb +++ b/lib/sisu/v3dv/composite.rb @@ -161,11 +161,11 @@ module SiSU_Assemble end if not @code_flag \ and i !~/^%+\s/ - i.gsub!(/^([123]|:?[ABC])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + i=i.gsub(/^([123]|:?[ABC])~\? /,'% [conditional heading:] \1~ ') #off conditional heading (consider syntax) if i =~/^@\S+?:/ - i.gsub!(/\n/m,"\n% ") - i.gsub!(/\n%\s+$/m,'') - i.gsub!(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers + i=i.gsub(/\n/m,"\n% "). + gsub(/\n%\s+$/m,''). + gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers end end file[:prepared] << i @@ -176,8 +176,7 @@ module SiSU_Assemble end file[:prepared] << "\n% end import" << "\n\n" if file[:images].length > 0 - file[:images].flatten! - file[:images].uniq! + file[:images]=file[:images].flatten.uniq file[:images].delete_if {|x| x =~/https?:\/\// } end file @@ -218,15 +217,13 @@ module SiSU_Assemble end else tuned_file << para end - tuned_file.flatten! - tuned_file.compact! + tuned_file=tuned_file.flatten.compact end if @@imager.length >0 @@imager.each do |d,i| - i.flatten! - i.uniq! + i=i.flatten.uniq image_info=d + i - download_images(mage_info.flatten) + download_images(image_info.flatten) end end tuned_file diff --git a/lib/sisu/v3dv/concordance.rb b/lib/sisu/v3dv/concordance.rb index 2e14ab14..e51514c3 100644 --- a/lib/sisu/v3dv/concordance.rb +++ b/lib/sisu/v3dv/concordance.rb @@ -245,54 +245,55 @@ WOK ocn=line.ocn.to_s if ocn =~/\d+/ \ and ocn !~/^0$/ - line.obj.gsub!(/#{@rxp_excluded1}/,' ') + line.obj=line.obj.gsub(/#{@rxp_excluded1}/,' ') line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match for word in line.obj.scan(@rgx_scanlist) #%take in word or other match if word =~ /^([#{@alphlst[:l]}])/ firstletter=$1 flu=firstletter.tr(@alphlst[:l],@alphlst[:u]) - word.gsub!(/^#{firstletter}/,flu ) + word=word.gsub(/^#{firstletter}/,flu ) end - word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,'') - word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'') - word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') - word.gsub!(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'') - word.gsub!(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') - word.gsub!(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/ - word.gsub!(/#{Mx[:br_line]}/,' ') - word.gsub!(/^ +/,'') - word.gsub!(/^\S$/,'') + word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,''). + gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') + word=word.gsub(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/ + word=word.gsub(/#{Mx[:br_line]}/,' '). + gsub(/^ +/,''). + gsub(/^\S$/,'') word=nil if word.empty? word=nil if word =~@rxp_excluded0 #watch word=nil if word =~/^\S$/ if word - word.gsub!(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' ') - word.gsub!(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,'') - word.gsub!(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,'') - word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''); word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') - word.gsub!(/<\/?\S+?>/,'') - word.gsub!(/^\@+/,'') - word.strip! - word.gsub!(/#{Mx[:tc_p]}.+/,'') - word.gsub!(/[\.,;:"]$/,'') - word.gsub!(/["]/,'') - word.gsub!(/^\s*[\(]/,'') - word.gsub!(/[\(]\s*$/,'') - word.gsub!(/^(?:See|e\.?g\.?).+/,'') - word.gsub!(/^\s*[.,;:]\s*/,'') - word.strip! - word.gsub!(/^\(?[a-zA-Z]\)$/,'') - word.gsub!(/^\d+(st|nd|rd|th)$/,'') - word.gsub!(/^(\d+\.?)+$/, '') - word.gsub!(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') - word.gsub!(/:name#\S+/,'') - word.gsub!(/^\S$/,'') + word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' '). + gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/<\/?\S+?>/,''). + gsub(/^\@+/,''). + strip. + gsub(/#{Mx[:tc_p]}.+/,''). + gsub(/[\.,;:"]$/,''). + gsub(/["]/,''). + gsub(/^\s*[\(]/,''). + gsub(/[\(]\s*$/,''). + gsub(/^(?:See|e\.?g\.?).+/,''). + gsub(/^\s*[.,;:]\s*/,''). + strip. + gsub(/^\(?[a-zA-Z]\)$/,''). + gsub(/^\d+(st|nd|rd|th)$/,''). + gsub(/^(\d+\.?)+$/, ''). + gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,''). + gsub(/:name#\S+/,''). + gsub(/^\S$/,'') word=nil if word =~/^\S$/ word=nil if word =~/^\s*$/ #watch if word unless word =~/[A-Z][A-Z]/ \ or word =~/\w+\s\w+/ - word.capitalize! + word=word.capitalize end @freq[word] +=1 @word_map[word] ||= [] @@ -316,8 +317,8 @@ WOK scr='Full Text scroll: doc#  ' seg='' head=SiSU_Concordance::Source::DocTitle.new(@particulars).create - head.gsub!(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2) - head.gsub!(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) + head=head.gsub(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2). + gsub(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) @file_concordance << head @file_concordance << '

' alph=@alph[:u] diff --git a/lib/sisu/v3dv/dal_character_check.rb b/lib/sisu/v3dv/dal_character_check.rb index 2857cb98..4ec95f82 100644 --- a/lib/sisu/v3dv/dal_character_check.rb +++ b/lib/sisu/v3dv/dal_character_check.rb @@ -69,25 +69,26 @@ module SiSU_DAL_CharacterCheck endnote_no=1 data.each do |dob| unless dob.is =='table' - dob.obj.strip! - dob.obj.gsub!(/^[{~}]\s*$/,'') - dob.obj.gsub!(/~#\s*/,"#{Mx[:pa_non_object_no_heading]}") - dob.obj.gsub!(/-#\s*/,"#{Mx[:pa_non_object_dummy_heading]}") - dob.obj.gsub!(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '); dob.obj.gsub!(/(~\{\s*)\s+/,'\1 ') - dob.obj.gsub!(/ \/\//,"#{Mx[:br_line]}") - dob.obj.gsub!(/
/,"#{Mx[:br_line]}") #needed by xml, xhtml etc. - dob.obj.gsub!(/\t/,' ') - dob.obj.gsub!(/\342\200\231/u,"'") #if dob =~/’/ #Avoid #‘ ’ #“ ” - dob.obj.gsub!(/�/u,' ') #watch, replace with char code - dob.obj.gsub!(/·/u,'*') - dob.obj.gsub!(/\\copy(?:right)?\b/,'©') - dob.obj.gsub!(/\\trademark\b|\\tm\b/,'®') + dob.obj=dob.obj.strip. + gsub(/^[{~}]\s*$/,''). + gsub(/~#\s*/,"#{Mx[:pa_non_object_no_heading]}"). + gsub(/-#\s*/,"#{Mx[:pa_non_object_dummy_heading]}"). + gsub(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '). + gsub(/(~\{\s*)\s+/,'\1 '). + gsub(/ \/\//,"#{Mx[:br_line]}"). + gsub(/
/,"#{Mx[:br_line]}"). #needed by xml, xhtml etc. + gsub(/\t/,' '). + gsub(/\342\200\231/u,"'"). #if dob =~/’/ #Avoid #‘ ’ #“ ” + gsub(/�/u,' '). #watch, replace with char code + gsub(/·/u,'*'). + gsub(/\\copy(?:right)?\b/,'©'). + gsub(/\\trademark\b|\\tm\b/,'®') dob.obj=dob.obj + "\n" unless dob.is =~/^code/ case dob.obj when /\^~/ #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ sub_dob=dob.obj.dup - @endnote_array << sub_dob.gsub!(/\n/,'').gsub!(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip + @endnote_array << sub_dob.gsub(/\n/,'').gsub(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip endnote_no+=1 dob=nil if dob.obj =~/\^~ .+/ #watch, removes 'binary' endnote now in endnote array for later insertion end diff --git a/lib/sisu/v3dv/dal_doc_str.rb b/lib/sisu/v3dv/dal_doc_str.rb index dbf4f066..91fa9458 100644 --- a/lib/sisu/v3dv/dal_doc_str.rb +++ b/lib/sisu/v3dv/dal_doc_str.rb @@ -131,11 +131,11 @@ module SiSU_DAL_DocumentStructureExtract if str.nil? else if str =~/(?:^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/ - str.gsub!(/(^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/i, - "\\1#{Mx[:tag_o]}\\2#{Mx[:tag_c]}") - str.gsub!(/ [ ]+/i,' ') + str=str.gsub(/(^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/i, + "\\1#{Mx[:tag_o]}\\2#{Mx[:tag_c]}"). + gsub(/ [ ]+/i,' ') tags=str.scan(/#{Mx[:tag_o]}(\S+?)#{Mx[:tag_c]}/).flatten - str.gsub!(/[ ]?#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}[ ]?/,' ') #may be issues with spaces would leave one, but "code" blocks? + str=str.gsub(/[ ]?#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}[ ]?/,' ') #may be issues with spaces would leave one, but "code" blocks? end tags=nametag ? (tags << nametag) : tags end @@ -148,7 +148,7 @@ module SiSU_DAL_DocumentStructureExtract @@counter,@verse_count=0,0 @metadata={} @data.each do |t_o| - t_o.gsub!(/(?:\n\s*\n)+/m,"\n") unless @@flag['code'] + t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") unless @@flag['code'] if t_o !~/^(?:code|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ and not @@flag['code'] \ and not @@flag['poem'] \ @@ -158,7 +158,7 @@ module SiSU_DAL_DocumentStructureExtract and not @@flag['table'] unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any idx=if t_o=~/^=\{(.+)\}\s*$\Z/m; m=$1 - t_o.gsub!(/\n=\{.+\}\s*$\Z/m,'') + t_o=t_o.gsub(/\n=\{.+\}\s*$\Z/m,'') m else nil end @@ -304,7 +304,7 @@ module SiSU_DAL_DocumentStructureExtract cols=nil rws.each do |r| cols=(cols ? cols : (r.scan('|').length) +1) - r.gsub!(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end col=[] @@ -337,7 +337,7 @@ module SiSU_DAL_DocumentStructureExtract rws=tbl.split(/\n/) rows='' rws.each do |r| - r.gsub!(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") rows += r + Mx[:tc_c] end h={ head_: hd, cols: col.length, widths: col, obj: rows, idx: idx, tags: tags } @@ -366,8 +366,8 @@ module SiSU_DAL_DocumentStructureExtract else if t_o !~/^table\{/ \ and not t_o.nil? - t_o.gsub!(/^\n+/m,'') #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2) - t_o.gsub!(/\n+/m,"#{Mx[:tc_p]}") + t_o=t_o.gsub(/^\n+/m,''). #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2) + gsub(/\n+/m,"#{Mx[:tc_p]}") @rows += t_o + Mx[:tc_c] end t_o=nil @@ -447,7 +447,7 @@ module SiSU_DAL_DocumentStructureExtract t_o=SiSU_DAL_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join poem=t_o.split(/\n\n/) poem.each do |v| - v.gsub!(/\n/m,"#{Mx[:br_nl]}\n") + v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") obj,tags=extract_tags(v) h={ obj: obj, tags: tags } t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.verse(h) @@ -463,17 +463,17 @@ module SiSU_DAL_DocumentStructureExtract or @@flag['group'] \ or @@flag['alt'] if t_o.class==String - t_o.gsub!(/\n/m,"#{Mx[:br_nl]}") - t_o.gsub!(/[ ][ ]/m,"#{Mx[:nbsp]*2}") - t_o.gsub!(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") + t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}"). + gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). + gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") t_o=t_o + Mx[:br_nl] if t_o =~/\S+/ elsif t_o.is=='group' \ or t_o.is=='block' \ or t_o.is=='alt' \ or t_o.is=='verse' - t_o.obj.gsub!(/\n/m,"#{Mx[:br_nl]}") - t_o.obj.gsub!(/[ ][ ]/m,"#{Mx[:nbsp]*2}") - t_o.obj.gsub!(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") + t_o.obj=t_o.obj.gsub(/\n/m,"#{Mx[:br_nl]}"). + gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). + gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") end @tuned_block << t_o if t_o =~/\S+/ else tuned_file << t_o @@ -742,26 +742,26 @@ module SiSU_DAL_DocumentStructureExtract meta end def build_lines(type='') - data=@data - data.each do |line| - if line =~/\S/ \ + lines,lines_new=@data,[] + lines.each do |line| + line=if line =~/\S/ \ and line !~/^code\{|^\}code/ \ and line.class != Hash - line.gsub!(/\s\s/,"#{Mx[:nbsp]*2}") - line.gsub!(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") - line.gsub!(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type=='code' # REMOVE try sort for texpdf special case - if line =~/(?:https?|file|ftp):\/\/\S+$/ - line.gsub!(/\s*$/," #{Mx[:br_nl]}") - else line.gsub!(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' - end - if @@flag['code']; @@counter+=1 - else + @@counter+=1 if @@flag['code'] + line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}"). + gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") + line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type=='code' # REMOVE try sort for texpdf special case + line=if line =~/(?:https?|file|ftp):\/\/\S+$/ + line.gsub(/\s*$/," #{Mx[:br_nl]}") + else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' end elsif line =~/^\s*$/ - line.gsub!(/\s*$/,"#{Mx[:br_nl]}") + line.gsub(/\s*$/,"#{Mx[:br_nl]}") + else line end + lines_new << line end - data + lines_new end end class Structure # this must happen early @@ -805,26 +805,26 @@ module SiSU_DAL_DocumentStructureExtract end def structure_markup_normalize #needs a bit of thinking dob=if @md.markup_version.determined < 0.38 #%convert internal representation, consider making 0.38 structure default ([A-C1-6] instead of [1-9]), requires downstream changes - @dob.gsub!(/^[456]~/,'!_') - @dob.gsub!(/^3~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^3~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}") - @dob.gsub!(/^2~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^2~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}") - @dob.gsub!(/^1~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^1~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}") - @dob.gsub!(/^:?C~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^:?C~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}") - @dob.gsub!(/^:?B~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^:?B~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}") - @dob.gsub!(/^:?A~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}") - @dob.gsub!(/^:?A~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}") + @dob=@dob.gsub(/^[456]~/,'!_'). + gsub(/^3~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}"). + gsub(/^3~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}"). + gsub(/^2~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}"). + gsub(/^2~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}"). + gsub(/^1~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}"). + gsub(/^1~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}"). + gsub(/^:?C~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}"). + gsub(/^:?C~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}"). + gsub(/^:?B~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}"). + gsub(/^:?B~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}"). + gsub(/^:?A~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}"). + gsub(/^:?A~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}") @dob=if @dob =~/^@(?:level|markup):\s/ - @dob.gsub!(/3/,'6') - @dob.gsub!(/2/,'5') - @dob.gsub!(/1/,'4') - @dob.gsub!(/:?C/,'3') - @dob.gsub!(/:?B/,'2') - @dob.gsub!(/:?A/,'1') + @dob=@dob.gsub(/3/,'6'). + gsub(/2/,'5'). + gsub(/1/,'4'). + gsub(/:?C/,'3'). + gsub(/:?B/,'2'). + gsub(/:?A/,'1') @dob else @dob end @@ -833,19 +833,19 @@ module SiSU_DAL_DocumentStructureExtract end def structure_marks t_o=if @md.markup_version.determined < 0.38 - @t_o.gsub!(/^1~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^1~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}") - @t_o.gsub!(/^2~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^2~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}") - @t_o.gsub!(/^3~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^3~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}") - @t_o.gsub!(/^4~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^4~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}") - @t_o.gsub!(/^5~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^5~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}") - @t_o.gsub!(/^6~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}") - @t_o.gsub!(/^6~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}") - @t_o.gsub!(/^[789]~/,'!_') + @t_o=@t_o.gsub(/^1~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}"). + gsub(/^1~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}"). + gsub(/^2~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}"). + gsub(/^2~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}"). + gsub(/^3~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}"). + gsub(/^3~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}"). + gsub(/^4~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}"). + gsub(/^4~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}"). + gsub(/^5~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}"). + gsub(/^5~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}"). + gsub(/^6~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}"). + gsub(/^6~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}"). + gsub(/^[789]~/,'!_') @t_o else @t_o end @@ -945,13 +945,13 @@ module SiSU_DAL_DocumentStructureExtract end end else ocnu+=1 - dob.obj.gsub!(/#{Mx[:fa_o]}~##{Mx[:fa_c]}/,'') if dob.obj + dob.obj=dob.obj.gsub(/#{Mx[:fa_o]}~##{Mx[:fa_c]}/,'') if dob.obj ocn_dv,ocn_sp="u#{ocnu}","u#{ocnu}" dob.ocn,dob.odv,dob.osp=ocn,ocn_dv,ocn_sp end h elsif dob.obj=~/#{Mx[:pa_non_object_no_heading]}/ - dob.obj.gsub!(/#{Mx[:pa_non_object_no_heading]}/,'') + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') if dob.is=='para' h={ obj: dob.obj, ocn_: false, ocn: nil } dob=SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h,dob) @@ -960,7 +960,7 @@ module SiSU_DAL_DocumentStructureExtract dob=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,dob) end elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ - dob.obj.gsub!(/#{Mx[:pa_non_object_dummy_heading]}/,'') + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') if dob.is=='para' h={ obj: dob.obj, ocn_: false, ocn: nil } dob=SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h,dob) @@ -970,7 +970,7 @@ module SiSU_DAL_DocumentStructureExtract end else dob end - dob.obj.gsub!(/\n\n/,"\n") if dob.is =~/(?:code|verse|alt|group|block)/ #newlines taken out + dob.obj=dob.obj.gsub(/\n\n/,"\n") if dob.is =~/(?:code|verse|alt|group|block)/ #newlines taken out @o_array << dob end @o_array @@ -1060,8 +1060,7 @@ module SiSU_DAL_DocumentStructureExtract end puts_tag_close(0,hs) if @md.opt.cmd =~/V/ tuned_file << tag_close(0,hs) - tuned_file.flatten! - tuned_file + tuned_file=tuned_file.flatten end def tags(o) tag=if o[:status]=='open' diff --git a/lib/sisu/v3dv/dal_endnotes.rb b/lib/sisu/v3dv/dal_endnotes.rb index bb327f39..eb5e3429 100644 --- a/lib/sisu/v3dv/dal_endnotes.rb +++ b/lib/sisu/v3dv/dal_endnotes.rb @@ -69,17 +69,17 @@ module SiSU_DAL_Endnotes data.each do |dob| # manually numbered endnotes --> if @md.opt.mod.inspect =~/--no-asterisk|--no-annotate/ - dob.obj.gsub!(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') + dob.obj=dob.obj.gsub(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') end if @md.opt.mod.inspect =~/--no-dagger|--no-annotate/ - dob.obj.gsub!(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') + dob.obj=dob.obj.gsub(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') end if defined? dob.obj \ and defined? dob.is \ and dob.is !~/^code/ case dob.obj # auto-numbered endnotes --> when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ - dob.obj.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1') # required 2003w31 + dob.obj=dob.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1') # required 2003w31 word_mode=dob.obj.scan(/\S+/m) word_mode=endnote_call_number(word_mode) dob.obj=word_mode.join(' ') diff --git a/lib/sisu/v3dv/dal_expand_insertions.rb b/lib/sisu/v3dv/dal_expand_insertions.rb index f821769e..8ec52065 100644 --- a/lib/sisu/v3dv/dal_expand_insertions.rb +++ b/lib/sisu/v3dv/dal_expand_insertions.rb @@ -274,7 +274,7 @@ module SiSU_DAL_Insertions pre=txt=cmd=source=linked_doc=note='' if defined? @u.remote if /(?

.+?)\{(?.+?)\s\[(?\d[sS]*)\]\}(?(?\S+?)\.ss[tm]\b)(?.*)/m =~ para
-              pre.strip!
+              pre=pre.strip
             elsif /\{(?.+?)\s\[(?\d[sS]*)\]\}(?(?\S+?)\.ss[tm]\b)(?.*)/m =~ para
             end
             if linked_doc =~ /(\S+?)\/(\S+)/ 
diff --git a/lib/sisu/v3dv/dal_hash_digest.rb b/lib/sisu/v3dv/dal_hash_digest.rb
index 8353b5a0..40f81197 100644
--- a/lib/sisu/v3dv/dal_hash_digest.rb
+++ b/lib/sisu/v3dv/dal_hash_digest.rb
@@ -68,14 +68,13 @@ module SiSU_DAL_Hash
     # 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph)
     # 3. whole object, text with markup and any endnotes, (question: with or without the endnote digests??? presumption better without, [however may be easier to check with?])
     # [digests should not include other digests]
-      data=@data
+      data=@data.compact
       @tuned_file=[]
-      data.compact!
       sha_ =(@env.digest.type=='sha256' ? true : false)
       sha_ ? (require 'digest/sha2') : (require 'digest/md5')
       data.each do |t_o|
         unless t_o.obj.class==Array
-          t_o.obj.strip!
+          t_o.obj=t_o.obj.strip
         end
         if t_o.of !~/structure|comment|layout/ \
         and t_o.ocn.class==Fixnum
@@ -125,7 +124,7 @@ module SiSU_DAL_Hash
         case t_o.obj
         when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m
           en_and_t_o,en_and_t_o_digest=[],[]
-          t_o.obj.gsub!(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch
+          t_o.obj=t_o.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch
           t_o_plus_en=t_o.obj.scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m)
           t_o_tail=if t_o.obj =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m
             /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+.*/m.match(t_o.obj)[1]
@@ -144,11 +143,11 @@ module SiSU_DAL_Hash
     def strip_clean_extra_spaces(s)                                            # dal output tuned
       s=s.dup
       s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/
-      s=s.gsub(/ [ ]+/,' ')
-      s=s.gsub(/^ [ ]+/,'')
-      s=s.gsub(/ [ ]+$/,'')
-      s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2')
-      s=s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2')
+      s=s.gsub(/ [ ]+/,' ').
+        gsub(/^ [ ]+/,'').
+        gsub(/ [ ]+$/,'').
+        gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2').
+        gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2')
     end
   end
 end
diff --git a/lib/sisu/v3dv/dal_idx.rb b/lib/sisu/v3dv/dal_idx.rb
index 8ba2f2b5..5f4a38e0 100644
--- a/lib/sisu/v3dv/dal_idx.rb
+++ b/lib/sisu/v3dv/dal_idx.rb
@@ -101,21 +101,20 @@ module SiSU_DAL_BookIndex
           g=idx_list.scan(/[^;]+/)
           idxl=[]
           g.each do |i|
-            i.strip!
+            i=i.strip
             idxl << { rough_idx: i, ocn: ocn, seg: seg }
           end
           idxl
         else { rough_idx: idx_list, ocn: ocn, seg: seg }
         end
       end
-      idx_lst.flatten!
-      idx_lst
+      idx_lst=idx_lst.flatten
     end
     def construct_book_index(idx_array)
       the_idx={}
       idx_array.each do |idx|
         idx_lst=idx[:rough_idx].scan(/[^|:]+/)
-        idx_lst[0].strip!
+        idx_lst[0]=idx_lst[0].strip
         if idx_lst[0] =~/.+?\+\d+/
           use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2]
         else use=idx_lst[0]
@@ -123,7 +122,7 @@ module SiSU_DAL_BookIndex
         use=use[0].chr.capitalize + use[1,use.length]
         the_idx[use]={} unless the_idx[use] and defined? the_idx[use]
         idx_lst.each do |i|
-          i.strip!
+          i=i.strip
           i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/
           x=if idx_lst.length==1 or idx_lst[0].gsub(/\+\d+/,'')==i
             the_idx[use]['term_node_lev1']=[] unless the_idx[use]['term_node_lev1'] and defined? the_idx[use]['term_node_lev1']
@@ -151,12 +150,12 @@ module SiSU_DAL_BookIndex
       the_idx
     end
     def clean_xml(str)
-      str.gsub!(/&/,'&')
-      str.gsub!(/\(/,'(')
-      str.gsub!(/\)/,')')
-      str.gsub!(/\*/,'*')
-      str.gsub!(/\+/,'+')
-      str.gsub!(/,/,',')
+      str=str.gsub(/&/,'&').
+        gsub(/\(/,'(').
+        gsub(/\)/,')').
+        gsub(/\*/,'*').
+        gsub(/\+/,'+').
+        gsub(/,/,',')
       str
     end
     def index(the_idx)
@@ -347,7 +346,7 @@ module SiSU_DAL_BookIndex
     def clean_index(data)                                  #check on use of dob
       tuned_file=[]
       data.each do |para|
-        para.gsub!(/\n*#{@rgx_idx}/m,'')
+        para=para.gsub(/\n*#{@rgx_idx}/m,'')
         tuned_file << para
       end
       tuned_file
diff --git a/lib/sisu/v3dv/dal_images.rb b/lib/sisu/v3dv/dal_images.rb
index fd058c72..0f65b814 100644
--- a/lib/sisu/v3dv/dal_images.rb
+++ b/lib/sisu/v3dv/dal_images.rb
@@ -81,7 +81,7 @@ module SiSU_DAL_Images
       end
       data.each do |dob|
         unless dob.is =~/^table/
-          dob.obj.strip!
+          dob.obj=dob.obj.strip
           if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
             if dob.obj !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+/
               m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/
@@ -133,8 +133,8 @@ module SiSU_DAL_Images
                         img_col=((1.00*img_row/row)*col).round
                       end
                     end
-                    dob.obj.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}")
-                  else dob.obj.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,'[ \1 (\2 missing) ]')
+                    dob.obj=dob.obj.gsub(/(#{image})/,"#{image} #{img_col}x#{img_row}")
+                  else dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,'[ \1 (\2 missing) ]')
                   end
                 end
               else
@@ -144,7 +144,9 @@ module SiSU_DAL_Images
               end
             end
           end
-          dob.obj.gsub!(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
+          if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
+            dob.obj=dob.obj.gsub(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ')
+          end
         end
         tuned_file << dob unless dob.nil?
       end
diff --git a/lib/sisu/v3dv/dal_numbering.rb b/lib/sisu/v3dv/dal_numbering.rb
index cf7d861a..332db4bf 100644
--- a/lib/sisu/v3dv/dal_numbering.rb
+++ b/lib/sisu/v3dv/dal_numbering.rb
@@ -77,12 +77,13 @@ module SiSU_DAL_Numbering
     def number_plaintext_para(data)
       @tuned_file=[]
       data.each do |dob|
-        if dob.of !~/(?:block|comment|layout)/ and dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX
-          dob.obj.gsub!(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks
+        if dob.of !~/(?:block|comment|layout)/ \
+        and dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX
+          dob.obj=dob.obj.gsub(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks
         end
         unless dob.obj.class==Array
-          dob.obj.gsub!(/^\s+/,'')
-          dob.obj.gsub!(/\s$/,"\n")
+          dob.obj=dob.obj.gsub(/^\s+/,'').
+            gsub(/\s$/,"\n")
         end
         @tuned_file << dob
       end
@@ -90,37 +91,35 @@ module SiSU_DAL_Numbering
     end
     def number_sub_heading(dob,num,title_no)
       unless dob.obj =~/\d+\.|(?:chapter|article|section|clause)\s+\d+/i #name selection arbitrary, fix
-        case dob.name
-        when /-/;  dob.obj.gsub!(/^/,"#{title_no} ")
-        when /^#/; dob.obj.gsub!(/^/,"#{title_no} ")
-        when /^[a-z_\.]+/
-          dob.obj.gsub!(/^/,"#{title_no} ")
+        dob.obj=case dob.name
+        when /-/;  dob.obj.gsub(/^/,"#{title_no} ")
+        when /^#/; dob.obj.gsub(/^/,"#{title_no} ")
+        when /^[a-z_\.]+/; dob.obj.gsub(/^/,"#{title_no} ")
         else
           dob.name=title_no if dob.name=~/^$/ #where title contains title number
-          dob.obj.gsub!(/^/,"#{title_no} ") if title_no =~/\d+/ #main, where title number is to be provided #watch changed placement
+          dob.obj.gsub(/^/,"#{title_no} ") if title_no =~/\d+/ #main, where title number is to be provided #watch changed placement
         end
         if @md.toc_lev_limit \
         and @md.toc_lev_limit < num
-          dob.obj.gsub!(/^/,'!_ ') #bold line, watch
+          dob.obj=dob.obj.gsub(/^/,'!_ ') #bold line, watch
         end
       end
       dob
     end
     def heading_tag_clean(heading_tag)
-      heading_tag.gsub!(/[ ]+/,'_')
-      heading_tag.gsub!(/["']/,'')
-      heading_tag.gsub!(/[\/]/,'-')
-      heading_tag.gsub!(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,'')
-      heading_tag.gsub!(/#{Mx[:fa_italics_o]}|#{Mx[:fa_italics_c]}/,'')
-      heading_tag.gsub!(/#{Mx[:fa_underscore_o]}|#{Mx[:fa_underscore_c]}/,'')
-      heading_tag.gsub!(/#{Mx[:fa_cite_o]}|#{Mx[:fa_cite_c]}/,'')
-      heading_tag.gsub!(/#{Mx[:fa_insert_o]}|#{Mx[:fa_insert_c]}/,'')
-      heading_tag.gsub!(/#{Mx[:fa_strike_o]}|#{Mx[:fa_strike_c]}/,'')
-      heading_tag.gsub!(/#{Mx[:fa_superscript_o]}|#{Mx[:fa_superscript_c]}/,'')
-      heading_tag.gsub!(/#{Mx[:fa_subscript_o]}|#{Mx[:fa_subscript_c]}/,'')
-      heading_tag.gsub!(/#{Mx[:fa_hilite_o]}|#{Mx[:fa_hilite_c]}/,'')
-      heading_tag.gsub!(/#{Mx[:gl_bullet]}/,'')
-      heading_tag
+      heading_tag=heading_tag.gsub(/[ ]+/,'_').
+        gsub(/["']/,'').
+        gsub(/[\/]/,'-').
+        gsub(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,'').
+        gsub(/#{Mx[:fa_italics_o]}|#{Mx[:fa_italics_c]}/,'').
+        gsub(/#{Mx[:fa_underscore_o]}|#{Mx[:fa_underscore_c]}/,'').
+        gsub(/#{Mx[:fa_cite_o]}|#{Mx[:fa_cite_c]}/,'').
+        gsub(/#{Mx[:fa_insert_o]}|#{Mx[:fa_insert_c]}/,'').
+        gsub(/#{Mx[:fa_strike_o]}|#{Mx[:fa_strike_c]}/,'').
+        gsub(/#{Mx[:fa_superscript_o]}|#{Mx[:fa_superscript_c]}/,'').
+        gsub(/#{Mx[:fa_subscript_o]}|#{Mx[:fa_subscript_c]}/,'').
+        gsub(/#{Mx[:fa_hilite_o]}|#{Mx[:fa_hilite_c]}/,'').
+        gsub(/#{Mx[:gl_bullet]}/,'')
     end
     def auto_number_heading_ie_title(data)                                             #also does some segment naming
       @tuned_file=[]
@@ -135,8 +134,8 @@ module SiSU_DAL_Numbering
         no1=num_top; no2=(num_top + 1); no3=(num_top + 2);  no4=(num_top + 3)
       end
       t_not=0
-      data.compact!
       chapter_number_counter=0
+      data=data.compact
       data.each do |dob| #@md.seg_names << [additions to segment names]
         title_no=nil
         dob=SiSU_DAL_DocumentStructureExtract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require
@@ -147,8 +146,8 @@ module SiSU_DAL_Numbering
           if  dob.lv=='1' \
           and dob.obj =~/^#\s|\s#(?:\s|$)/
             chapter_number_counter +=1
-            dob.obj.gsub!(/^#\s/,"#{chapter_number_counter} ")
-            dob.obj.gsub!(/#([:,]?\s|[.]?$)/,"#{chapter_number_counter}\\1")
+            dob.obj=dob.obj.gsub(/^#\s/,"#{chapter_number_counter} ").
+              gsub(/#([:,]?\s|[.]?$)/,"#{chapter_number_counter}\\1")
           end
           if dob.ln==no1
             @subnumber=1
@@ -168,15 +167,15 @@ module SiSU_DAL_Numbering
                   tag=dob.obj.gsub(/(Article|Clause|Section|Chapter)\s+/,"\\1_#{title_no}").downcase
                   tag=heading_tag_clean(tag)
                   dob.tags=[tag,dob.tags].flatten if tag !~/^\d+$/ #check whether will work across file types with stop signs
-                  (dob.obj =~/(Article|Clause|Section)\s+/) \
-                  ? (dob.obj.gsub!(/(Article|Clause|Section)\s+/,"\\1 #{title_no} "))
-                  : (dob.obj.gsub!(/^/,"#{title_no}. ")) #fix stop later
+                  dob.obj=(dob.obj =~/(Article|Clause|Section)\s+/) \
+                  ? (dob.obj.gsub(/(Article|Clause|Section)\s+/,"\\1 #{title_no} "))
+                  : (dob.obj.gsub(/^/,"#{title_no}. ")) #fix stop later
                 end
                 if dob.ln !=no1 \
                 and dob.obj =~/^[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review
                   dob.name ="#{title_no}" if not dob.name
                   dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs
-                  dob.obj.gsub!(/^/,"#{title_no}. ")
+                  dob.obj=dob.obj.gsub(/^/,"#{title_no}. ")
                 end
                 @md.seg_names << title_no
               end
@@ -184,7 +183,7 @@ module SiSU_DAL_Numbering
               and dob.name!~/^[a-z_\.]+$/ \
               and dob.obj !~/[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required # not fixed, work on
                 dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs
-                dob.obj.gsub!(/^/i,"#{title_no}. ")
+                dob.obj=dob.obj.gsub(/^/i,"#{title_no}. ")
               end
             end
             if dob.ln==no1         #watch because here you change dob.name
@@ -251,10 +250,10 @@ module SiSU_DAL_Numbering
               letter_small=0
               number_small=0 if dob.obj =~ /^#1/
               number_small+=1
-              dob.obj.gsub!(/^#[ 1]/,"#{number_small}. ") #change 2004
+              dob.obj=dob.obj.gsub(/^#[ 1]/,"#{number_small}. ")
             end
             if dob.obj =~/^_# /
-              dob.obj.gsub!(/^_# /,"#{letter[letter_small]}. ") #change 2004
+              dob.obj=dob.obj.gsub(/^_# /,"#{letter[letter_small]}. ")
               dob.indent='1'
               letter_small+=1
             end
@@ -298,8 +297,8 @@ module SiSU_DAL_Numbering
           if dob.name !~/^\S+/ \
           and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m      #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name
             possible_seg_name=$1
-            possible_seg_name.gsub!(/(?:[:,-]|\W)/,'.')
-            possible_seg_name.gsub!(/\.$/,'')
+            possible_seg_name=possible_seg_name.gsub(/(?:[:,-]|\W)/,'.').
+              gsub(/\.$/,'')
             if not @md.seg_names.nil? \
             and not @md.seg_names.include?(possible_seg_name)
               dob.name=possible_seg_name
diff --git a/lib/sisu/v3dv/dal_substitutions_and_insertions.rb b/lib/sisu/v3dv/dal_substitutions_and_insertions.rb
index b81a91e2..2ae365be 100644
--- a/lib/sisu/v3dv/dal_substitutions_and_insertions.rb
+++ b/lib/sisu/v3dv/dal_substitutions_and_insertions.rb
@@ -66,12 +66,12 @@ module SiSU_DAL_SubstituteAndInsert
       data=@data
       data_expand=[]
       if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it)
-        data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'')
-        data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'')
+        data[0]=data[0].gsub(/^#!\s*\/usr\/bin\/sisu/,'').
+          gsub(/^#!\s*\/usr\/bin\/env sisu/,'')
       end
       if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier
-        data[0].gsub!(/^(SiSU\s*[\d.]*)$/,'% \1')
-        data[0].gsub!(/^(sisu-[\d.]+)$/,'% \1')
+        data[0]=data[0].gsub(/^(SiSU\s*[\d.]*)$/,'% \1').
+          gsub(/^(sisu-[\d.]+)$/,'% \1')
       end
       data.each do |para|
         if para =~/<:(insert\d+)!?>/ \
@@ -132,22 +132,24 @@ module SiSU_DAL_SubstituteAndInsert
           para.each {|x| data_expand << x }
         else data_expand << para
         end
-        data_expand.flatten!
-        data_expand.compact!
+        data_expand=data_expand.flatten.compact
       end
+      data_new=[]
       data_expand.each do |para|
         para=if @md.markup_version.determined >= 0.38
           SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure_markup_normalize
         else
           SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure_marks
         end
-        para.gsub!(/^(:?A~)\s*$/,'\1~ @title @author')                                    #conditional header
-        para.gsub!(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#')    #conditional header for incorporated document 2004w12
+        para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author').                                    #conditional header
+          gsub(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#')    #conditional header for incorporated document 2004w12
         if para =~/^@\S+?:/
-          para.gsub!(/^@(\S+?):(\s+|$)/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2")
-          para.gsub!(/^@(\S+?):([+-])(\s+|$)/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3")
+          para=para.gsub(/^@(\S+?):(\s+|$)/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2").
+            gsub(/^@(\S+?):([+-])(\s+|$)/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3")
         end
+        data_new << para
       end
+      data_new
     end
   end
 end
diff --git a/lib/sisu/v3dv/dal_syntax.rb b/lib/sisu/v3dv/dal_syntax.rb
index 6d923467..a8ece51e 100644
--- a/lib/sisu/v3dv/dal_syntax.rb
+++ b/lib/sisu/v3dv/dal_syntax.rb
@@ -120,7 +120,7 @@ module SiSU_DAL_Syntax
       end
     end
     def songsheet
-      @data.compact!
+      @data=@data.compact
       @data.each do |dob|
         dob=breaks(dob)
         dob=if @md.sem_tag then sem(dob) else dob end #revisit
@@ -136,8 +136,8 @@ module SiSU_DAL_Syntax
     end
     def breaks(dob)
       if dob.is !~/^(?:meta|comment|code|table)/
-        dob.obj.gsub!(/ \\\\(?: |$)/,"#{Mx[:br_line]}")
-        dob.obj.gsub!(/(?:<:?br>|
)/,"#{Mx[:br_line]}") # depreciated + dob.obj=dob.obj.gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}"). + gsub(/(?:<:?br>|
)/,"#{Mx[:br_line]}") # depreciated end dob end @@ -149,18 +149,17 @@ module SiSU_DAL_Syntax and @vz.markup_make_italic[:str]) dob.obj=if dob.is !~/^(?:meta|heading|code|comment)/ word=dob.obj.scan(@line_scan_ital) - word.flatten! - word.compact! #reinstated + word=word.flatten.compact line_array=[] word.each do |w| unless /#{@manmkp_ital}|#{@http_m}/.match(w) if defined? @md.make.italics[:regx] \ and @md.make.italics[:regx] - w.gsub!(@md.make.italics[:regx], + w=w.gsub(@md.make.italics[:regx], "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") elsif defined? @vz.markup_make_italic \ and @vz.markup_make_italic - w.gsub!(@vz.markup_make_italic, + w=w.gsub(@vz.markup_make_italic, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") else w end @@ -174,28 +173,28 @@ module SiSU_DAL_Syntax dob end def embolden(given) - given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, - "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2") - given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, - "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}") - given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") - given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") - given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s*([~-]#)$/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") - given.gsub!(/(?:^!_\s+|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]}\s*)(.*)?\s*$/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + given=given.gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2"). + gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, + "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}"). + gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). + gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). + gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s*([~-]#)$/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). + gsub(/(?:^!_\s+|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]}\s*)(.*)?\s*$/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end def italicise(given) - given.gsub!(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") - given.gsub!(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") - given.gsub!(/^\/_\s*(.+?)\s*([~-]#)$/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") - given.gsub!(/^\/_\s+(.*)?\s*$/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") + given=given.gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). + gsub(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). + gsub(/^\/_\s*(.+?)\s*([~-]#)$/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). + gsub(/^\/_\s+(.*)?\s*$/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") end def wordlist_bold(dob) dob=dob.dup @@ -206,19 +205,18 @@ module SiSU_DAL_Syntax dob.obj=if dob.is !~/^(?:meta|heading|code|comment|table)/ line_array=[] word=dob.obj.scan(@line_scan_bold) - word.flatten! - word.compact! + word=word.flatten.compact word.each do |w| unless /#{@manmkp_bold}|#{@http_m}/.match(w) if defined? @md.make.bold[:regx] \ and @md.make.bold[:regx] #document header: @bold: [bold word list] - w.gsub!(@md.make.bold[:regx],"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + w=w.gsub(@md.make.bold[:regx],"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") elsif defined? @vz.markup_make_bold \ and @vz.markup_make_bold #defaults and skin adjusted bold word list - w.gsub!(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + w=w.gsub(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end else - if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + w=if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! elsif w =~/^\/_\s+/; italicise(w) else w end @@ -229,42 +227,43 @@ module SiSU_DAL_Syntax else dob.obj end else - if dob.is !~/^(?:heading|comment|meta)/ \ + dob.obj=if dob.is !~/^(?:heading|comment|meta)/ \ and dob.obj =~ /^!_\s+/ embolden(dob.obj) elsif dob.is=='heading' \ and dob.ln.to_s =~/[7-9]/ embolden(dob.obj) + else dob.obj end if dob.obj =~ /\/_\s+/ - italicise(dob.obj) + dob.obj=italicise(dob.obj) end end dob end def fontface(dob) - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)\*\{(.+?)\}\*/m, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)!\{(.+?)\}!/m, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\(|\>)\/\{(.+?)\}\//m, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)_\{(.+?)\}_/m, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)#\{(.+?)\}#/m, - "\\1#{Mx[:fa_monospace_o]}\\2#{Mx[:fa_monospace_c]}") #monospace - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/m, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? - dob.obj.gsub!(/(^|[^\\])\^\{(.+?)\}\^/m, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript - dob.obj.gsub!(/(^|[^\\]),\{(.+?)\},/m, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") #subscript - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/m, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") #inserted text - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/m, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #strikethrough - deleted text - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added + dob.obj=dob.obj.gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)\*\{(.+?)\}\*/m, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)!\{(.+?)\}!/m, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\(|\>)\/\{(.+?)\}\//m, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)_\{(.+?)\}_/m, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)#\{(.+?)\}#/m, + "\\1#{Mx[:fa_monospace_o]}\\2#{Mx[:fa_monospace_c]}"). #monospace + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/m, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). #cite /blockquote? + gsub(/(^|[^\\])\^\{(.+?)\}\^/m, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). #superscript + gsub(/(^|[^\\]),\{(.+?)\},/m, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). #subscript + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/m, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). #inserted text + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/m, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). #strikethrough - deleted text + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added dob end def bodymarkup(dob) @@ -304,26 +303,25 @@ module SiSU_DAL_Syntax if word word.each do |w| # _ - / # | : ! ^ ~ unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!! - w.gsub!(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character + w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character end - w.gsub!(/^\<$/,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}") #escaped special character - w.gsub!(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character + w=w.gsub(/^\<$/,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character line_array << w end dob.obj=line_array.join(' ') dob.obj=dob.obj.strip end - dob.obj.gsub!(/^([*#-.]{1,12})$/,'\1 ~#') #ocn off for these paragraph separators - dob.obj.gsub!(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]) - dob.obj.gsub!(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]) #default if markup does not specify - dob.obj.gsub!(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) + dob.obj=dob.obj.gsub(/^([*#-.]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators + gsub(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]). + gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify + gsub(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) if dob.is =='heading' \ and dob.ln ==1 - dob.obj.gsub!(/\s*@title\b/," #{@md.title.full}") - if defined? @md.creator.author \ + dob.obj=dob.obj.gsub(/\s*@title\b/," #{@md.title.full}") + dob.obj=if defined? @md.creator.author \ and @md.creator.author - dob.obj.gsub!(/\s+(?:@creator|@author)/,",#{Mx[:br_line]}#{@md.creator.author}") - else dob.obj.gsub!(/\s+(?:@creator|@author)/,'') + dob.obj.gsub(/\s+(?:@creator|@author)/,",#{Mx[:br_line]}#{@md.creator.author}") + else dob.obj.gsub(/\s+(?:@creator|@author)/,'') end end if defined? @md.title \ @@ -332,113 +330,113 @@ module SiSU_DAL_Syntax and defined? @md.creator \ and @md.creator if dob.is =='heading' - dob.obj.gsub!(/^\s*@title\s*$/,@md.title.full) if dob.lv =~/1/ - if dob.lv =~/[23]/ \ + dob.obj=dob.obj.gsub(/^\s*@title\s*$/,@md.title.full) if dob.lv =~/1/ + dob.obj=if dob.lv =~/[23]/ \ and defined? @md.creator.author \ and @md.creator.author - dob.obj.gsub!(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.creator.author}") - else dob.obj.gsub!(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1') + dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.creator.author}") + else dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1') end end end - dob.obj.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup - dob.obj.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') - dob.obj.gsub!(//,'<:\1>') #escaped special character - dob.obj.gsub!(/ /,"#{Mx[:nbsp]}") #escaped special character - dob.obj.gsub!(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\{/,"#{Mx[:gl_o]}#123#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\}/,"#{Mx[:gl_o]}#125#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\<>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\_/,"#{Mx[:gl_o]}#095#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\-/,"#{Mx[:gl_o]}#045#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\+/,"#{Mx[:gl_o]}#043#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\//,"#{Mx[:gl_o]}#047#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\#/,"#{Mx[:gl_o]}#035#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\&/,"#{Mx[:gl_o]}#038#{Mx[:gl_c]}") #& #escaped special character - dob.obj.gsub!(/\\\|/,"#{Mx[:gl_o]}#124#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\:/,"#{Mx[:gl_o]}#058#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\^/,"#{Mx[:gl_o]}#094#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\,/,"#{Mx[:gl_o]}#044#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility - dob.obj.gsub!(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character + dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup + gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image'). + gsub(//,'<:\1>'). #escaped special character + gsub(/ /,"#{Mx[:nbsp]}"). #escaped special character + gsub(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\{/,"#{Mx[:gl_o]}#123#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\}/,"#{Mx[:gl_o]}#125#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\<>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}#{Mx[:gl_o]}#gt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\_/,"#{Mx[:gl_o]}#095#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\-/,"#{Mx[:gl_o]}#045#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\+/,"#{Mx[:gl_o]}#043#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\//,"#{Mx[:gl_o]}#047#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\#/,"#{Mx[:gl_o]}#035#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\&/,"#{Mx[:gl_o]}#038#{Mx[:gl_c]}"). #& #escaped special character + gsub(/\\\|/,"#{Mx[:gl_o]}#124#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\:/,"#{Mx[:gl_o]}#058#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\^/,"#{Mx[:gl_o]}#094#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\,/,"#{Mx[:gl_o]}#044#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, + dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch end if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") end - dob.obj.gsub!(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3") #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) - dob.obj.gsub!(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}\\1#{Mx[:rel_c]}\\2}) - dob.obj.gsub!(/#{Mx[:lnk_c]}:(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) - dob.obj.gsub!(/#{Mx[:lnk_c]}[.]{2}\/(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) + dob.obj=dob.obj.gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) + gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}). + gsub(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}\\1#{Mx[:rel_c]}\\2}). + gsub(/#{Mx[:lnk_c]}:(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}). + gsub(/#{Mx[:lnk_c]}[.]{2}\/(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) end if dob.obj=~/_(?:https?|ftp):\S+/m # _http://url #CHECK - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])(_(?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])(_(?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) end dob=fontface(dob) - dob.obj.gsub!(/<[:e]\s+(.+?)!?>/, - "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}") #not tested - dob.obj.gsub!(/^\s*_\*\s*/, - "#{Mx[:gl_bullet]}") #bullets, shortcut - dob.obj.gsub!(/=\{(.+?)\}/, - "#{Mx[:idx_o]}\\1#{Mx[:idx_c]}") - dob.obj.gsub!(/^\s*_([1-9])\*\s*/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}") #bullets, shortcut - dob.obj.gsub!(/^\s*_([1-9])\s+/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}") #indent - dob.obj.gsub!(/^\s*_([1-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} ") #indent bold - dob.obj.gsub!(/^\s*__([1-9])\s+/, - "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}") #hang - dob.obj.gsub!(/^\s*__([1-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} ") #hangdef - dob.obj.gsub!(/^\s*_([0-9])_([0-9])\s+/, - "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}") #hang - dob.obj.gsub!(/^\s*_([0-9])_([0-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\3#{Mx[:fa_bold_c]} ") #hangdef - dob.obj.gsub!(/<:hi>/,"#{Mx[:fa_hilite_o]}") #'') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) - dob.obj.gsub!(/<:\/hi>/,"#{Mx[:fa_hilite_c]}") #'') - dob.obj.gsub!(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n") - dob.obj.gsub!(/[ ]+($)/,'\1') - dob.obj.gsub!(/\{\s*(.+?)\s*\}(https?:\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3") #any remaining linked text or image - dob.obj.gsub!(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image - dob.obj.gsub!(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}") - dob.obj.gsub!(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4") #any remaining linked text or image - dob.obj.gsub!(/\{\s*(.+?)\s*\}#([a-zA-Z0-9][a-zA-Z0-9_-]*)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3") #any remaining linked text or image, check need - dob.obj.gsub!(/\{\s*(.+?)\s*\}(#{Mx[:rel_o]}\S+?#{Mx[:rel_c]})/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image, check need - dob.obj.gsub!(/\{\s*(.+?)\s*\}(image)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image + dob.obj=dob.obj.gsub(/<[:e]\s+(.+?)!?>/, + "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}"). #not tested + gsub(/^\s*_\*\s*/, + "#{Mx[:gl_bullet]}"). #bullets, shortcut + gsub(/=\{(.+?)\}/, + "#{Mx[:idx_o]}\\1#{Mx[:idx_c]}"). + gsub(/^\s*_([1-9])\*\s*/, + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}"). #bullets, shortcut + gsub(/^\s*_([1-9])\s+/, + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}"). #indent + gsub(/^\s*_([1-9])!\s+(.+?)\s*$/, + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #indent bold + gsub(/^\s*__([1-9])\s+/, + "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}"). #hang + gsub(/^\s*__([1-9])!\s+(.+?)\s*$/, + "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #hangdef + gsub(/^\s*_([0-9])_([0-9])\s+/, + "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}"). #hang + gsub(/^\s*_([0-9])_([0-9])!\s+(.+?)\s*$/, + "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\3#{Mx[:fa_bold_c]} "). #hangdef + gsub(/<:hi>/,"#{Mx[:fa_hilite_o]}"). #'') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) + gsub(/<:\/hi>/,"#{Mx[:fa_hilite_c]}"). #'') + gsub(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n"). + gsub(/[ ]+($)/,'\1'). + gsub(/\{\s*(.+?)\s*\}(https?:\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3"). #any remaining linked text or image + gsub(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image + gsub(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}"). + gsub(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4"). #any remaining linked text or image + gsub(/\{\s*(.+?)\s*\}#([a-zA-Z0-9][a-zA-Z0-9_-]*)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3"). #any remaining linked text or image, check need + gsub(/\{\s*(.+?)\s*\}(#{Mx[:rel_o]}\S+?#{Mx[:rel_c]})/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image, check need + gsub(/\{\s*(.+?)\s*\}(image)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image elsif dob.is=='table' dob=fontface(dob) elsif dob.is =='code' - dob.obj.gsub!(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: ') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert

back, clumsy + dob.obj=dob.obj.gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: '). + gsub(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert

back, clumsy if dob.number_ codeline=[] ln=1 dob.obj.split(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}||\n/).each_with_index do |cl,i| unless i == 0 - cl.gsub!(Mx[:br_nl],'') + cl=cl.gsub(Mx[:br_nl],'') w=3-ln.to_s.length cl = "#{ln}#{Mx[:nbsp]*w}#{Mx[:vline]}#{cl}#{Mx[:br_nl]}" ln +=1 @@ -448,7 +446,7 @@ module SiSU_DAL_Syntax codeline= codeline.join("") dob.obj=codeline else - dob.obj.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n") + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n") end dob else # @\S+?: @@ -474,62 +472,62 @@ module SiSU_DAL_Syntax # +2 puts 'tech' @data.each do |line| - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)u\{(.+?)\}u/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)c\{(.+?)\}c/, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)i\{(.+?)\}i/, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)!\{(.+?)\}!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)_\{(.+?)\}_/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^\{(.+?)\}\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)9\{(.+?)\}9/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>),\{(.+?)\},/, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasise single word, watch - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3") #italics single word, watch - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore single word, watch - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^(\S+?)\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #check #superscript single word, watch digit added - line.gsub!(/^\s*_\([1-9]\)\(\*\+\)\s*/, - "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}") #bullets, shortcut - line.gsub!(/^\s*_\([1-9]\)\s+/, - "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}") #watch - line.gsub!(/^\s*__\([1-9]\)\s+/, - "#{Mx[:pa_o]}:h\\1#{Mx[:pa_c]}") #watch - #line.gsub!(/^\s*__\([1-9]\)!\s+/, - # "#{Mx[:pa_o]}:hd\\1#{Mx[:pa_c]}") #watch - line.gsub!(/#{Mx[:br_line]}\s*_[12]\s+/, - "#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') + line=line.gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)u\{(.+?)\}u/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)c\{(.+?)\}c/, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). #cite + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)i\{(.+?)\}i/, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)!\{(.+?)\}!/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)_\{(.+?)\}_/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^\{(.+?)\}\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)9\{(.+?)\}9/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>),\{(.+?)\},/, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasise single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3"). #italics single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^(\S+?)\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). #check #superscript single word, watch digit added + gsub(/^\s*_\([1-9]\)\(\*\+\)\s*/, + "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}"). #bullets, shortcut + gsub(/^\s*_\([1-9]\)\s+/, + "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}"). #watch + gsub(/^\s*__\([1-9]\)\s+/, + "#{Mx[:pa_o]}:h\\1#{Mx[:pa_c]}"). #watch + #line.gsub(/^\s*__\([1-9]\)!\s+/, + # "#{Mx[:pa_o]}:hd\\1#{Mx[:pa_c]}"). #watch + gsub(/#{Mx[:br_line]}\s*_[12]\s+/, + "#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') end @data end diff --git a/lib/sisu/v3dv/db_columns.rb b/lib/sisu/v3dv/db_columns.rb index 89d4c7e3..cf4ba9c7 100644 --- a/lib/sisu/v3dv/db_columns.rb +++ b/lib/sisu/v3dv/db_columns.rb @@ -109,7 +109,7 @@ module SiSU_DbColumns t=if defined? @md.title.full \ and @md.title.full=~/\S+/ txt=@md.title.full - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -131,7 +131,7 @@ module SiSU_DbColumns t=if defined? @md.title.main \ and @md.title.main=~/\S+/ txt=@md.title.main - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -153,7 +153,7 @@ module SiSU_DbColumns t=if defined? @md.title.sub \ and @md.title.sub=~/\S+/ txt=@md.title.sub - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -175,7 +175,7 @@ module SiSU_DbColumns t=if defined? @md.title.short \ and @md.title.short=~/\S+/ txt=@md.title.short - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -197,7 +197,7 @@ module SiSU_DbColumns t=if defined? @md.title.edition \ and @md.title.edition=~/\S+/ txt=@md.title.edition - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -219,7 +219,7 @@ module SiSU_DbColumns t=if defined? @md.title.note \ and @md.title.note=~/\S+/ txt=@md.title.note - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -240,7 +240,7 @@ module SiSU_DbColumns def tuple t=if @lang.list[@md.opt.lng][:n] txt=@lang.list[@md.opt.lng][:n] - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -262,7 +262,7 @@ module SiSU_DbColumns t=if defined? @md.opt.lng \ and @md.opt.lng=~/\S+/ txt=@md.opt.lng - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -302,8 +302,8 @@ module SiSU_DbColumns @md.creator.author_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -325,7 +325,7 @@ module SiSU_DbColumns t=if defined? @md.creator.author_hon \ and @md.creator.author_hon=~/\S+/ txt=@md.creator.author_hon - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -347,7 +347,7 @@ module SiSU_DbColumns t=if defined? @md.creator.author_nationality_detail \ and @md.creator.author_nationality=~/\S+/ txt=@md.creator.author_nationality_detail - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -374,8 +374,8 @@ module SiSU_DbColumns @md.creator.editor_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -402,8 +402,8 @@ module SiSU_DbColumns @md.creator.contributor_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -430,8 +430,8 @@ module SiSU_DbColumns @md.creator.illustrator_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -458,8 +458,8 @@ module SiSU_DbColumns @md.creator.photographer_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -485,8 +485,8 @@ module SiSU_DbColumns @md.creator.translator_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -513,8 +513,8 @@ module SiSU_DbColumns @md.creator.prepared_by_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -541,8 +541,8 @@ module SiSU_DbColumns @md.creator.digitized_by_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -569,8 +569,8 @@ module SiSU_DbColumns @md.creator.audio_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -596,8 +596,8 @@ module SiSU_DbColumns @md.creator.video_detail.each do |h| txt=txt + %{#{h[:the]}, #{h[:others]}; } end - txt.gsub!(/[;, ]+\s*$/,'') - special_character_escape(txt) + txt=txt.gsub(/[;, ]+\s*$/,'') + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -630,7 +630,7 @@ module SiSU_DbColumns def tuple t=if @lang.list[@md.opt.lng][:n] txt=@lang.list[@md.opt.lng][:n] - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -653,7 +653,7 @@ module SiSU_DbColumns t=if defined? @md.opt.lng \ and @md.opt.lng=~/\S+/ txt=@md.opt.lng - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -675,7 +675,7 @@ module SiSU_DbColumns t=if defined? @md.language.original \ and @md.language.original=~/\S+/ txt=@md.language.original - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -697,7 +697,7 @@ module SiSU_DbColumns t=if defined? @md.language.original_char \ and @md.language.original_char=~/\S+/ txt=@md.language.original_char - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -733,7 +733,7 @@ module SiSU_DbColumns t=if defined? @md.date.added_to_site \ and @md.date.added_to_site=~/\S+/ txt=@md.date.added_to_site - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -755,7 +755,7 @@ module SiSU_DbColumns t=if defined? @md.date.available \ and @md.date.available=~/\S+/ txt=@md.date.available - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -777,7 +777,7 @@ module SiSU_DbColumns t=if defined? @md.date.created \ and @md.date.created=~/\S+/ txt=@md.date.created - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -799,7 +799,7 @@ module SiSU_DbColumns t=if defined? @md.date.issued \ and @md.date.issued=~/\S+/ txt=@md.date.issued - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -821,7 +821,7 @@ module SiSU_DbColumns t=if defined? @md.date.modified \ and @md.date.modified=~/\S+/ txt=@md.date.modified - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -843,7 +843,7 @@ module SiSU_DbColumns t=if defined? @md.date.published \ and @md.date.published=~/\S+/ txt=@md.date.published - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -865,7 +865,7 @@ module SiSU_DbColumns t=if defined? @md.date.valid \ and @md.date.valid=~/\S+/ txt=@md.date.valid - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -887,7 +887,7 @@ module SiSU_DbColumns t=if defined? @md.date.translated \ and @md.date.translated=~/\S+/ txt=@md.date.translated - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -909,7 +909,7 @@ module SiSU_DbColumns t=if defined? @md.date.original_publication \ and @md.date.original_publication=~/\S+/ txt=@md.date.original_publication - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -932,7 +932,7 @@ module SiSU_DbColumns t=if defined? @md.generated \ and @md.generated.to_s=~/\S+/ txt=@md.generated.to_s - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -958,7 +958,7 @@ module SiSU_DbColumns t=if defined? @md.publisher \ and @md.publisher=~/\S+/ txt=@md.publisher - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -980,7 +980,7 @@ module SiSU_DbColumns # t=if defined? @md.current.publisher \ # and @md.current.publisher=~/\S+/ # txt=@md.current.publisher -# special_character_escape(txt) +# txt=special_character_escape(txt) # "'#{txt}', " # end # end @@ -1011,7 +1011,7 @@ module SiSU_DbColumns t=if defined? @md.original.publisher \ and @md.original.publisher=~/\S+/ txt=@md.original.publisher - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1033,7 +1033,7 @@ module SiSU_DbColumns t=if defined? @md.original.language \ and @md.original.language=~/\S+/ txt=@md.original.language - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1055,7 +1055,7 @@ module SiSU_DbColumns t=if defined? @md.original.language_char \ and @md.original.language_char=~/\S+/ txt=@md.original.language_char - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1077,7 +1077,7 @@ module SiSU_DbColumns t=if defined? @md.original.source \ and @md.original.source=~/\S+/ txt=@md.original.source - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1099,7 +1099,7 @@ module SiSU_DbColumns t=if defined? @md.original.institution \ and @md.original.institution=~/\S+/ txt=@md.original.institution - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1121,7 +1121,7 @@ module SiSU_DbColumns t=if defined? @md.original.nationality \ and @md.original.nationality=~/\S+/ txt=@md.original.nationality - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1158,7 +1158,7 @@ module SiSU_DbColumns t=if defined? @md.rights.all \ and @md.rights.all=~/\S+/ txt=@md.rights.all - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1180,7 +1180,7 @@ module SiSU_DbColumns t=if defined? @md.rights.copyright_text \ and @md.rights.copyright_text=~/\S+/ txt=@md.rights.copyright_text - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1202,7 +1202,7 @@ module SiSU_DbColumns t=if defined? @md.rights.copyright_translation \ and @md.rights.copyright_translation=~/\S+/ txt=@md.rights.copyright_translation - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1224,7 +1224,7 @@ module SiSU_DbColumns t=if defined? @md.rights.copyright_illustrations \ and @md.rights.copyright_illustrations=~/\S+/ txt=@md.rights.copyright_illustrations - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1246,7 +1246,7 @@ module SiSU_DbColumns t=if defined? @md.rights.copyright_photographs \ and @md.rights.copyright_photographs=~/\S+/ txt=@md.rights.copyright_photographs - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1268,7 +1268,7 @@ module SiSU_DbColumns t=if defined? @md.rights.copyright_preparation \ and @md.rights.copyright_preparation=~/\S+/ txt=@md.rights.copyright_preparation - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1290,7 +1290,7 @@ module SiSU_DbColumns t=if defined? @md.rights.copyright_digitization \ and @md.rights.copyright_digitization=~/\S+/ txt=@md.rights.copyright_digitization - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1312,7 +1312,7 @@ module SiSU_DbColumns t=if defined? @md.rights.copyright_audio \ and @md.rights.copyright_audio=~/\S+/ txt=@md.rights.copyright_audio - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1334,7 +1334,7 @@ module SiSU_DbColumns t=if defined? @md.rights.copyright_video \ and @md.rights.copyright_video=~/\S+/ txt=@md.rights.copyright_video - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1356,7 +1356,7 @@ module SiSU_DbColumns t=if defined? @md.rights.license \ and @md.rights.license=~/\S+/ txt=@md.rights.license - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1394,7 +1394,7 @@ module SiSU_DbColumns t=if defined? @md.classify.topic_register \ and @md.classify.topic_register=~/\S+/ txt=@md.classify.topic_register - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1416,7 +1416,7 @@ module SiSU_DbColumns t=if defined? @md.classify.subject \ and @md.classify.subject=~/\S+/ txt=@md.classify.subject - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1438,7 +1438,7 @@ module SiSU_DbColumns t=if defined? @md.classify.type \ and @md.classify.type=~/\S+/ txt=@md.classify.type - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1460,7 +1460,7 @@ module SiSU_DbColumns t=if defined? @md.classify.loc \ and @md.classify.loc=~/\S+/ txt=@md.classify.loc - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1482,7 +1482,7 @@ module SiSU_DbColumns t=if defined? @md.classify.dewey \ and @md.classify.dewey=~/\S+/ txt=@md.classify.dewey - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1504,7 +1504,7 @@ module SiSU_DbColumns t=if defined? @md.classify.oclc \ and @md.classify.oclc=~/\S+/ txt=@md.classify.oclc - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1526,7 +1526,7 @@ module SiSU_DbColumns t=if defined? @md.classify.pg \ and @md.classify.pg=~/\S+/ txt=@md.classify.pg - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1548,7 +1548,7 @@ module SiSU_DbColumns t=if defined? @md.classify.isbn \ and @md.classify.isbn=~/\S+/ txt=@md.classify.isbn - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1570,7 +1570,7 @@ module SiSU_DbColumns t=if defined? @md.classify.format \ and @md.classify.format=~/\S+/ txt=@md.classify.format - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1592,7 +1592,7 @@ module SiSU_DbColumns t=if defined? @md.classify.identifier \ and @md.classify.identifier=~/\S+/ txt=@md.classify.identifier - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1614,7 +1614,7 @@ module SiSU_DbColumns t=if defined? @md.classify.relation \ and @md.classify.relation=~/\S+/ txt=@md.classify.relation - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1636,7 +1636,7 @@ module SiSU_DbColumns t=if defined? @md.classify.coverage \ and @md.classify.coverage=~/\S+/ txt=@md.classify.coverage - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1658,7 +1658,7 @@ module SiSU_DbColumns t=if defined? @md.classify.keywords \ and @md.classify.keywords=~/\S+/ txt=@md.classify.keywords - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1692,7 +1692,7 @@ module SiSU_DbColumns t=if defined? @md.notes.abstract \ and @md.notes.abstract=~/\S+/ txt=@md.notes.abstract - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1714,7 +1714,7 @@ module SiSU_DbColumns t=if defined? @md.notes.comment \ and @md.notes.comment=~/\S+/ txt=@md.notes.comment - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1736,7 +1736,7 @@ module SiSU_DbColumns t=if defined? @md.notes.description \ and @md.notes.description=~/\S+/ txt=@md.notes.description - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1758,7 +1758,7 @@ module SiSU_DbColumns t=if defined? @md.notes.history \ and @md.notes.history=~/\S+/ txt=@md.notes.history - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1780,7 +1780,7 @@ module SiSU_DbColumns t=if defined? @md.notes.prefix \ and @md.notes.prefix=~/\S+/ txt=@md.notes.prefix - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1802,7 +1802,7 @@ module SiSU_DbColumns t=if defined? @md.notes.prefix_a \ and @md.notes.prefix_a=~/\S+/ txt=@md.notes.prefix_a - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1824,7 +1824,7 @@ module SiSU_DbColumns t=if defined? @md.notes.prefix_b \ and @md.notes.prefix_b=~/\S+/ txt=@md.notes.prefix_b - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1846,7 +1846,7 @@ module SiSU_DbColumns t=if defined? @md.notes.suffix \ and @md.notes.suffix=~/\S+/ txt=@md.notes.suffix - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1871,7 +1871,7 @@ module SiSU_DbColumns t=if defined? @md.fns \ and @md.fns=~/\S+/ txt=@md.fns - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1916,7 +1916,7 @@ module SiSU_DbColumns t=if defined? @md.filesize \ and @md.filesize=~/\S+/ txt=@md.filesize - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -1938,7 +1938,7 @@ module SiSU_DbColumns t=if defined? @md.wc_words \ and @md.wc_words=~/\S+/ txt=@md.wc_words - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -2006,7 +2006,7 @@ module SiSU_DbColumns t=if defined? @md.skin_name \ and @md.skin_name=~/\S+/ txt=@md.skin_name - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -2029,7 +2029,7 @@ module SiSU_DbColumns and @md.dgst_skin.class==Array \ and @md.dgst_skin[1]=~/\S+/ txt=@md.dgst_skin[1] - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -2051,7 +2051,7 @@ module SiSU_DbColumns t=if defined? @md.skin \ and @md.skin=~/\S+/ txt=@md.skin - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end @@ -2074,7 +2074,7 @@ module SiSU_DbColumns t=if defined? @md.links \ and @md.links=~/\S+/ txt=@md.links - special_character_escape(txt) + txt=special_character_escape(txt) ["#{name}, ","'#{txt}', "] else ['',''] end diff --git a/lib/sisu/v3dv/db_import.rb b/lib/sisu/v3dv/db_import.rb index adbe5af5..a2b66937 100644 --- a/lib/sisu/v3dv/db_import.rb +++ b/lib/sisu/v3dv/db_import.rb @@ -212,7 +212,7 @@ module SiSU_DbImport src=special_character_escape(src) @tp[:sisutxt_f],@tp[:sisutxt_i]='sisutxt, ',"'#{src}', " txt=clean_searchable_text(txt_arr) - #special_character_escape(txt) + #txt=special_character_escape(txt) @tp[:fulltxt_f],@tp[:fulltxt_i]='fulltxt, ',"'#{txt}', " end #% title @@ -268,7 +268,7 @@ module SiSU_DbImport @col[:lid]+=1 txt=endnotes(txt).extract_any @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_minus - special_character_escape(@col[:body]) + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) @@ -302,7 +302,7 @@ module SiSU_DbImport @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - special_character_escape(@col[:body]) + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) @@ -329,7 +329,7 @@ module SiSU_DbImport @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - special_character_escape(@col[:body]) + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) @@ -356,7 +356,7 @@ module SiSU_DbImport @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - special_character_escape(@col[:body]) + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) @@ -406,7 +406,7 @@ module SiSU_DbImport else SiSU_FormatShared::CSS_Format.new(@md,data).norm end - special_character_escape(@col[:body]) + @col[:body]=special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) @@ -424,9 +424,9 @@ module SiSU_DbImport nr,txt,digest_clean=$1,$2.strip,0 end @id_n+=1 - special_character_escape(txt) + txt=special_character_escape(txt) body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) - strip_markup(txt) + txt=strip_markup(txt) if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| @@ -463,9 +463,9 @@ module SiSU_DbImport nr,txt,digest_clean=$1,$2.strip,0 end @id_n+=1 - special_character_escape(txt) + txt=special_character_escape(txt) body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) - strip_markup(txt) + txt=strip_markup(txt) if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| @@ -502,9 +502,9 @@ module SiSU_DbImport nr,txt,digest_clean=$1,$2.strip,0 end @id_n+=1 - special_character_escape(txt) + txt=special_character_escape(txt) body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) - strip_markup(txt) + txt=strip_markup(txt) if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| @@ -568,14 +568,14 @@ module SiSU_DbImport : nil end def clean_text(base_url=nil) - if base_url - @txt.gsub!(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,%{\\1}) - @txt.gsub!(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,%{\\1}) - @txt.gsub!(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,%{\\1}) + @txt=if base_url + @txt.gsub(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,%{\\1}). + gsub(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,%{\\1}). + gsub(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,%{\\1}) else - @txt.gsub!(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,'\1') - @txt.gsub!(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,'\1') - @txt.gsub!(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,'\1') + @txt.gsub(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,'\1'). + gsub(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,'\1'). + gsub(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,'\1') end @txt end diff --git a/lib/sisu/v3dv/db_sqltxt.rb b/lib/sisu/v3dv/db_sqltxt.rb index 49dcf10a..e65a8521 100644 --- a/lib/sisu/v3dv/db_sqltxt.rb +++ b/lib/sisu/v3dv/db_sqltxt.rb @@ -59,46 +59,45 @@ module SiSU_DbText class Prepare def special_character_escape(str) - str.gsub!(/'/,"''") #string.gsub!(/'/,"\047") #string.gsub!(/'/,"\\'") - str.gsub!(/(\\)/m,'\1\1') #ok but with warnings, double backslash on sqlite #str.gsub!(/[\\]/m,'\\x5C') #ok but with warnings, but not for sqlite #str.gsub!(/(\\)/m,'\1') #ok for sqlite not for pgsql - str.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"
\n") - str.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check - str.gsub!(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)#{Mx[:lnk_c]}\S+/,'[image: \1] \2') - str.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}(?:file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2') - str.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'\1') - str + str=str.gsub(/'/,"''"). #string.gsub!(/'/,"\047") #string.gsub!(/'/,"\\'") + gsub(/(\\)/m,'\1\1'). #ok but with warnings, double backslash on sqlite #str.gsub!(/[\\]/m,'\\x5C') #ok but with warnings, but not for sqlite #str.gsub!(/(\\)/m,'\1') #ok for sqlite not for pgsql + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"
\n"). + gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,''). #check + gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)#{Mx[:lnk_c]}\S+/,'[image: \1] \2'). + gsub(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}(?:file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2'). + gsub(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'\1') end def clean_searchable_text(arr) #produce clean, searchable, plaintext from document source txt_arr,en=[],[] arr=arr.class==String ? arr.split(/\n+/m) : arr arr.each do |s| - s.gsub!(/([*\/_-])\{(.+?)\}\1/m,'\2') - s.gsub!(/^(?:block|group|poem|code)\{/m,''); s.gsub!(/^\}(?:block|group|poem|code)/m,'') - s.gsub!(/\A(?:@\S+:\s+.+)\Z/m,'') + s=s.gsub(/([*\/_-])\{(.+?)\}\1/m,'\2'). + gsub(/^(?:block|group|poem|code)\{/m,'').gsub(/^\}(?:block|group|poem|code)/m,''). + gsub(/\A(?:@\S+:\s+.+)\Z/m,'') if s =~/^:A~/ if defined? @md.creator \ and defined? @md.creator.author \ and not @md.creator.author.empty? - s.gsub!(/@author/,@md.creator.author) + s=s.gsub(/@author/,@md.creator.author) else SiSU_Screen::Ansi.new('v','WARNING Document Author information missing; provide @creator: :author:',@md.fnb).warn unless @md.opt.cmd.inspect =~/q/ end if defined? @md.title \ and defined? @md.title.full \ and not @md.title.full.empty? - s.gsub!(/@title/,@md.title.full) + s=s.gsub(/@title/,@md.title.full) else SiSU_Screen::Ansi.new('v','WARNING Document Title missing; provide @title:',@md.fnb).warn unless @md.opt.cmd.inspect =~/q/ end end - s.gsub!(/^(?:_[1-9]\*?|_\*)\s+/m,'') - s.gsub!(/^(?:[1-9]\~(\S+)?)\s+/m,'') - s.gsub!(/^(?::?[A-C]\~(\S+)?)\s+/m,'') - s.gsub!(/^%{1,3} .+/m,'') #removed even if contained in code block - s.gsub!(/
/m,' ') + s=s.gsub(/^(?:_[1-9]\*?|_\*)\s+/m,''). + gsub(/^(?:[1-9]\~(\S+)?)\s+/m,''). + gsub(/^(?::?[A-C]\~(\S+)?)\s+/m,''). + gsub(/^%{1,3} .+/m,''). #removed even if contained in code block + gsub(/
/m,' ') en << s.scan(/~\{\s*(.+?)\s*\}~/m) - s.gsub!(/~\{.+?\}~/m,'') - s.gsub!(/ \s+/m,' ') + s=s.gsub(/~\{.+?\}~/m,''). + gsub(/ \s+/m,' ') #special_character_escape(s) s end @@ -109,17 +108,16 @@ module SiSU_DbText txt end def strip_markup(str) #define rules, make same as in dal clean - str.gsub!(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]') - str.gsub!(/(?: \\;|#{Mx[:nbsp]})+/,' ') - str.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}\d+(.+)#{Mx[:tc_c]}/u,'\1') #tables - str.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}\d+#{Mx[:tc_p]}/u,' ') #tables - str.gsub!(/#{Mx[:tc_p]}/u,' ') #tables tidy later - str.gsub!(/<.+?>/,'') - str.gsub!(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:file|ftp)\/\/:\S+ /,' [image] ') # else image names found in search - str.gsub!(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [image]') # else image names found in search - str.gsub!(/\s\s+/,' ') - str.strip! - str + str=str.gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]'). + gsub(/(?: \\;|#{Mx[:nbsp]})+/,' '). + gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}\d+(.+)#{Mx[:tc_c]}/u,'\1'). #tables + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}\d+#{Mx[:tc_p]}/u,' '). #tables + gsub(/#{Mx[:tc_p]}/u,' '). #tables tidy later + gsub(/<.+?>/,''). + gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:file|ftp)\/\/:\S+ /,' [image] '). # else image names found in search + gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [image]'). # else image names found in search + gsub(/\s\s+/,' '). + strip end def unique_words(str) a=str.scan(/[a-zA-Z0-9\\\/_-]{2,}/) #a=str.scan(/\S+{2,}/) diff --git a/lib/sisu/v3dv/defaults.rb b/lib/sisu/v3dv/defaults.rb index 55aeef21..1c9dd94f 100644 --- a/lib/sisu/v3dv/defaults.rb +++ b/lib/sisu/v3dv/defaults.rb @@ -735,8 +735,8 @@ module SiSU_Viz when /\/i$/; 'i' else '' end - r.gsub!(/^\/(.+?)\/i?/,'\1') - r.gsub!(/\(/,'(?:') # avoid need to escape use of brackets within regex provided + r=r.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\(/,'(?:') # avoid need to escape use of brackets within regex provided m='\b(' + r + ')\b' make[:str] make[:regx]=if x =~/i/; /#{m}/i @@ -756,8 +756,8 @@ module SiSU_Viz when /\/i$/; 'i' else '' end - r.gsub!(/^\/(.+?)\/i?/,'\1') - r.gsub!(/\(/,'(?:') # avoid need to escape use of brackets within regex provided + r.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\(/,'(?:') # avoid need to escape use of brackets within regex provided m='\b(' + r + ')\b' make[:str] make[:regx]=if x =~/i/; /#{m}/i diff --git a/lib/sisu/v3dv/digests.rb b/lib/sisu/v3dv/digests.rb index 5f5d90b3..91299d4c 100644 --- a/lib/sisu/v3dv/digests.rb +++ b/lib/sisu/v3dv/digests.rb @@ -153,9 +153,9 @@ module SiSU_DigestView if para =~/#{Mx[:id_o]}~(\d+);((?:\w|[0-6]:)\d+);(\w\d+)#{Mx[:id_c]}#{Mx[:id_o]}([0-9a-f]{#{@dl}}):([0-9a-f]{#{@dl}})#{Mx[:id_c]}/ ocn,h1,h2,d_clean,d_all=$1,$2,$3,$4,$5 @ocn=ocn unless ocn.to_i==0 - para.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') - para.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') - para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') + para=para.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') if para=~/#{Mx[:en_a_o]}[\d*+]+.+?#{Mx[:id_o]}[0-9a-f]{#{@dl}}#{Mx[:id_c]}#{Mx[:en_a_c]}/ para_endnotes << para.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+).+?#{Mx[:id_o]}([0-9a-f]{#{@dl}})#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) end diff --git a/lib/sisu/v3dv/epub.rb b/lib/sisu/v3dv/epub.rb index 259cdbe0..c87112cf 100644 --- a/lib/sisu/v3dv/epub.rb +++ b/lib/sisu/v3dv/epub.rb @@ -498,7 +498,7 @@ module SiSU_EPUB SiSU_Screen::Ansi.new(@md.opt.cmd,'Scroll & Segtoc').txt_grey if @md.opt.cmd =~/[MVv]/ format_head_toc=SiSU_EPUB_Format::HeadToc.new(@md) dochead=format_head_toc.head - dochead.gsub!(/toc\.(html)/,'doc.\1') #kludge + dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge toc_shared << dochead #<< ads.div.major segtoc << format_head_toc.head #<< ads.div.major if SiSU_EPUB_Format::HeadToc.method_defined? :toc_head_escript @@ -566,7 +566,7 @@ module SiSU_EPUB #Segtoc tail added here segtoc << seg_toc_band_bottom segtoc << format_head_toc.xhtml_close - segtoc.flatten!.compact! + segtoc=segtoc.flatten.compact #watch SiSU_EPUB::Source::Output.new(@md,segtoc).segtoc segtoc=[] @toc[:scr],@toc[:seg]=[],[] @@ -666,7 +666,7 @@ module SiSU_EPUB filename_html_segtoc=@make.epub.xhtml_segtoc filename_html_index=@make.epub.xhtml_index @output.each do |para| - para.strip! + para=para.strip unless para =~/\A\s*\Z/ filename_html_segtoc.puts para,"\n" filename_html_index.puts para,"\n" diff --git a/lib/sisu/v3dv/epub_concordance.rb b/lib/sisu/v3dv/epub_concordance.rb index 9c90d482..1106ec13 100644 --- a/lib/sisu/v3dv/epub_concordance.rb +++ b/lib/sisu/v3dv/epub_concordance.rb @@ -213,46 +213,46 @@ WOK and toy !~/^0$/ line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match for word in line.obj.scan(@rgx_scanlist) #%take in word or other match - word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,'') - word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'') - word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') - word.gsub!(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'') - word.gsub!(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') - word.gsub!(/^\S$/,'') + word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). + gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,''). + gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,''). + gsub(/^\S$/,'') word=nil if word.empty? word=nil if word =~@rxp_excluded0 #watch word=nil if word =~@rxp_excluded1 #watch word=nil if word =~/^\S$/ if word - word.gsub!(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' ') - word.gsub!(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,'') - word.gsub!(/#{Mx[:mk_o]}(?:[0-9a-f]{32}:[0-9a-f]{32}|[0-9a-f]{64}:[0-9a-f]{64})#{Mx[:mk_c]}/,'') - word.gsub!(/#{Mx[:mk_o]}(?:[0-9a-f]{32}|[0-9a-f]{64})#{Mx[:mk_c]}/,'') - word.gsub!(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,'') - word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''); word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') - word.gsub!(/<\/?\S+?>/,'') - word.gsub!(/^\@+/,'') - word.strip! - word.gsub!(/#{Mx[:tc_p]}.+/,'') - word.gsub!(/[\.,;:"]$/,'') - word.gsub!(/["]/,'') - word.gsub!(/^\s*[\(]/,'') - word.gsub!(/[\(]\s*$/,'') - word.gsub!(/^(?:See|e\.?g\.?).+/,'') - word.gsub!(/^\s*[.,;:]\s*/,'') - word.strip! - word.gsub!(/^\(?[a-zA-Z]\)$/,'') - word.gsub!(/^\d+(st|nd|rd|th)$/,'') - word.gsub!(/^(\d+\.?)+$/, '') - word.gsub!(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') - word.gsub!(/:name#\S+/,'') - word.gsub!(/^\S$/,'') + word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' '). + gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,''). + gsub(/#{Mx[:mk_o]}(?:[0-9a-f]{32}:[0-9a-f]{32}|[0-9a-f]{64}:[0-9a-f]{64})#{Mx[:mk_c]}/,''). + gsub(/#{Mx[:mk_o]}(?:[0-9a-f]{32}|[0-9a-f]{64})#{Mx[:mk_c]}/,''). + gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,''). + gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'').gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). + gsub(/<\/?\S+?>/,''). + gsub(/^\@+/,''). + strip. + gsub(/#{Mx[:tc_p]}.+/,''). + gsub(/[\.,;:"]$/,''). + gsub(/["]/,''). + gsub(/^\s*[\(]/,''). + gsub(/[\(]\s*$/,''). + gsub(/^(?:See|e\.?g\.?).+/,''). + gsub(/^\s*[.,;:]\s*/,''). + strip. + gsub(/^\(?[a-zA-Z]\)$/,''). + gsub(/^\d+(st|nd|rd|th)$/,''). + gsub(/^(\d+\.?)+$/, ''). + gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,''). + gsub(/:name#\S+/,''). + gsub(/^\S$/,'') word=nil if word =~/^\S$/ word=nil if word =~/^\s*$/ #watch if word unless word =~/[A-Z][A-Z]/ \ or word =~/\w+\s\w+/ - word.capitalize! + word=word.capitalize end @freq[word] +=1 @word_map[word] ||= [] diff --git a/lib/sisu/v3dv/epub_format.rb b/lib/sisu/v3dv/epub_format.rb index 3f7ea4d5..c1987fa0 100644 --- a/lib/sisu/v3dv/epub_format.rb +++ b/lib/sisu/v3dv/epub_format.rb @@ -1493,12 +1493,12 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(//,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(//,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.author.dup - x.gsub!(//,'>') - x.gsub!(/<br(?: \/)?>/,'
') + x=x.gsub(//,'>'). + gsub(/<br(?: \/)?>/,'
') %{\n #{x}} else '' end @@ -1515,12 +1515,12 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(//,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(//,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.editor.dup - x.gsub!(//,'>') - x.gsub!(/<br(?: \/)?>/,'
') + x=x.gsub(//,'>'). + gsub(/<br(?: \/)?>/,'
') %{\n #{x}} else '' end @@ -1537,12 +1537,12 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(//,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(//,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.translator.dup - x.gsub!(//,'>') - x.gsub!(/<br(?: \/)?>/,'
') + x=x.gsub(//,'>'). + gsub(/<br(?: \/)?>/,'
') %{\n #{x}} else '' end @@ -1559,28 +1559,28 @@ WOK m=(m.empty?) \ ? (surname + other_names) : (m + '; ' + surname + ', ' + other_names) - m.gsub!(//,'>') - m.gsub!(/<br(?: \/)?>/,';') + m=m.gsub(//,'>'). + gsub(/<br(?: \/)?>/,';') end x=@md.creator.illustrator.dup - x.gsub!(//,'>') - x.gsub!(/<br(?: \/)?>/,'
') + x=x.gsub(//,'>'). + gsub(/<br(?: \/)?>/,'
') %{\n #{x}} else '' end date_published=if defined? @md.date.published \ and @md.date.published =~/\S+/ x=@md.date.published.dup - x.gsub!(//,'>') - x.gsub!(/<br(?: \/)?>/,'
') + x=x.gsub(//,'>'). + gsub(/<br(?: \/)?>/,'
') %{\n #{x}} else '' end subject=if defined? @md.classify.subject \ and @md.classify.subject =~/\S+/ x=@md.classify.subject.dup - x.gsub!(//,'>') - x.gsub!(/<br(?: \/)?>/,'
') + x=x.gsub(//,'>'). + gsub(/<br(?: \/)?>/,'
') %{\n #{x}} else '' end @@ -2177,7 +2177,7 @@ WOK end end if @txt and not @txt.empty? - @txt.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') + @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') end @p_num=ParagraphNumber.new(@md,@ocn) @vz=SiSU_Env::GetInit.instance.skin @@ -2216,60 +2216,60 @@ WOK } end - def para_form_css(tag,attrib) # regular paragraphs shaped here + def para_form_css(tag,attrib,txt) # regular paragraphs shaped here ul=ulc='' ul,ulc="
    \n ","\n
" if @tag =~/li/ %{
#{@p_num.ocn_display} #{ul}<#{tag} class="#{attrib}" #{@p_num.id}> - #{@named}#{@txt} + #{@named}#{txt} #{ulc}
} end def para - para_form_css('p','norm') + para_form_css('p','norm',@txt) end def group - para_form_css('p','group') + para_form_css('p','group',@txt) end def block - para_form_css('p','block') + para_form_css('p','block',@txt) end def alt - para_form_css('p','alt') + para_form_css('p','alt',@txt) end def verse - para_form_css('p','verse') + para_form_css('p','verse',@txt) end def code - para_form_css('p','code') + para_form_css('p','code',@txt) end def center - para_form_css('p','center') + para_form_css('p','center',@txt) end def bold - para_form_css('p','bold') + para_form_css('p','bold',@txt) end def bullet - para_form_css('li','bullet') + para_form_css('li','bullet',@txt) end def table @txt=if @t_o.obj !~/^
') - @txt.gsub!(/#{Mx[:br_obj]}/,'

') - para_form_css('p','norm') + @txt=@txt.gsub(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'

'). + gsub(/#{Mx[:br_obj]}/,'

') + para_form_css('p','norm',@txt) end def format(tag,attrib) - para_form_css(tag,attrib) + para_form_css(tag,attrib,@txt) end def title_heading(tag,attrib) %{ @@ -2298,8 +2298,8 @@ WOK def title_heading4 '' end - def seg_heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + def seg_heading_sub(tag,attrib,txt) + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{
#{@p_num.ocn_display} @@ -2320,10 +2320,10 @@ WOK } end def seg_heading5 - seg_heading_sub('p','bold') + seg_heading_sub('p','bold',@txt) end def seg_heading6 - seg_heading_sub('p','bold') + seg_heading_sub('p','bold',@txt) end def dl #check :trailer "
#{@txt} #{@trailer}
" @@ -2333,18 +2333,19 @@ WOK

' end - def gsub_body - case @txt + def gsub_body #unused + @txt=case @txt when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\((i+|iv|v|vi+|ix|x|xi+)\)/ - @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1(\2)') + @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1(\2)') when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\(?(\d|[a-z])+\)/ - @txt.gsub!(/^\((\d+|[a-z])+\)/,'(\1)') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1(\2)') + @txt.gsub(/^\((\d+|[a-z])+\)/,'(\1)'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1(\2)') when /^\s*\d{1,3}\.\s/ - @txt.gsub!(/^\s*(\d+\.)/,'\1') + @txt.gsub(/^\s*(\d+\.)/,'\1') when /^\s*[A-Z]\.\s/ - @txt.gsub!(/^\s*([A-Z]\.)/,'\1') + @txt.gsub(/^\s*([A-Z]\.)/,'\1') + else @txt end end def bold_para @@ -2356,9 +2357,9 @@ WOK     #{@vz.table_close}} end - def bold_heading - @txt.gsub!(/[1-9]~\S+/,'') - @txt.gsub!(/[1-9]~/,'') + def bold_heading #unused + @txt=@txt.gsub(/[1-9]~\S+/,''). + gsub(/[1-9]~/,'') %{

#{@txt}

@@ -2444,9 +2445,8 @@ WOK } end def clean(txt) - txt.gsub!(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,'') - txt.gsub!(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') - txt + txt=txt.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,''). + gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') end def subtoc_lev(tag,attrib) @txt=clean(@txt) @@ -2458,10 +2458,10 @@ WOK note='' if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})/m # had \s* at end note=$1 - note.gsub!(/[\n\s]+/m,' ') - txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') - txt.gsub!(/ \d+<\/sup> /m,'') - txt.gsub!(/#{Mx[:nbsp]}\d+<\/sup>#{Mx[:nbsp]}/m,'') #remove + note=note.gsub(/[\n\s]+/m,' ') + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' '). + gsub(/ \d+<\/sup> /m,''). + gsub(/#{Mx[:nbsp]}\d+<\/sup>#{Mx[:nbsp]}/m,'') #remove end %{<#{tag} class="#{attrib}"> #{txt} #{note} @@ -2473,8 +2473,8 @@ WOK def subtoc_lev6 subtoc_lev('h6','subtoc') if @txt end - def heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + def heading_sub(tag,attrib,txt) + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{
#{@p_num.ocn_display} @@ -2496,10 +2496,10 @@ WOK } end def heading5 - heading_sub('p','bold') + heading_sub('p','bold',@txt) end def heading6 - heading_sub('p','bold') + heading_sub('p','bold',@txt) end def navigation_heading4 %{ diff --git a/lib/sisu/v3dv/epub_segments.rb b/lib/sisu/v3dv/epub_segments.rb index e8bc3f20..1119d8c8 100644 --- a/lib/sisu/v3dv/epub_segments.rb +++ b/lib/sisu/v3dv/epub_segments.rb @@ -114,11 +114,10 @@ WOK filename_seg << @seg[:headings] << @seg[:main] << "\n\n" end filename_seg << @seg[:tail] << @seg[:nav] << @seg[:close] - filename_seg.flatten!.compact! + filename_seg=filename_seg.flatten.compact #watch filename_seg.each do |str| unless str =~/\A\s*\Z/ - str.strip! - @output_epub_cont_seg << str + @output_epub_cont_seg << str.strip end end @output_epub_cont_seg.close @@ -187,10 +186,10 @@ WOK # #while dob.obj =~/href="#{Xx[:segment]}#+(\S+?)"/ # # m=$1 # # if map_nametags[m][:segname] - # # dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) + # # dob.obj=dob.obj.sub(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) # # else # # p "NOT FOUND name_tags: #{m}" - # # dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#\\1"}) # not satisfactory + # # dob.obj=dob.obj.sub(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#\\1"}) # not satisfactory # # end # #end #end @@ -329,7 +328,7 @@ WOK txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading1.gsub(clean,'') - @@heading1.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') + @@heading1=@@heading1.gsub(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is2==1 heading2=@@heading2 @@ -340,7 +339,7 @@ WOK txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading2.gsub(clean,'') - @@heading2.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') + @@heading2=@@heading2.gsub(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is3==1 heading3=@@heading3 @@ -351,7 +350,7 @@ WOK txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading3.gsub(clean,'') - @@heading3.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') + @@heading3=@@heading3.gsub(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is4==1 heading4=@@heading4 @@ -413,7 +412,7 @@ WOK sto.break end if @md.flag_separate_endnotes # may need to revisit, check - dob.obj.gsub!(/"\s+href="#note_ref(\d+)">/,%{" href=\"endnotes#{Sfx[:epub_xhtml]}#note_ref\\1">}) #endnote- twice #removed file type + dob.obj=dob.obj.gsub(/"\s+href="#note_ref(\d+)">/,%{" href=\"endnotes#{Sfx[:epub_xhtml]}#note_ref\\1">}) #endnote- twice #removed file type end if dob.is =~/heading|para/ \ and (not dob.ocn or dob.ocn.to_s.empty?) @@ -464,7 +463,7 @@ WOK end def get_subtoc_endnotes(data) #get endnotes & sub-table of contents subtoc data.each do |dob| - dob.obj.gsub!(/(.+?)<\/a>/mi,'\1') + dob.obj=dob.obj.gsub(/(.+?)<\/a>/mi,'\1') if @md.flag_auto_endnotes if (dob.is=='heading' \ || dob.is=='heading_insert') \ @@ -516,7 +515,7 @@ WOK if dob.obj=~/#{Mx[:en_b_o]}#{pls}\d+\s.+?#{Mx[:en_b_c]}/m endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}#{pls}\d+\s.+?#{Mx[:en_b_c]}/m) end - endnote_array.flatten! #.compact! #check compacting + endnote_array=endnote_array.flatten #.compact #check compacting endnote_array.each do |note| note_match=note.dup note_match_seg=note.dup @@ -541,7 +540,7 @@ WOK note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408 @@seg[:endnote_all] << note_match_all_seg end - dob.obj.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') end end end diff --git a/lib/sisu/v3dv/epub_tune.rb b/lib/sisu/v3dv/epub_tune.rb index 62bcc4e0..dfb19caf 100644 --- a/lib/sisu/v3dv/epub_tune.rb +++ b/lib/sisu/v3dv/epub_tune.rb @@ -101,98 +101,97 @@ module SiSU_EPUB_Tune html else html.obj end - str.gsub!(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - str.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - str.gsub!(/\*/u,'*') # * - str.gsub!(/\+/u,'+') # + - str.gsub!(/¢/u,'¢') # ¢ - str.gsub!(/£/u,'£') # £ - str.gsub!(/¥/u,'¥') # ¥ - str.gsub!(/§/u,'§') # § - str.gsub!(/©/u,'©') # © - str.gsub!(/ª/u,'ª') # ª - str.gsub!(/«/u,'«') # « - str.gsub!(/®/u,'®') # ® - str.gsub!(/°/u,'°') # ° - str.gsub!(/±/u,'±') # ± - str.gsub!(/²/u,'²') # ² - str.gsub!(/³/u,'³') # ³ - str.gsub!(/µ/u,'µ') # µ - str.gsub!(/¶/u,'¶') # ¶ - str.gsub!(/¹/u,'¹') # ¹ - str.gsub!(/º/u,'º') # º - str.gsub!(/»/u,'»') # » - str.gsub!(/¼/u,'¼') # ¼ - str.gsub!(/½/u,'½') # ½ - str.gsub!(/¾/u,'¾') # ¾ - str.gsub!(/×/u,'×') # × - str.gsub!(/÷/u,'÷') # ÷ - str.gsub!(/¿/u,'¿') # ¿ - str.gsub!(/À/u,'À') # À - str.gsub!(/Á/u,'Á') # Á - str.gsub!(/Â/u,'Â') # Â - str.gsub!(/Ã/u,'Ã') # Ã - str.gsub!(/Ä/u,'Ä') # Ä - str.gsub!(/Å/u,'Å') # Å - str.gsub!(/Æ/u,'Æ') # Æ - str.gsub!(/Ç/u,'Ç') # Ç - str.gsub!(/È/u,'È') # È - str.gsub!(/É/u,'É') # É - str.gsub!(/Ê/u,'Ê') # Ê - str.gsub!(/Ë/u,'Ë') # Ë - str.gsub!(/Ì/u,'Ì') # Ì - str.gsub!(/Í/u,'Í') # Í - str.gsub!(/Î/u,'Î') # Î - str.gsub!(/Ï/u,'Ï') # Ï - str.gsub!(/Ð/u,'Ð') # Ð - str.gsub!(/Ñ/u,'Ñ') # Ñ - str.gsub!(/Ò/u,'Ò') # Ò - str.gsub!(/Ó/u,'Ó') # Ó - str.gsub!(/Ô/u,'Ô') # Ô - str.gsub!(/Õ/u,'Õ') # Õ - str.gsub!(/Ö/u,'Ö') # Ö - str.gsub!(/Ø/u,'Ø') # Ø - str.gsub!(/Ù/u,'Ù') # Ù - str.gsub!(/Ú/u,'Ú') # Ú - str.gsub!(/Û/u,'Û') # Û - str.gsub!(/Ü/u,'Ü') # Ü - str.gsub!(/Ý/u,'Ý') # Ý - str.gsub!(/Þ/u,'Þ') # Þ - str.gsub!(/ß/u,'ß') # ß - str.gsub!(/à/u,'à') # à - str.gsub!(/á/u,'á') # á - str.gsub!(/â/u,'â') # â - str.gsub!(/ã/u,'ã') # ã - str.gsub!(/ä/u,'ä') # ä - str.gsub!(/å/u,'å') # å - str.gsub!(/æ/u,'æ') # æ - str.gsub!(/ç/u,'ç') # ç - str.gsub!(/è/u,'è') # è - str.gsub!(/é/u,'é') # é - str.gsub!(/ê/u,'ê') # ê - str.gsub!(/ë/u,'ë') # ë - str.gsub!(/ì/u,'ì') # ì - str.gsub!(/í/u,'í') # í - str.gsub!(/î/u,'î') # î - str.gsub!(/ï/u,'ï') # ï - str.gsub!(/ð/u,'ð') # ð - str.gsub!(/ñ/u,'ñ') # ñ - str.gsub!(/ò/u,'ò') # ò - str.gsub!(/ó/u,'ó') # ó - str.gsub!(/ô/u,'ô') # ô - str.gsub!(/õ/u,'õ') # õ - str.gsub!(/ö/u,'ö') # ö - str.gsub!(/ø/u,'ø') # ø - str.gsub!(/ù/u,'ù') # ú - str.gsub!(/ú/u,'ú') # û - str.gsub!(/û/u,'û') # ü - str.gsub!(/ü/u,'ü') # ý - str.gsub!(/þ/u,'þ') # þ - str.gsub!(/ÿ/u,'ÿ') # ÿ - str.gsub!(/ý/u,'ý') - str.gsub!(/
/u,'
') - str.gsub(/#{Mx[:nbsp]}/u,' ') - str + str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/\*/u,'*'). # * + gsub(/\+/u,'+'). # + + gsub(/¢/u,'¢'). # ¢ + gsub(/£/u,'£'). # £ + gsub(/¥/u,'¥'). # ¥ + gsub(/§/u,'§'). # § + gsub(/©/u,'©'). # © + gsub(/ª/u,'ª'). # ª + gsub(/«/u,'«'). # « + gsub(/®/u,'®'). # ® + gsub(/°/u,'°'). # ° + gsub(/±/u,'±'). # ± + gsub(/²/u,'²'). # ² + gsub(/³/u,'³'). # ³ + gsub(/µ/u,'µ'). # µ + gsub(/¶/u,'¶'). # ¶ + gsub(/¹/u,'¹'). # ¹ + gsub(/º/u,'º'). # º + gsub(/»/u,'»'). # » + gsub(/¼/u,'¼'). # ¼ + gsub(/½/u,'½'). # ½ + gsub(/¾/u,'¾'). # ¾ + gsub(/×/u,'×'). # × + gsub(/÷/u,'÷'). # ÷ + gsub(/¿/u,'¿'). # ¿ + gsub(/À/u,'À'). # À + gsub(/Á/u,'Á'). # Á + gsub(/Â/u,'Â'). # Â + gsub(/Ã/u,'Ã'). # Ã + gsub(/Ä/u,'Ä'). # Ä + gsub(/Å/u,'Å'). # Å + gsub(/Æ/u,'Æ'). # Æ + gsub(/Ç/u,'Ç'). # Ç + gsub(/È/u,'È'). # È + gsub(/É/u,'É'). # É + gsub(/Ê/u,'Ê'). # Ê + gsub(/Ë/u,'Ë'). # Ë + gsub(/Ì/u,'Ì'). # Ì + gsub(/Í/u,'Í'). # Í + gsub(/Î/u,'Î'). # Î + gsub(/Ï/u,'Ï'). # Ï + gsub(/Ð/u,'Ð'). # Ð + gsub(/Ñ/u,'Ñ'). # Ñ + gsub(/Ò/u,'Ò'). # Ò + gsub(/Ó/u,'Ó'). # Ó + gsub(/Ô/u,'Ô'). # Ô + gsub(/Õ/u,'Õ'). # Õ + gsub(/Ö/u,'Ö'). # Ö + gsub(/Ø/u,'Ø'). # Ø + gsub(/Ù/u,'Ù'). # Ù + gsub(/Ú/u,'Ú'). # Ú + gsub(/Û/u,'Û'). # Û + gsub(/Ü/u,'Ü'). # Ü + gsub(/Ý/u,'Ý'). # Ý + gsub(/Þ/u,'Þ'). # Þ + gsub(/ß/u,'ß'). # ß + gsub(/à/u,'à'). # à + gsub(/á/u,'á'). # á + gsub(/â/u,'â'). # â + gsub(/ã/u,'ã'). # ã + gsub(/ä/u,'ä'). # ä + gsub(/å/u,'å'). # å + gsub(/æ/u,'æ'). # æ + gsub(/ç/u,'ç'). # ç + gsub(/è/u,'è'). # è + gsub(/é/u,'é'). # é + gsub(/ê/u,'ê'). # ê + gsub(/ë/u,'ë'). # ë + gsub(/ì/u,'ì'). # ì + gsub(/í/u,'í'). # í + gsub(/î/u,'î'). # î + gsub(/ï/u,'ï'). # ï + gsub(/ð/u,'ð'). # ð + gsub(/ñ/u,'ñ'). # ñ + gsub(/ò/u,'ò'). # ò + gsub(/ó/u,'ó'). # ó + gsub(/ô/u,'ô'). # ô + gsub(/õ/u,'õ'). # õ + gsub(/ö/u,'ö'). # ö + gsub(/ø/u,'ø'). # ø + gsub(/ù/u,'ù'). # ú + gsub(/ú/u,'ú'). # û + gsub(/û/u,'û'). # ü + gsub(/ü/u,'ü'). # ý + gsub(/þ/u,'þ'). # þ + gsub(/ÿ/u,'ÿ'). # ÿ + gsub(/ý/u,'ý'). + gsub(/
/u,'
'). + gsub(/#{Mx[:nbsp]}/u,' ') end end class Tune @@ -224,23 +223,23 @@ module SiSU_EPUB_Tune def markup @tuned_file=[] @data.each do |dob| - 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[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is=='table' - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1') # tt, kbd - dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') - dob.obj.gsub!(/^#{Mx[:gl_bullet]}/m,'●  ') - dob.obj.gsub!(/#{Mx[:nbsp]}/,' ') - dob.obj.gsub!(/<(p|br)>/,'<\1 />') - dob=SiSU_EPUB_Tune::CleanXHTML.new(dob).clean + dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is=='table' + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). + gsub(/^#{Mx[:gl_bullet]}/m,'●  '). + gsub(/#{Mx[:nbsp]}/,' '). + gsub(/<(p|br)>/,'<\1 />') + dob.obj=SiSU_EPUB_Tune::CleanXHTML.new(dob.obj).clean @tuned_file << dob end end @@ -272,29 +271,32 @@ module SiSU_EPUB_Tune %{
#{caption}} else %{#{caption}} end - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else link=m[/(.+)/m] png=m.scan(/\S+/)[0].strip link=link.strip - u.sub!(/^#*/,'') #make neater + u=u.sub(/^#*/,'') #make neater if map_nametags[u] \ and map_nametags[u][:segname] - if u=~/^\d+$/ - u.gsub!(/^(\d+)$/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#o\\1") if u !~/\// unless http_ - else - u.gsub!(/(\S+)/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#\\1") if u !~/\// unless http_ + u=unless http_ + u=if u=~/^\d+$/ + u.gsub(/^(\d+)$/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#o\\1") if u !~/\// + else + u.gsub(/(\S+)/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#\\1") if u !~/\// + end + else u end elsif u =~/^:/ - u.gsub!(/^:/,"#{@env.url.root}/") + u=u.gsub(/^:/,"#{@env.url.root}/") elsif u =~/^\.\.\// - u.gsub!(/^\.\.\//,"#{@env.url.root}/") + u=u.gsub(/^\.\.\//,"#{@env.url.root}/") elsif u =~/https?:\/\// else p "NOT FOUND name_tags: #{u}" end ins=%{#{link}} - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins) - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins). + gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) end word else word @@ -309,56 +311,57 @@ module SiSU_EPUB_Tune data.each do |dob| unless dob.is=='code' if dob.obj =~/<::\s+/ #watch - dob.obj.gsub!(/<::\s+(\S+?)\s+!>/, + dob.obj=dob.obj.gsub(/<::\s+(\S+?)\s+!>/, %{\\1}) end if dob.obj =~/<:image\s+/ - dob.obj.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, - %{}) - dob.obj.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+>/, - %{}) - dob.obj.gsub!(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, - %{}) - dob.obj.gsub!(/<:image\s+(\S+)\s+>/, - %{}) + dob.obj=dob.obj.gsub(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, + %{}). + gsub(/<:image\s+(http\S+)\s+(\S+)\s+>/, + %{}). + gsub(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/, + %{}). + gsub(/<:image\s+(\S+)\s+>/, + %{}) end if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ @word_mode=dob.obj.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)[()\[\]]*[,.;:!?'"]{0,2}|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+/mu) words=urls(@word_mode) - dob.obj.gsub!(/.+/m,words) + dob.obj=dob.obj.gsub(/.+/m,words) end - dob.obj.gsub!(/\\copyright/i,%{©}) - if (dob.obj !~/\<:ad\s+\.\.\//) - dob.obj.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, + dob.obj=dob.obj.gsub(/\\copyright/i,%{©}) + dob.obj=if (dob.obj !~/\<:ad\s+\.\.\//) + dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, %{\n
\\3
\n}) else - dob.obj.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, + dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, %{\n
\\3
\n}) end - dob.obj.gsub!(/!pick/,%{stellar}) - dob.obj.gsub!(/!new/,%{ new}) - dob.obj.gsub!(/<:h(.{1,7}?)>/,'\1') - dob.obj.gsub!(/<:to(\d{1,7}?)>/,'to { \1 } ') - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') #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}\\1#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj=dob.obj.gsub(/!pick/,%{stellar}). + gsub(/!new/,%{ new}). + gsub(/<:h(.{1,7}?)>/,'\1'). + gsub(/<:to(\d{1,7}?)>/,'to { \1 } '). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). #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}\\1#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration if dob.obj =~/..\/\S+/ \ and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ - dob.obj.gsub!(/(\.\.\/\S+)/,'\1') + dob.obj=dob.obj.gsub(/(\.\.\/\S+)/,'\1') end - dob.obj.gsub!(//m,'>') + dob.obj=dob.obj.gsub(//m,'>') end @tuned_file << dob end end def amp_html - data=@data + data,data_new=@data,[] data.each do |dob| - dob.obj.gsub!(/&/u,'&') + dob.obj=dob.obj.gsub(/&/u,'&') + data_new << dob end - data + data_new end def endnotes_html data=@data @@ -367,23 +370,23 @@ module SiSU_EPUB_Tune ast,pls='*','+' data.each do |dob| unless dob.is =~/^code/ - dob.obj.gsub!(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/, - %{#{Mx[:nbsp]}#{Mx[:nbsp]}\\2#{Mx[:nbsp]} } + #note- endnote- - %{\\1\\2 #{Mx[:nbsp]}\\2. \\3 \\4}) #endnote- note- (careful may have switched) - dob.obj.gsub!(/(#{Mx[:en_b_o]})[*](\d+)\s+(.+?)(#{Mx[:en_b_c]})/, - %{#{Mx[:nbsp]}#{Mx[:nbsp]}#{ast}\\2#{Mx[:nbsp]} } + #note- endnote- - %{\\1#{ast}\\2 #{Mx[:nbsp]}#{ast}\\2. \\3 \\4}) #endnote- note- (careful may have switched) - dob.obj.gsub!(/(#{Mx[:en_b_o]})[+](\d+)\s+(.+?)(#{Mx[:en_b_c]})/, - %{#{Mx[:nbsp]}#{Mx[:nbsp]}#{pls}\\2#{Mx[:nbsp]} } + #note- endnote- - %{\\1#{pls}\\2 #{Mx[:nbsp]}#{pls}\\2. \\3 \\4}) #endnote- note- (careful may have switched) # double-check there may here be a bug + dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/, + %{#{Mx[:nbsp]}#{Mx[:nbsp]}\\2#{Mx[:nbsp]} } + #note- endnote- + %{\\1\\2 #{Mx[:nbsp]}\\2. \\3 \\4}). #endnote- note- (careful may have switched) + gsub(/(#{Mx[:en_b_o]})[*](\d+)\s+(.+?)(#{Mx[:en_b_c]})/, + %{#{Mx[:nbsp]}#{Mx[:nbsp]}#{ast}\\2#{Mx[:nbsp]} } + #note- endnote- + %{\\1#{ast}\\2 #{Mx[:nbsp]}#{ast}\\2. \\3 \\4}). #endnote- note- (careful may have switched) + gsub(/(#{Mx[:en_b_o]})[+](\d+)\s+(.+?)(#{Mx[:en_b_c]})/, + %{#{Mx[:nbsp]}#{Mx[:nbsp]}#{pls}\\2#{Mx[:nbsp]} } + #note- endnote- + %{\\1#{pls}\\2 #{Mx[:nbsp]}#{pls}\\2. \\3 \\4}) #endnote- note- (careful may have switched) # double-check there may here be a bug if dob.obj =~/#{Mx[:en_a_o]}([*+]+)\s+.+?#{Mx[:en_a_c]}/ m=$1.length.to_i - dob.obj.gsub!(/(#{Mx[:en_a_o]})[*]+\s+(.+?)(#{Mx[:en_a_c]})/, - %{#{Mx[:nbsp]}#{Mx[:nbsp]}#{ast*m}#{Mx[:nbsp]} } + #note- endnote- - %{\\1#{ast*m} #{Mx[:nbsp]}#{ast*m} \\2 \\3}) #endnote- note- (careful may have switched) - dob.obj.gsub!(/(#{Mx[:en_a_o]})([+]+)\s+(.+?)(#{Mx[:en_a_c]})/, - %{#{Mx[:nbsp]}#{Mx[:nbsp]}#{pls*m}#{Mx[:nbsp]} } + #note- endnote- - %{\\1#{pls*m} #{Mx[:nbsp]}#{pls*m} \\2 \\3}) #endnote- note- (careful may have switched) + dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]})[*]+\s+(.+?)(#{Mx[:en_a_c]})/, + %{#{Mx[:nbsp]}#{Mx[:nbsp]}#{ast*m}#{Mx[:nbsp]} } + #note- endnote- + %{\\1#{ast*m} #{Mx[:nbsp]}#{ast*m} \\2 \\3}). #endnote- note- (careful may have switched) + gsub(/(#{Mx[:en_a_o]})([+]+)\s+(.+?)(#{Mx[:en_a_c]})/, + %{#{Mx[:nbsp]}#{Mx[:nbsp]}#{pls*m}#{Mx[:nbsp]} } + #note- endnote- + %{\\1#{pls*m} #{Mx[:nbsp]}#{pls*m} \\2 \\3}) #endnote- note- (careful may have switched) end end @tuned_file << dob @@ -393,8 +396,7 @@ module SiSU_EPUB_Tune data=@data @tuned_file=[] data.each do |dob| - dob.obj.strip! - dob.obj.chomp! + dob.obj=dob.obj.strip.chomp @tuned_file << dob end @tuned_file << "\n" if (@md.fns =~/\.sst0/) #remove diff --git a/lib/sisu/v3dv/harvest_authors.rb b/lib/sisu/v3dv/harvest_authors.rb index 3d3c2378..fa6934a5 100644 --- a/lib/sisu/v3dv/harvest_authors.rb +++ b/lib/sisu/v3dv/harvest_authors.rb @@ -139,7 +139,7 @@ module SiSU_Harvest_Authors else #p "missing author field: #{@filename} title: #{@title}; author: #{@author_format}" end - idx_array[lang].flatten! + idx_array[lang]=idx_array[lang].flatten idx_array end end @@ -157,7 +157,7 @@ module SiSU_Harvest_Authors @@the_idx_authors[lang] ||= {} idx_array.each do |idx| idx[:author][:last_first_format_a].each do |author| - author.strip! + author=author.strip if @@the_idx_authors[lang][author].class==NilClass @@the_idx_authors[lang][author]={ md: [] } end diff --git a/lib/sisu/v3dv/harvest_topics.rb b/lib/sisu/v3dv/harvest_topics.rb index 6bdc7e12..504e0a4d 100644 --- a/lib/sisu/v3dv/harvest_topics.rb +++ b/lib/sisu/v3dv/harvest_topics.rb @@ -144,7 +144,7 @@ module SiSU_Harvest_Topics g=@idx_list.scan(/[^;]+/) idxl=[] g.each do |i| - i.strip! + i=i.strip idxl << { filename: filename, file: file, rough_idx: i, title: @fulltitle, author: creator, page: page, lang: lang } end idxl @@ -153,7 +153,7 @@ module SiSU_Harvest_Topics else p "missing required field in #{@filename} - [title]: <<#{@title}>>; [author]: <<#{@author_format}>>; [idx]: <<#{@idx_list}>>" if @opt.cmd.inspect =~/[VM]/ end - idx_array[lang].flatten! + idx_array[lang]=idx_array[lang].flatten idx_array end end diff --git a/lib/sisu/v3dv/html.rb b/lib/sisu/v3dv/html.rb index 3006ff95..2c249348 100644 --- a/lib/sisu/v3dv/html.rb +++ b/lib/sisu/v3dv/html.rb @@ -488,8 +488,8 @@ WOK end def level_crosslink dob=@data - if dob !~/^4~!/ - dob.gsub!(/^4~!\s+(\S+)\s+(.+)/, + dob=if dob !~/^4~!/ + dob.gsub(/^4~!\s+(\S+)\s+(.+)/, %{
#{@png.crosslink_ext} @@ -498,7 +498,7 @@ WOK
}) else - dob.gsub!(/^4~!\s+(\S+)\s+(.+)/, + dob.gsub(/^4~!\s+(\S+)\s+(.+)/, %{
@@ -521,7 +521,7 @@ WOK SiSU_Screen::Ansi.new(@md.opt.cmd,'Scroll & Segtoc').txt_grey if @md.opt.cmd =~/[MVv]/ format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) dochead=format_head_toc.head - dochead.gsub!(/toc\.(html)/,'doc.\1') #kludge + dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge ads=SiSU_HTML_Promo::Ad.new(@md) toc_shared << dochead << ads.div.major @segtoc << format_head_toc.head << ads.div.major @@ -584,7 +584,7 @@ WOK @segtoc << @seg_toc_band_bottom ads=SiSU_HTML_Promo::Ad.new(@md) @segtoc << format_head_toc.seg_navigation_tail << ads.div.close << ads.display << format_head_toc.html_close - @segtoc.flatten!.compact! + @segtoc=@segtoc.flatten.compact #watch SiSU_HTML::Source::Output.new(@segtoc,@md).segtoc @segtoc=[] @toc[:scr],@toc[:seg]=[],[] @@ -603,7 +603,7 @@ WOK scroll=[] hr='

' scroll << @scr_toc << '
' << hr << @scr_body << @scr_endnotes << hr << @scr_owner_details << '
' << @scr_tails - scroll.flatten!.compact! + scroll=scroll.flatten.compact #watch end end class Seg < SiSU_HTML_Seg::Seg @@ -617,12 +617,12 @@ WOK begin @filename_html_scroll=@file.write_file.html_scroll @data.each do |para| - para.strip! - para.gsub!(/<:.+?>/,'') - para.gsub!(Xx[:html_relative2],@file.path_rel_links.html_scroll_2) - para.gsub!(Xx[:html_relative1],@file.path_rel_links.html_scroll_1) - #para.gsub!(/#{Xx[:html_relative]}/,@file.path_rel_links.html_scroll) - para.gsub!(/#{Rx[:mx_fa_clean]}/,'') + para=para.strip. + gsub(/<:.+?>/,''). + gsub(Xx[:html_relative2],@file.path_rel_links.html_scroll_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_scroll_1). + #gsub(/#{Xx[:html_relative]}/,@file.path_rel_links.html_scroll). + gsub(/#{Rx[:mx_fa_clean]}/,'') unless para =~/\A\s*\Z/ @filename_html_scroll.puts para,"\n" end @@ -635,10 +635,10 @@ WOK begin @filename_html_segtoc=@file.write_file.html_segtoc @data.each do |para| - para.strip! - para.gsub!(//,'') - para.gsub!(Xx[:html_relative2],@file.path_rel_links.html_seg_2) - para.gsub!(Xx[:html_relative1],@file.path_rel_links.html_seg_1) + para=para.strip. + gsub(//,''). + gsub(Xx[:html_relative2],@file.path_rel_links.html_seg_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_seg_1) unless para =~/\A\s*\Z/ @filename_html_segtoc.puts para,"\n" end diff --git a/lib/sisu/v3dv/html_format.rb b/lib/sisu/v3dv/html_format.rb index be4427ac..fdf7f568 100644 --- a/lib/sisu/v3dv/html_format.rb +++ b/lib/sisu/v3dv/html_format.rb @@ -75,14 +75,14 @@ module SiSU_HTML_Format or @skin_no_ocn ocn_class='ocn_off' @ocn.gsub(/^(\d+|)$/, - %{}) + %{}) elsif @ocn.to_i==0 @ocn.gsub(/^(\d+|)$/, - %{
 }) + %{}) else ocn_class='ocn' @ocn.gsub(/^(\d+|)$/, - %{}) + %{}) end end def name @@ -653,7 +653,7 @@ WOK @file=SiSU_Env::FileOp.new(@md) if @md if @file.output_dir_structure.by_language_code? \ or @file.output_dir_structure.by_filetype? - nxt.gsub!(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") + nxt=nxt.gsub(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") end end %{ @@ -715,7 +715,7 @@ WOK @file=SiSU_Env::FileOp.new(@md) if @md if @file.output_dir_structure.by_language_code? \ or @file.output_dir_structure.by_filetype? - nxt.gsub!(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") + nxt=nxt.gsub(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") end end %{
@@ -974,7 +974,7 @@ WOK end @headnamed= (@headname ? %{} : nil) if @txt and not @txt.empty? - @txt.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') + @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') end @p_num=ParagraphNumber.new(@md,@ocn) @vz=SiSU_Env::GetInit.instance.skin @@ -1081,8 +1081,8 @@ WOK para_form_css('p','norm') end def break - @txt.gsub!(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'

') - @txt.gsub!(/#{Mx[:br_obj]}/,'

') + @txt=@txt.gsub(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'

'). + gsub(/#{Mx[:br_obj]}/,'

') para_form_css('p','norm') end def format(tag,attrib) @@ -1141,7 +1141,7 @@ WOK '' end def seg_heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + @txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{
#{@p_num.ocn_display} @@ -1176,15 +1176,16 @@ WOK
' end def gsub_body #fix - case @txt + @txt=case @txt when /^\((i+|iv|v|vi+|ix|x|xi+)\)/ - @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)') + @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)') when /^\(?(\d|[a-z])+\)/ - @txt.gsub!(/^\((\d+|[a-z])+\)/,'(\1)') + @txt.gsub(/^\((\d+|[a-z])+\)/,'(\1)') when /^\s*\d{1,3}\.\s/ - @txt.gsub!(/^\s*(\d+\.)/,'\1') + @txt.gsub(/^\s*(\d+\.)/,'\1') when /^\s*[A-Z]\.\s/ - @txt.gsub!(/^\s*([A-Z]\.)/,'\1') + @txt.gsub(/^\s*([A-Z]\.)/,'\1') + else @txt end end def bold_para @@ -1197,8 +1198,8 @@ WOK #{@vz.table_close}} end def bold_heading - @txt.gsub!(/[1-9]~(\S+)/,'') - @txt.gsub!(/[1-9]~/,'') + @txt=@txt.gsub(/[1-9]~(\S+)/,''). + gsub(/[1-9]~/,'') %{

#{@txt}

@@ -1286,8 +1287,8 @@ WOK } end def clean(txt) - txt.gsub!(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,'') - txt.gsub!(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') + txt=txt.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,''). + gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') txt end def subtoc_lev(tag,attrib) @@ -1300,9 +1301,9 @@ WOK note='' if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})/m # had \s* at end note=$1 - note.gsub!(/[\n\s]+/m,' ') - txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') - txt.gsub!(/ \d+<\/sup> /m,'') + note=note.gsub(/[\n\s]+/m,' ') + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' '). + gsub(/ \d+<\/sup> /m,'') end %{<#{tag} class="#{attrib}"> #{txt} #{note} @@ -1315,7 +1316,7 @@ WOK subtoc_lev('h6','subtoc') if @txt end def heading_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + @txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{
#{@p_num.ocn_display} @@ -1407,7 +1408,7 @@ WOK lev('h0','toc') end def strip_endnotes(txt) - txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') txt end def mini_lev1 diff --git a/lib/sisu/v3dv/html_minitoc.rb b/lib/sisu/v3dv/html_minitoc.rb index 96ef5d75..d70fa7e1 100644 --- a/lib/sisu/v3dv/html_minitoc.rb +++ b/lib/sisu/v3dv/html_minitoc.rb @@ -75,10 +75,10 @@ @toc=[] @data.each do |txt| if (txt.is =='heading' or txt.is =='heading_insert') - txt.obj.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,'') #remove endnotes from toc - txt.obj.gsub!(/ \d+<\/sup> <\/a>/,'') - txt.obj.gsub!(@pat_strip_heading_name,'\1') - txt.obj.gsub(/(.*?)<\/a>(.*)/,'\1') #2002w42 altered gsub! - problematic? - suspect + txt.obj=txt.obj.gsub(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,''). #remove endnotes from toc + gsub(/ \d+<\/sup> <\/a>/,''). + gsub(@pat_strip_heading_name,'\1') + #gsub(/(.*?)<\/a>(.*)/,'\1') #2002w42 altered gsub - problematic? - suspect toc=case txt.ln when 1; SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_1 when 2; SiSU_HTML_MiniToc::TocMini.new(@md,txt).level_2 @@ -110,7 +110,7 @@ txt=@data if (txt.is =='heading' or txt.is =='heading_insert') \ and txt.ocn !=0 - txt.obj.gsub!(@pat_strip_heading_name,'\1') + txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end title=unless txt.obj =~/Document Information/; txt.obj else @@ -130,7 +130,7 @@ txt=@data if (txt.is =='heading' or txt.is =='heading_insert') \ and txt.ocn !=0 - txt.obj.gsub!(@pat_strip_heading_name,'\1') + txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end txt_obj={ txt: txt.obj } format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) @@ -167,7 +167,7 @@ txt=@data if (txt.is =='heading' or txt.is =='heading_insert') \ and txt.ocn !=0 - txt.obj.gsub!(@pat_strip_heading_name,'\1') + txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end toc={} lnk_n_txt=%{ @@ -182,7 +182,7 @@ txt=@data if (txt.is =='heading' or txt.is =='heading_insert') \ and txt.ocn !=0 - txt.obj.gsub!(@pat_strip_heading_name,'\1') + txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end toc={} lnk_n_txt=%{ diff --git a/lib/sisu/v3dv/html_scroll.rb b/lib/sisu/v3dv/html_scroll.rb index f540b104..89f88b04 100644 --- a/lib/sisu/v3dv/html_scroll.rb +++ b/lib/sisu/v3dv/html_scroll.rb @@ -81,14 +81,14 @@ module SiSU_HTML_Scroll @rcdc=false @scr={ body: [], metadata: [], owner_details: [] } data.each do |dob| - dob.obj.gsub!(/#{@md.file.output_path.html_seg.rel_image}/m,@md.file.output_path.html_scroll.rel_image) + dob.obj=dob.obj.gsub(/#{@md.file.output_path.html_seg.rel_image}/m,@md.file.output_path.html_scroll.rel_image) if defined? dob.name and dob.name =~/^meta/ \ and dob.obj =~/Document Information/ - dob.obj.gsub!(/(Document Information(?: \(metadata\))?)/,'\1') + dob.obj=dob.obj.gsub(/(Document Information(?: \(metadata\))?)/,'\1') end if dob.obj =~/^Metadata$/ \ and dob.lv =='B' - dob.obj.gsub!(/Metadata/,'') + dob.obj=dob.obj.gsub(/Metadata/,'') end if defined? dob.name \ and dob.name =~/^metadata/ \ @@ -96,11 +96,11 @@ module SiSU_HTML_Scroll and dob.obj =~/SiSU Metadata, document information/ @rcdc=true end - dob.obj.gsub!(/href="[a-z0-9._-]+(#\S+?")/m,'href="\1') # internal document links - dob.obj.gsub!(/href="#{Xx[:segment]}/m,'href="') - dob.obj.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'


') + dob.obj=dob.obj.gsub(/href="[a-z0-9._-]+(#\S+?")/m,'href="\1'). # internal document links + gsub(/href="#{Xx[:segment]}/m,'href="'). + gsub(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'


') if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]})/ - unless dob.is =~/^code/; dob.obj.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + unless dob.is =~/^code/; dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') end if defined? dob.ocn @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,dob.ocn) @@ -139,7 +139,7 @@ module SiSU_HTML_Scroll sto.heading_body4 book_idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_html(@md.opt).html_idx book_idx.each do |x| #takes book index prepared for segments and strips segment identifying info - x.gsub!(/(\1(?:-\d+)?)<\/a>/,'\2') + x=x.gsub(/(\1(?:-\d+)?)<\/a>/,'\2') end book_idx.join("\n") #elsif dob.ln==4 \ diff --git a/lib/sisu/v3dv/html_segments.rb b/lib/sisu/v3dv/html_segments.rb index 20ab0726..ba825ae4 100644 --- a/lib/sisu/v3dv/html_segments.rb +++ b/lib/sisu/v3dv/html_segments.rb @@ -106,12 +106,12 @@ module SiSU_HTML_Seg filename_seg << @minitoc << @seg[:headings] << @seg[:main] << "\n
\n" end filename_seg << @seg[:tail] << @seg[:tocband_bannerless] << @seg[:credits] - filename_seg.flatten!.compact! + filename_seg=filename_seg.flatten.compact #watch filename_seg.each do |str| unless str =~/\A\s*\Z/ - str.strip! - str.gsub!(Xx[:html_relative2],@file.path_rel_links.html_seg_2) - str.gsub!(Xx[:html_relative1],@file.path_rel_links.html_seg_1) + str=str.strip. + gsub(Xx[:html_relative2],@file.path_rel_links.html_seg_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_seg_1) @output_seg_file << str end end @@ -331,7 +331,7 @@ module SiSU_HTML_Seg txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading1.gsub(clean,'') - @@heading1.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') + @@heading1=@@heading1.gsub(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is2==1 heading2=@@heading2 @@ -342,7 +342,7 @@ module SiSU_HTML_Seg txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading2.gsub(clean,'') - @@heading2.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') + @@heading2=@@heading2.gsub(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is3==1 heading3=@@heading3 @@ -353,7 +353,7 @@ module SiSU_HTML_Seg txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@seg[:headings] << format_seg.title_heading3.gsub(clean,'') - @@heading3.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') + @@heading3=@@heading3.gsub(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is4==1 heading4=@@heading4 @@ -421,13 +421,13 @@ module SiSU_HTML_Seg sto.break end if @md.flag_separate_endnotes - dob.obj.gsub!(/"\s+href="#_(\d+)">/,%{" href=\"endnotes#{Sfx[:html]}#_\\1">}) #endnote- twice #removed file type + dob.obj=dob.obj.gsub(/"\s+href="#_(\d+)">/,%{" href=\"endnotes#{Sfx[:html]}#_\\1">}) #endnote- twice #removed file type end if dob.obj !~/#{@vz.margin_txt_w1}|#{@vz.margin_txt_w2}/ if dob.is =~/heading|para/ and (not dob.ocn or dob.ocn.to_s.empty?) format_seg=SiSU_HTML_Format::FormatSeg.new(@md,dob) end - dob.obj.gsub!(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with #?? workpoint + dob.obj=dob.obj.gsub(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with #?? workpoint if dob.obj =~/ / #endnote- note- format_seg=SiSU_HTML_Format::FormatSeg.new(@md,dob) dob=format_seg.no_paranum @@ -471,7 +471,7 @@ module SiSU_HTML_Seg end def get_subtoc_endnotes(data) #get endnotes & sub-table of contents subtoc data.each do |dob| - dob.obj.gsub!(/(.+?)<\/a>/mi,'\1') + dob.obj=dob.obj.gsub(/(.+?)<\/a>/mi,'\1') if @md.flag_auto_endnotes if (dob.is=='heading' or dob.is=='heading_insert') \ and dob.ln.to_s =~/^[1234]/ \ @@ -523,7 +523,7 @@ module SiSU_HTML_Seg if dob.obj=~/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m endnote_array << dob.obj.scan(/#{Mx[:en_b_o]}[+]\d+\s.+?#{Mx[:en_b_c]}/m) end - endnote_array.flatten!.compact! #check compacting + endnote_array=endnote_array.flatten.compact #watch, check compacting endnote_array.each do |note| note_match=note.dup note_match_seg=note.dup @@ -548,7 +548,7 @@ module SiSU_HTML_Seg note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408 @@seg[:endnote_all] << note_match_all_seg end - dob.obj.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') end end end diff --git a/lib/sisu/v3dv/html_tune.rb b/lib/sisu/v3dv/html_tune.rb index 1b5cca4d..fab17b78 100644 --- a/lib/sisu/v3dv/html_tune.rb +++ b/lib/sisu/v3dv/html_tune.rb @@ -84,7 +84,7 @@ module SiSU_HTML_Tune data=[] @data.each do |x| unless x.obj.empty? - x.obj.strip! + x.obj=x.obj.strip data << x end end @@ -106,94 +106,93 @@ module SiSU_HTML_Tune html else html.obj end - str.gsub!(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - str.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - str.gsub!(/¢/u,'¢') # ¢ - str.gsub!(/£/u,'£') # £ - str.gsub!(/¥/u,'¥') # ¥ - str.gsub!(/§/u,'§') # § - str.gsub!(/©/u,'©') # © - str.gsub!(/ª/u,'ª') # ª - str.gsub!(/«/u,'«') # « - str.gsub!(/®/u,'®') # ® - str.gsub!(/°/u,'°') # ° - str.gsub!(/±/u,'±') # ± - str.gsub!(/²/u,'²') # ² - str.gsub!(/³/u,'³') # ³ - str.gsub!(/µ/u,'µ') # µ - str.gsub!(/¶/u,'¶') # ¶ - str.gsub!(/¹/u,'¹') # ¹ - str.gsub!(/º/u,'º') # º - str.gsub!(/»/u,'»') # » - str.gsub!(/¼/u,'¼') # ¼ - str.gsub!(/½/u,'½') # ½ - str.gsub!(/¾/u,'¾') # ¾ - str.gsub!(/×/u,'×') # × - str.gsub!(/÷/u,'÷') # ÷ - str.gsub!(/¿/u,'¿') # ¿ - str.gsub!(/À/u,'À') # À - str.gsub!(/Á/u,'Á') # Á - str.gsub!(/Â/u,'Â') # Â - str.gsub!(/Ã/u,'Ã') # Ã - str.gsub!(/Ä/u,'Ä') # Ä - str.gsub!(/Å/u,'Å') # Å - str.gsub!(/Æ/u,'Æ') # Æ - str.gsub!(/Ç/u,'Ç') # Ç - str.gsub!(/È/u,'È') # È - str.gsub!(/É/u,'É') # É - str.gsub!(/Ê/u,'Ê') # Ê - str.gsub!(/Ë/u,'Ë') # Ë - str.gsub!(/Ì/u,'Ì') # Ì - str.gsub!(/Í/u,'Í') # Í - str.gsub!(/Î/u,'Î') # Î - str.gsub!(/Ï/u,'Ï') # Ï - str.gsub!(/Ð/u,'Ð') # Ð - str.gsub!(/Ñ/u,'Ñ') # Ñ - str.gsub!(/Ò/u,'Ò') # Ò - str.gsub!(/Ó/u,'Ó') # Ó - str.gsub!(/Ô/u,'Ô') # Ô - str.gsub!(/Õ/u,'Õ') # Õ - str.gsub!(/Ö/u,'Ö') # Ö - str.gsub!(/Ø/u,'Ø') # Ø - str.gsub!(/Ù/u,'Ù') # Ù - str.gsub!(/Ú/u,'Ú') # Ú - str.gsub!(/Û/u,'Û') # Û - str.gsub!(/Ü/u,'Ü') # Ü - str.gsub!(/Ý/u,'Ý') # Ý - str.gsub!(/Þ/u,'Þ') # Þ - str.gsub!(/ß/u,'ß') # ß - str.gsub!(/à/u,'à') # à - str.gsub!(/á/u,'á') # á - str.gsub!(/â/u,'â') # â - str.gsub!(/ã/u,'ã') # ã - str.gsub!(/ä/u,'ä') # ä - str.gsub!(/å/u,'å') # å - str.gsub!(/æ/u,'æ') # æ - str.gsub!(/ç/u,'ç') # ç - str.gsub!(/è/u,'è') # è - str.gsub!(/é/u,'é') # é - str.gsub!(/ê/u,'ê') # ê - str.gsub!(/ë/u,'ë') # ë - str.gsub!(/ì/u,'ì') # ì - str.gsub!(/í/u,'í') # í - str.gsub!(/î/u,'î') # î - str.gsub!(/ï/u,'ï') # ï - str.gsub!(/ð/u,'ð') # ð - str.gsub!(/ñ/u,'ñ') # ñ - str.gsub!(/ò/u,'ò') # ò - str.gsub!(/ó/u,'ó') # ó - str.gsub!(/ô/u,'ô') # ô - str.gsub!(/õ/u,'õ') # õ - str.gsub!(/ö/u,'ö') # ö - str.gsub!(/ø/u,'ø') # ø - str.gsub!(/ù/u,'ù') # ú - str.gsub!(/ú/u,'ú') # û - str.gsub!(/û/u,'û') # ü - str.gsub!(/ü/u,'ü') # ý - str.gsub!(/þ/u,'þ') # þ - str.gsub!(/ÿ/u,'ÿ') # ÿ - str.gsub!(/ý/u,'ý') - str + str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/¢/u,'¢'). # ¢ + gsub(/£/u,'£'). # £ + gsub(/¥/u,'¥'). # ¥ + gsub(/§/u,'§'). # § + gsub(/©/u,'©'). # © + gsub(/ª/u,'ª'). # ª + gsub(/«/u,'«'). # « + gsub(/®/u,'®'). # ® + gsub(/°/u,'°'). # ° + gsub(/±/u,'±'). # ± + gsub(/²/u,'²'). # ² + gsub(/³/u,'³'). # ³ + gsub(/µ/u,'µ'). # µ + gsub(/¶/u,'¶'). # ¶ + gsub(/¹/u,'¹'). # ¹ + gsub(/º/u,'º'). # º + gsub(/»/u,'»'). # » + gsub(/¼/u,'¼'). # ¼ + gsub(/½/u,'½'). # ½ + gsub(/¾/u,'¾'). # ¾ + gsub(/×/u,'×'). # × + gsub(/÷/u,'÷'). # ÷ + gsub(/¿/u,'¿'). # ¿ + gsub(/À/u,'À'). # À + gsub(/Á/u,'Á'). # Á + gsub(/Â/u,'Â'). # Â + gsub(/Ã/u,'Ã'). # Ã + gsub(/Ä/u,'Ä'). # Ä + gsub(/Å/u,'Å'). # Å + gsub(/Æ/u,'Æ'). # Æ + gsub(/Ç/u,'Ç'). # Ç + gsub(/È/u,'È'). # È + gsub(/É/u,'É'). # É + gsub(/Ê/u,'Ê'). # Ê + gsub(/Ë/u,'Ë'). # Ë + gsub(/Ì/u,'Ì'). # Ì + gsub(/Í/u,'Í'). # Í + gsub(/Î/u,'Î'). # Î + gsub(/Ï/u,'Ï'). # Ï + gsub(/Ð/u,'Ð'). # Ð + gsub(/Ñ/u,'Ñ'). # Ñ + gsub(/Ò/u,'Ò'). # Ò + gsub(/Ó/u,'Ó'). # Ó + gsub(/Ô/u,'Ô'). # Ô + gsub(/Õ/u,'Õ'). # Õ + gsub(/Ö/u,'Ö'). # Ö + gsub(/Ø/u,'Ø'). # Ø + gsub(/Ù/u,'Ù'). # Ù + gsub(/Ú/u,'Ú'). # Ú + gsub(/Û/u,'Û'). # Û + gsub(/Ü/u,'Ü'). # Ü + gsub(/Ý/u,'Ý'). # Ý + gsub(/Þ/u,'Þ'). # Þ + gsub(/ß/u,'ß'). # ß + gsub(/à/u,'à'). # à + gsub(/á/u,'á'). # á + gsub(/â/u,'â'). # â + gsub(/ã/u,'ã'). # ã + gsub(/ä/u,'ä'). # ä + gsub(/å/u,'å'). # å + gsub(/æ/u,'æ'). # æ + gsub(/ç/u,'ç'). # ç + gsub(/è/u,'è'). # è + gsub(/é/u,'é'). # é + gsub(/ê/u,'ê'). # ê + gsub(/ë/u,'ë'). # ë + gsub(/ì/u,'ì'). # ì + gsub(/í/u,'í'). # í + gsub(/î/u,'î'). # î + gsub(/ï/u,'ï'). # ï + gsub(/ð/u,'ð'). # ð + gsub(/ñ/u,'ñ'). # ñ + gsub(/ò/u,'ò'). # ò + gsub(/ó/u,'ó'). # ó + gsub(/ô/u,'ô'). # ô + gsub(/õ/u,'õ'). # õ + gsub(/ö/u,'ö'). # ö + gsub(/ø/u,'ø'). # ø + gsub(/ù/u,'ù'). # ú + gsub(/ú/u,'ú'). # û + gsub(/û/u,'û'). # ü + gsub(/ü/u,'ü'). # ý + gsub(/þ/u,'þ'). # þ + gsub(/ÿ/u,'ÿ'). # ÿ + gsub(/ý/u,'ý') end end class Tune @@ -266,15 +265,15 @@ module SiSU_HTML_Tune %{#{caption}} else %{#{caption}} end - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else link=m[/(.+)/m] png=m.scan(/\S+/)[0].strip link=link.strip - u.gsub!(/(\S+)/,"#{Xx[:segment]}#\\1") if u !~/\// unless http_ #marker: in scroll remove; in seg replace + u=u.gsub(/(\S+)/,"#{Xx[:segment]}#\\1") if u !~/\// unless http_ #marker: in scroll remove; in seg replace ins=%{#{link}} - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins) - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins). + gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) end word else word @@ -288,74 +287,74 @@ module SiSU_HTML_Tune if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ @word_mode=dob.obj.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)[()\[\]]*[,.;:!?'"]{0,2}|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+/mu) words=urls(@word_mode) - dob.obj.gsub!(/.+/m,words) + dob.obj=dob.obj.gsub(/.+/m,words) end #consider change, do a while loop - dob.obj.gsub!(/\\copyright/i,%{©}) + dob.obj=dob.obj.gsub(/\\copyright/i,%{©}) if (dob.obj !~/\<:ad\s+\.\.\//) - dob.obj.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, + dob.obj=dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/, %{\n
\\3
\n}) else - dob.obj.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, + dob.obj=dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/, %{\n
\\3
\n}) end - dob.obj.gsub!(/!pick/,%{stellar}) - dob.obj.gsub!(/!new/,%{ new}) - dob.obj.gsub!(/<:h(.{1,7}?)>/,'\1') - dob.obj.gsub!(/<:to(\d{1,7}?)>/,'to { \1 } ') - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') #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}\\1#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj=dob.obj.gsub(/!pick/,%{stellar}). + gsub(/!new/,%{ new}). + gsub(/<:h(.{1,7}?)>/,'\1'). + gsub(/<:to(\d{1,7}?)>/,'to { \1 } '). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). #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}\\1#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration if dob.obj =~/#{Xx[:html_relative2]}\/\S+/ \ and dob.obj !~/(\"#{Xx[:html_relative2]}\/\S+?\"|>\s*#{Xx[:html_relative2]}\/\S+<)/ - dob.obj.gsub!(/(#{Xx[:html_relative2]}\/\S+)/,'\1') + dob.obj=dob.obj.gsub(/(#{Xx[:html_relative2]}\/\S+)/,'\1') end if dob.obj =~/..\/\S+/ \ and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ - dob.obj.gsub!(/\.\.(\/\S+)/,%{\1}) + dob.obj=dob.obj.gsub(/\.\.(\/\S+)/,%{\1}) end - dob.obj.gsub!(//m,'>') + dob.obj=dob.obj.gsub(//m,'>') end dob end def angle_brackets(dob) - dob.obj.gsub!(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}") + dob.obj=dob.obj.gsub(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}") dob end def endnotes_html(dob) unless dob.is =~/^code/ - dob.obj.gsub!(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/, - '  \2  ' + #note- endnote- - '\1\2  \2. \3 \4') #endnote- note- (careful may have switched) - dob.obj.gsub!(/(#{Mx[:en_b_o]})([*+]\d+)\s+(.+?)(#{Mx[:en_b_c]})/, - '  \2  ' + #note- endnote- - '\1\2  \2. \3 \4') #endnote- note- (careful may have switched) - dob.obj.gsub!(/(#{Mx[:en_a_o]})([*+]+)\s+(.+?)(#{Mx[:en_a_c]})/, - '  \2  ' + #note- endnote- - '\1\2  \2 \3 \4') #endnote- note- (careful may have switched) + dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/, + '  \2  ' + #note- endnote- + '\1\2  \2. \3 \4'). #endnote- note- (careful may have switched) + gsub(/(#{Mx[:en_b_o]})([*+]\d+)\s+(.+?)(#{Mx[:en_b_c]})/, + '  \2  ' + #note- endnote- + '\1\2  \2. \3 \4'). #endnote- note- (careful may have switched) + gsub(/(#{Mx[:en_a_o]})([*+]+)\s+(.+?)(#{Mx[:en_a_c]})/, + '  \2  ' + #note- endnote- + '\1\2  \2 \3 \4') #endnote- note- (careful may have switched) end dob end def markup(dob) - 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[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is=='table' - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1') # tt, kbd - dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') - dob.obj.gsub!(/^#{Mx[:gl_bullet]}/m,'●  ') - dob.obj.gsub!(/#{Mx[:nbsp]}/,' ') - dob.obj.gsub!(/<(p|br)>/,'<\1 />') + dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is=='table' + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). + gsub(/^#{Mx[:gl_bullet]}/m,'●  '). + gsub(/#{Mx[:nbsp]}/,' '). + gsub(/<(p|br)>/,'<\1 />') dob=SiSU_HTML_Tune::CleanHTML.new(dob).clean dob end @@ -363,8 +362,7 @@ module SiSU_HTML_Tune data=@data @tuned_file=[] data.each do |dob| - dob.obj.strip! - dob.obj.chomp! + dob.obj=dob.obj.strip.chomp @tuned_file << dob end @tuned_file << "\n" if (@md.fns =~/\.sst0/) #remove diff --git a/lib/sisu/v3dv/manifest.rb b/lib/sisu/v3dv/manifest.rb index 253b01d9..3310fa98 100644 --- a/lib/sisu/v3dv/manifest.rb +++ b/lib/sisu/v3dv/manifest.rb @@ -117,8 +117,8 @@ module SiSU_Manifest def output manifest=@f.write_file.manifest @manifest[:html].each do |x| - x.gsub!(Xx[:html_relative2],@f.path_rel_links.html_scroll_2) - x.gsub!(Xx[:html_relative1],@f.path_rel_links.html_scroll_1) + x=x.gsub(Xx[:html_relative2],@f.path_rel_links.html_scroll_2). + gsub(Xx[:html_relative1],@f.path_rel_links.html_scroll_1) manifest << x end end @@ -180,8 +180,7 @@ module SiSU_Manifest end end manifests - @m.uniq! - @m + @m=@m.uniq end def languages(id,file) flv=published_manifests? @@ -201,7 +200,7 @@ module SiSU_Manifest end end def metadata(id,info) - info.to_s.gsub!(/#{Mx[:br_line]}/,'
') + info=info.to_s.gsub(/#{Mx[:br_line]}/,'
') @manifest[:html] << %{
\n} end def links(url,lnk,target) @@ -772,8 +771,8 @@ WOK if @env.manifest_minitoc? if @env.output_dir_structure.by_language_code? \ or @env.output_dir_structure.by_filetype? - minitoc.gsub!(//,'') # remove dummy headings (used by html) #check - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'++\1++') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'--\1--') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1') - dob.obj.gsub!(/\A\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}#{Mx[:br_line]}([,.:!?](?: |$))?/m,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}") - dob.obj.gsub!(/\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}([,.:!?](?: |$))?/m,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}") - dob.obj.gsub!(/\A\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?#{Mx[:br_line]}/m,"#{Mx[:br_line]}.BI \\1\\2#{Mx[:br_line]}") - dob.obj.gsub!(/\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.B \\1\\2#{Mx[:br_line]}") - dob.obj.gsub!(/\s*#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}") + dob.obj=dob.obj.gsub(/.+?<-#>/,''). # remove dummy headings (used by html) #check + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'++\1++'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'--\1--'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). + gsub(/\A\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}#{Mx[:br_line]}([,.:!?](?: |$))?/m,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}"). + gsub(/\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}([,.:!?](?: |$))?/m,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}"). + gsub(/\A\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?#{Mx[:br_line]}/m,"#{Mx[:br_line]}.BI \\1\\2#{Mx[:br_line]}"). + gsub(/\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.B \\1\\2#{Mx[:br_line]}"). + gsub(/\s*#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}") unless dob.is=='code' - dob.obj.gsub!(/(?:^|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1 #{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3") - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1#{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3") + dob.obj=dob.obj.gsub(/(?:^|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1 #{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3"). + gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1#{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3") @manpage[:endnotes]=extract_endnotes(dob.obj) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_a_c]}/m,'[^\1]') # endnote marker marked up - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_b_c]}/m,'[^\1]') # endnote marker marked up - dob.obj.gsub!(/#{Mx[:gl_o]}#amp#{Mx[:gl_c]}/,'&') ##{Mx[:gl_o]}#095#{Mx[:gl_c]} - dob.obj.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - dob.obj.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - dob.obj.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - dob.obj.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') - dob.obj.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\e') - dob.obj.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - dob.obj.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - dob.obj.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - dob.obj.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - dob.obj.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - dob.obj.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_a_c]}/m,'[^\1]'). # endnote marker marked up + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_b_c]}/m,'[^\1]'). # endnote marker marked up + gsub(/#{Mx[:gl_o]}#amp#{Mx[:gl_c]}/,'&'). ##{Mx[:gl_o]}#095#{Mx[:gl_c]} + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\e'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') else - dob.obj.gsub!(/\\/,'\e') - dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n") # watch + dob.obj=dob.obj.gsub(/\\/,'\e'). + gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n") # watch #dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+\s*/,"\n") # watch end - dob.obj.gsub!(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*') #man page requires - dob.obj.gsub!(/┆/,'|') - dob.obj.gsub!(/\s\.(\S+)/,' \\.\1') - dob.obj.gsub!(/(\n\.)(\S\S\S+)/m,'\1\\.\2') - dob.obj.gsub!(/-/,'\-') #manpages use this - dob.obj.gsub!(/~/,'~') if dob.obj #manpages use this + dob.obj=dob.obj.gsub(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires + gsub(/┆/,'|'). + gsub(/\s\.(\S+)/,' \\.\1'). + gsub(/(\n\.)(\S\S\S+)/m,'\1\\.\2'). + gsub(/-/,'\-') #manpages use this + dob.obj=dob.obj.gsub(/~/,'~') if dob.obj #manpages use this if dob.is =~/block|group|verse|alt|code/ if dob.is =='code' - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _> _< - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _<_< - dob.obj.gsub!(/\A(.+)?\Z/m,".nf\n\n\\1\n\n.fi") + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2'). # _<_< + gsub(/\A(.+)?\Z/m,".nf\n\n\\1\n\n.fi") end end #dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+\s*/m,"\n.br\n") # watch - dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+\s*/m,"\n\n") # watch + dob.obj=dob.obj.gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+\s*/m,"\n\n") # watch blit=dob.obj.scan(/\[[^\]]+\]|[^\[]+/) blit_array=[] blit.each do |x| - if x =~/^\[/ - x.gsub!(/\s+/,' \ ') #manpages use this + x=if x =~/^\[/ + x.gsub(/\s+/,' \ ') #manpages use this else x end blit_array << x end dob.obj=blit_array.join - dob.obj.gsub!(/#{Mx[:gl_o]}:name#\S+?#{Mx[:gl_c]}/mi,'') #added - #dob.obj.gsub!(/\s\\\s+(#{Mx[:br_line]}|#{Mx[:br_nl]})/,'\1') #a messy solution - dob.obj.gsub!(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,'') # remove page breaks - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1\2') - dob.obj.gsub!(/(.+?)<\/a>/m,'\1') - dob.obj.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') # decide on - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/^(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]') + dob.obj=dob.obj.gsub(/#{Mx[:gl_o]}:name#\S+?#{Mx[:gl_c]}/mi,''). #added + #gsub(/\s\\\s+(#{Mx[:br_line]}|#{Mx[:br_nl]})/,'\1'). #a messy solution + gsub(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,''). # remove page breaks + gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1\2'). + gsub(/(.+?)<\/a>/m,'\1'). + gsub(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,''). # remove name links + gsub(/ |#{Mx[:nbsp]}/,' '). # decide on + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/^(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]') wordlist=dob.obj.scan(/\S+/) if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ if dob.obj =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change @@ -362,14 +362,14 @@ WOK dob.obj='' end if dob.obj - dob.obj.gsub!(/\s(\[)/m,' \ \1') - dob.obj.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n") # watch - dob.obj.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - dob.obj.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - dob.obj.gsub!(/#{Mx[:pa_o]}\S+#{Mx[:pa_c]}/,' ') + dob.obj=dob.obj.gsub(/\s(\[)/m,' \ \1'). + gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n"). # watch + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:pa_o]}\S+#{Mx[:pa_c]}/,' ') unless dob.is =='code' - dob.obj.gsub!(//,' ') - dob.obj.gsub!(/<:\S+>/,' ') + dob.obj=dob.obj.gsub(//,' '). + gsub(/<:\S+>/,' ') end end dob @@ -416,7 +416,7 @@ WOK if para.class==Array \ and para.length > 0 para.each do |line| - line.gsub!(/\s+$/m,'') + line=line.gsub(/\s+$/m,'') filename_manpage.puts line #unix manpage end else filename_manpage.puts para #unix manpage # /^([*=-]|\.){5}/ 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" 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?:/ %{#{txt.strip}#{trail}} when /^:/ # site same document collection html link - url.gsub!(/^:/,"#{@env.url.root}/") + url=url.gsub(/^:/,"#{@env.url.root}/") %{#{txt.strip}#{trail}} when /^\.\.\// # site same document collection html link - url.gsub!(/^\.\.\//,"#{@env.url.root}/") + url=url.gsub(/^\.\.\//,"#{@env.url.root}/") %{#{txt.strip}#{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]}/, - '\1') #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}\\1#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '\1'). #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}\\1#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}\\1#{@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}\\1#{@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]}/,'\1 \2') + str=str.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,'\1 \2') end if str =~/#{Mx[:en_a_o]}([*]+)\s+/ a=$1.gsub(/([*])/,"\\\\\\1") - str.gsub!(/#{Mx[:en_a_o]}([*]+)\s+(.+?)#{Mx[:en_a_c]}/,%{\\1 \\2}) + str=str.gsub(/#{Mx[:en_a_o]}([*]+)\s+(.+?)#{Mx[:en_a_c]}/,%{\\1 \\2}) @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]}/,%{\\1 \\2}) + str=str.gsub(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{\\1 \\2}) @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]}/,%{\\1 \\2}) + str=str.gsub(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{\\1 \\2}) @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!(/<(text:span text:style-name="Span_\S+?"|\/text:span)>/,'<\1>') #works, not ideal - str.gsub!(/#{Mx[:br_line]}/,'
') - str.gsub!(/<br(?:\s+\/)?>/,'
') - str + str=str.gsub(/&nbsp;| |#{Mx[:nbsp]}/,' '). + gsub(//,'>'). + gsub(/<(text:span text:style-name="Span_\S+?"|\/text:span)>/,'<\1>'). #works, not ideal + gsub(/#{Mx[:br_line]}/,'
'). + gsub(/<br(?:\s+\/)?>/,'
') 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]}/, - '\1') #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}\\1#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '\1'). #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}\\1#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}\\1#{@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,'') - 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,''). + 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 << %{#{parablock}} 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]}/, - '\1') #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}\\1#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '\1'). #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}\\1#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}\\1#{@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,'') - 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,''). + 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 << %{#{parablock}} 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*$/,'
') - parablock.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '\1') #http ftp matches escaped, no decoration + parablock=parablock.gsub(/^\s*$/,'
'). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '\1') #http ftp matches escaped, no decoration parray << %{#{parablock}} 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=dob.obj.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]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1') - 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]}/,'\1'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). + 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=' ' + dob.obj end - dob.obj.gsub!(/#{Mx[:br_line]}/,'
') - 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]}/, - '\1') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, - '\1') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, - '\1') - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, - '\1') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, - '\1') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, - '\1') - 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>/,'\1') - dob.obj.gsub!(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/,'
'). + gsub(/©/,'©'). #too arbitrary + gsub(/.+?<-#>/,''). # remove dummy headings (used by html) #check + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, + '\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, + '\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, + '\1'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, + '\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, + '\1'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, + '\1'). + 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>/,'\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 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 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 diff --git a/lib/sisu/v3dv/odf_format.rb b/lib/sisu/v3dv/odf_format.rb index 9167fc5e..c6d4b504 100644 --- a/lib/sisu/v3dv/odf_format.rb +++ b/lib/sisu/v3dv/odf_format.rb @@ -84,7 +84,7 @@ module SiSU_ODF_Format p caller end rgx=/#{Mx[:en_a_o]}\d+\s+(.+?)#{Mx[:en_a_c]}/ - @txt.gsub!(rgx,'\1') if @txt =~rgx + @txt=@txt.gsub(rgx,'\1') if @txt =~rgx @vz=SiSU_Env::GetInit.instance.skin end def scr_endnote_body @@ -150,7 +150,7 @@ module SiSU_ODF_Format 'Table_Heading' else 'P_table_cell' end - str.gsub!(/^~$/,'') # tilde / empty cell + str=str.gsub(/^~$/,'') # tilde / empty cell %{#{@br}} + %{#{@br}} + %{#{str}} + @@ -180,7 +180,7 @@ module SiSU_ODF_Format row='' if row =~/^/,1] @@tablefoot << m if m - row.gsub!(//,'') + row=row.gsub(//,'') @cells=[] row.split(/\s*#{Mx[:tc_p]}/).each do |cell| @cells << table_tag_cell(cell,i) @@ -226,8 +226,8 @@ module SiSU_ODF_Format 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 end def meta_inf_manifest_xml(md) @@ -256,8 +256,8 @@ WOK 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 end def meta_xml @@ -272,8 +272,8 @@ WOK 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 end def settings_xml @@ -375,8 +375,8 @@ WOK 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 end def styles_xml @@ -576,15 +576,15 @@ WOK 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 end def mimetype x=< 0) \ @@ -188,7 +189,7 @@ module SiSU_Commandline end SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n").print_brown if @cmd =~/[vVM]/ end -# @files.uniq! +# @files=@files.uniq @act=opt_act @files self @@ -229,7 +230,7 @@ module SiSU_Commandline fn = (y[r_f,1]) \ ? y[r_f,1] : y - fn.gsub!(/\.((?:ssm\.)?sst)/,'.-\1') + fn=fn.gsub(/\.((?:ssm\.)?sst)/,'.-\1') fullname=Dir.pwd + '/' + fn pt=Pathname.new(fullname) pth << Dir.pwd @@ -388,7 +389,7 @@ module SiSU_Commandline end ca=[] unless c.empty? - c.gsub!(/-/,'') + c=c.gsub(/-/,'') c.scan(/CC|\S/) {|x| ca << x} cmd= '-' + ca.uniq.join end diff --git a/lib/sisu/v3dv/param.rb b/lib/sisu/v3dv/param.rb index 4d439535..fc2ac877 100644 --- a/lib/sisu/v3dv/param.rb +++ b/lib/sisu/v3dv/param.rb @@ -179,7 +179,7 @@ module SiSU_Param end def name_format(name) if name - name.strip! + name=name.strip @name_a_h=[] authors=name.scan(/[^;]+/) authors.each_with_index do |a,i| @@ -776,8 +776,8 @@ module SiSU_Param m=@h['bold'] i=(m=~/\/i$/)? 'i' : '' z=if m - x=m.gsub(/^\/(.+?)\/i?/,'\1') - x.gsub!(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided rgx='\b(' + x + ')\b' y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) { str: '\b(?:' + x + ')\b', regx: y, i: i } @@ -789,8 +789,8 @@ module SiSU_Param m=@h['italics'] i=((m=~/\/i$/) ? 'i' : '') z=if m - x=m.gsub(/^\/(.+?)\/i?/,'\1') - x.gsub!(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided rgx='\b(' + x + ')\b' y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) { str: '\b(?:' + x + ')\b', regx: y, i: i } @@ -863,16 +863,16 @@ module SiSU_Param end end if manpage['name'] - manpage['name']=manpage['name'].join("\n.br\n") - manpage['name'].gsub!(/(-)/m,"\\\\\\1") - manpage['name'].gsub!(/\A/,"\n.br\n.SH NAME\n.br\n") + manpage['name']=manpage['name'].join("\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH NAME\n.br\n") else manpage['name']='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' end if manpage['synopsis'] - manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n") - manpage['synopsis'].gsub!(/(-)/m,"\\\\\\1") - manpage['synopsis'].gsub!(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") + manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") else manpage['synopsis']='' end @@ -1272,7 +1272,7 @@ module SiSU_Param end end end - para.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if para !~/^%+\s/ \ and para =~@rgx_image @ec[:image] << para.scan(@rgx_image).uniq @@ -1284,13 +1284,12 @@ module SiSU_Param end end #% here endeth the document loop if @ec[:image].length > 0 - @ec[:image].flatten! - @ec[:image].uniq! + @ec[:image]=@ec[:image].flatten.uniq @ec[:image].delete_if {|x| x =~/https?:\/\// } - @ec[:image].sort! + @ec[:image]=@ec[:image].sort end - @ec[:audio].uniq!; @ec[:audio].flatten!; @ec[:audio].sort! - @ec[:multimedia].uniq!; @ec[:multimedia].flatten!; @ec[:multimedia].sort! + @ec[:audio]=@ec[:audio].uniq.flatten.sort + @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort unless @rights if defined? @creator.author \ and @creator.author \ @@ -1315,10 +1314,10 @@ module SiSU_Param m[-1]=m[-1].scan(/[^|]+/) if m[-1] =~/[|]/ @topic_register_array << m end - @topic_register_array.sort! + @topic_register_array=@topic_register_array.sort end if @i18n - @i18n.uniq! + @i18n=@i18n.uniq @i18n << 'en' unless @i18n.find_index("en") else @i18n=[ 'en' ] @@ -1335,6 +1334,13 @@ module SiSU_Param translate.gsub!(/:?C/,'3') translate.gsub!(/:?B/,'2') translate.gsub!(/:?A/,'1') + # looks like an ok substituion for the above but is not, causes problems, check why + #translate=translate.gsub(/3/,'6'). + # gsub(/2/,'5'). + # gsub(/1/,'4'). + # gsub(/:?C/,'3'). + # gsub(/:?B/,'2'). + # gsub(/:?A/,'1') translate=if translate =~/^\d+$/; translate.to_i else translate end @@ -1342,10 +1348,10 @@ module SiSU_Param end end @pagenew,@pagebreak,@num_top,@toc_lev_limit=translated - @markup.gsub!(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}") - @markup.gsub!(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}") - @markup.gsub!(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}") - @markup.gsub!(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") + @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). + gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). + gsub(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}"). + gsub(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") end if @opt.mod.inspect =~/--papersize[=-]\S+|--pdf[=-]\S+/ \ or @opt.mod.inspect =~/--(?:a4|letter|legal|book|a5|b5)\b/i #command line config/header override @@ -1394,7 +1400,7 @@ module SiSU_Param # end # @lang << [lang[:n],"#{c[:a]}sisu_manifest#{c[:b]}.html#{c[:c]}"] # end if @flv - @lang.uniq! + @lang=@lang.uniq @fn=SiSU_Env::EnvCall.new(@fns).lang(fn_set_lang[:c]) @identifier="#{@env.url.root}/#{@fnb}/#{@fn[:toc]}" #DC note constructed dc identifier if @en[:note] > 0 \ diff --git a/lib/sisu/v3dv/plaintext.rb b/lib/sisu/v3dv/plaintext.rb index 9bef2c09..ba1cc48a 100644 --- a/lib/sisu/v3dv/plaintext.rb +++ b/lib/sisu/v3dv/plaintext.rb @@ -155,13 +155,13 @@ module SiSU_Plaintext ? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1)) : (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,1,1)) wrap=util.line_wrap - if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m - wrap.gsub!(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <]') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]') - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{@brace_url.txt_open}\\1#{@brace_url.txt_close}") + dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]'). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{@brace_url.txt_open}\\1#{@brace_url.txt_close}") extract_endnotes(dob) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]') # endnote marker marked up - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]') # endnote marker marked up - dob.obj.gsub!(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<') - dob.obj.gsub!(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>') - dob.obj.gsub!(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&') - dob.obj.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - dob.obj.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - dob.obj.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - dob.obj.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') - dob.obj.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - dob.obj.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - dob.obj.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - dob.obj.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - dob.obj.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - dob.obj.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') - dob.obj.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]'). # endnote marker marked up + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]'). # endnote marker marked up + gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). + gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>'). + gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&'). + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©'). + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') end - if dob.of=='block' # watch - dob.obj.gsub!(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* ") - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") - else dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") + dob.obj=if dob.of=='block' # watch + dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* "). + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") + else dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") end if dob.is=='code' - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _> _< - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _<_< + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< end - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') - dob.obj.gsub!(/(.+?)<\/a>/m,'\1') - dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') # remove name links - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') # decide on - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]') - dob.obj.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/(.+?)<\/a>/m,'\1'). + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links + gsub(/ |#{Mx[:nbsp]}/,' '). # decide on + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). + gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') wordlist=dob.obj.scan(/\S+/) if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ #if defined? dob.ocn and dob.ocn.to_s =~/\d+/ @@ -372,9 +372,11 @@ WOK end # following empty line (@br) missing, fix end dob='' if (dob.obj =~// \ - and dob.obj =~/^(-\{{2}~\d+|)/) # -endnote - dob.obj.gsub!(//,' ') if dob ## Clean Prepared Text - dob.obj.gsub!(/<:\S+>/,' ') if dob ## Clean Prepared Text + and dob.obj =~/^(-\{{2}~\d+|)/) # -endnote + if dob ## Clean Prepared Text + dob.obj=dob.obj.gsub(//,' '). + gsub(/<:\S+>/,' ') + end end end @plaintext diff --git a/lib/sisu/v3dv/plaintext_format.rb b/lib/sisu/v3dv/plaintext_format.rb index 7aec6da6..f7956070 100644 --- a/lib/sisu/v3dv/plaintext_format.rb +++ b/lib/sisu/v3dv/plaintext_format.rb @@ -86,9 +86,9 @@ module SiSU_PlaintextFormat p caller end rgx=/^#{Rx[:lv]}/ - @txt.gsub!(rgx,'') if @txt =~rgx + @txt=@txt.gsub(rgx,'') if @txt =~rgx rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:en_a_c]}/ - @txt.gsub!(rgx,'\1') if @txt =~rgx + @txt=@txt.gsub(rgx,'\1') if @txt =~rgx @vz=SiSU_Env::GetInit.instance.skin end def scr_endnote_body diff --git a/lib/sisu/v3dv/po4a.rb b/lib/sisu/v3dv/po4a.rb index a622aac9..945b07b8 100644 --- a/lib/sisu/v3dv/po4a.rb +++ b/lib/sisu/v3dv/po4a.rb @@ -74,7 +74,7 @@ module SiSU_Po4a # puts "#{@opt.fns} not a processed file type" #end r=Px[:lng_lst].join('|') - r.gsub!(/\|en\|/,'|') + r=r.gsub(/\|en\|/,'|') @lang_regx=%r{(?:#{r})} if opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ and opt.f_pth[:lng]!=opt.lng_base @@ -187,9 +187,9 @@ module SiSU_Po4a @n=[] notes_a.flatten.each do |n| #high cost to deal with
appropriately within plaintext, consider n=n.dup.to_s - n.gsub!(/^([\d]+)\s+/,'^~\1 ') - #n.gsub!(/^([\d*+]+)\s+/,'^~\1 ') - n.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') + n=n.gsub(/^([\d]+)\s+/,'^~\1 '). + #gsub(/^([\d*+]+)\s+/,'^~\1 '). + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') @n << n end notes_a=@n.flatten @@ -219,13 +219,13 @@ module SiSU_Po4a end util=pot_structure(desc,orig,trans) wrap=util.line_wrap - if wrap =~ /^\s*\^~[\d*+]+\s+.+?\s*\Z/m - wrap.gsub!(/^\s*(\^~[\d*+]+)\s+(.+?)\s*\Z/m, </ \ and dob_src.obj =~/^(-\{{2}~\d+|)/) # -endnote - dob_src.obj.gsub!(//,' ') if dob_src ## Clean Prepared Text - dob_src.obj.gsub!(/<:\S+>/,' ') if dob_src ## Clean Prepared Text + if dob_src ## Clean Prepared Text + dob_src.obj=dob_src.obj.gsub(//,' '). + gsub(/<:\S+>/,' ') if dob_src ## Clean Prepared Text + end end #[dob_src,dob_trn] end def markup(dob) # Used for major markup instructions dir=SiSU_Env::InfoEnv.new(@md.fns) fix=[] - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, - "#{Px[:po_bold_o]}\\1#{Px[:po_bold_c]}") - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, - "#{Px[:po_italics_o]}\\1#{Px[:po_italics_c]}") - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, - "#{Px[:po_underscore_o]}\\1#{Px[:po_underscore_c]}") - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, - "#{Px[:po_subscript_o]}\\1#{Px[:po_subscript_c]}") - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, - "#{Px[:po_superscript_o]}\\1#{Px[:po_superscript_c]}") - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, - "#{Px[:po_insert_o]}\\1#{Px[:po_insert_c]}") - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, - "#{Px[:po_cite_o]}\\1#{Px[:po_cite_c]}") - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, - "#{Px[:po_strike_o]}\\1#{Px[:po_strike_c]}") - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, - "#{Px[:po_monospace_o]}\\1#{Px[:po_monospace_c]}") + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, + "#{Px[:po_bold_o]}\\1#{Px[:po_bold_c]}"). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, + "#{Px[:po_italics_o]}\\1#{Px[:po_italics_c]}"). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, + "#{Px[:po_underscore_o]}\\1#{Px[:po_underscore_c]}"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, + "#{Px[:po_subscript_o]}\\1#{Px[:po_subscript_c]}"). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, + "#{Px[:po_superscript_o]}\\1#{Px[:po_superscript_c]}"). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, + "#{Px[:po_insert_o]}\\1#{Px[:po_insert_c]}"). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, + "#{Px[:po_cite_o]}\\1#{Px[:po_cite_c]}"). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, + "#{Px[:po_strike_o]}\\1#{Px[:po_strike_c]}"). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, + "#{Px[:po_monospace_o]}\\1#{Px[:po_monospace_c]}") notes='' unless dob.is=='code' - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]') - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1') + dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]'). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1') #dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{@brace_url.txt_open}\\1#{@brace_url.txt_close}") notes=extract_endnotes(dob) #% ### footnotes current state - extracted - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^') # endnote marker marked up + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^'). # endnote marker marked up #% ### footnotes current state - keep inline #dob.obj.gsub!(/#{Mx[:en_a_o]}[\d]+\s+(.+?)#{Mx[:en_a_c]}/,'~{ \1 }~') # inline endnote with marker marked up - dob.obj.gsub!(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/,'~[ \1 ]~') # inline endnote with marker marked up - dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,'~{\1 \2 }~') # inline endnote with marker marked up - dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/,'~[\1 \2 ]~') # inline endnote with marker marked up - dob.obj.gsub!(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<') - dob.obj.gsub!(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>') - dob.obj.gsub!(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&') - dob.obj.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - dob.obj.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - dob.obj.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - dob.obj.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') - dob.obj.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - dob.obj.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - dob.obj.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - dob.obj.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - dob.obj.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - dob.obj.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') + gsub(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/,'~[ \1 ]~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,'~{\1 \2 }~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/,'~[\1 \2 ]~'). # inline endnote with marker marked up + gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). + gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>'). + gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&'). + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') end - if dob.of=='block' # watch - dob.obj.gsub!(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* ") - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") - else dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") + dob.obj=if dob.of=='block' # watch + dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* "). + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") + else dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") end if dob.is=='code' - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _> _< - dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _<_< + dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< + gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< end - dob.obj.gsub!(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,'') # remove page breaks - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') - dob.obj.gsub!(/
(.+?)<\/a>/m,'\1') - dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') # remove name links - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') # decide on - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]") - dob.obj.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') + dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,''). # remove page breaks + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/(.+?)<\/a>/m,'\1'). + gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links + gsub(/ |#{Mx[:nbsp]}/,' '). # decide on + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') [dob,notes] end def publish(fn,pot) @@ -934,8 +936,8 @@ GSUB and para.length > 0 para.each do |line| if line - line.gsub!(/\s+$/m,'') - line.gsub!(/^\A[ ]*\Z/m,'') + line=line.gsub(/\s+$/m,''). + gsub(/^\A[ ]*\Z/m,'') if line=~/^\A[ ]*\Z/m emptyline+=1 else emptyline=0 diff --git a/lib/sisu/v3dv/po4a_set.rb b/lib/sisu/v3dv/po4a_set.rb index e536a464..6335fb8c 100644 --- a/lib/sisu/v3dv/po4a_set.rb +++ b/lib/sisu/v3dv/po4a_set.rb @@ -76,8 +76,8 @@ module SiSU_Po4aUtils out=[] out[line]='' @oldword='' #REMOVE @oldword - pa.gsub!(/
/,'
') - pa.gsub!(/#{Mx[:br_nl]}/,"\n\n") + pa=pa.gsub(/
/,'
'). + gsub(/#{Mx[:br_nl]}/,"\n\n") words=pa.scan(/\n\n|
|\S+/m) while words != '' word=words.shift @@ -109,7 +109,7 @@ module SiSU_Po4aUtils x=out.join(spaces_indent).gsub(/\A\n+/m,'').insert(0,spaces_hang) z=[] x.split(/\n/).each do |y| - y.gsub!(/"/,'\"') + y=y.gsub(/"/,'\"') y=%{"#{y}"} z << y end @@ -134,7 +134,7 @@ WOK pot_array.each do |pa| z=[] pa.split(/\n\n/).each do |y| - y.gsub!(/"/,'\"') + y=y.gsub(/"/,'\"') y=%{"#{y}"} z << y if not y.empty? end diff --git a/lib/sisu/v3dv/qrcode.rb b/lib/sisu/v3dv/qrcode.rb index b25504b0..49ef8ee3 100644 --- a/lib/sisu/v3dv/qrcode.rb +++ b/lib/sisu/v3dv/qrcode.rb @@ -215,7 +215,7 @@ WOK # "#{url}/sisu_manifest.#{lc}.html" #end manifests - @m.uniq! + @m=@m.uniq @m end def languages(id,file) @@ -232,11 +232,11 @@ WOK end end def metadata(id,info) - info.to_s.gsub!(/#{Mx[:br_line]}/,"\n") + info=info.to_s.gsub(/#{Mx[:br_line]}/,"\n") @manifest[:txt] << %{#{id}: #{info}\n} end def md_title_info(id,info) - info.to_s.gsub!(/#{Mx[:br_line]}/,"\n") + info=info.to_s.gsub(/#{Mx[:br_line]}/,"\n") @manifest[:txt_title] << %{#{info}\n} end def links(url,lnk,target) diff --git a/lib/sisu/v3dv/remote.rb b/lib/sisu/v3dv/remote.rb index 39e929cc..4004e5f8 100644 --- a/lib/sisu/v3dv/remote.rb +++ b/lib/sisu/v3dv/remote.rb @@ -143,10 +143,9 @@ module SiSU_Remote end if images \ and images.length > 1 - images.flatten! - images.uniq! + images=images.flatten.uniq images.delete_if {|x| x =~/https?:\/\// } - images.sort! + images=images.sort @msg,@msgs='downloading images:', [ images.join(',') ] @tell.call.warn unless @opt.cmd =~/q/ image_info=image_download_url + images diff --git a/lib/sisu/v3dv/shared_html_lite.rb b/lib/sisu/v3dv/shared_html_lite.rb index 5fd0a408..94413c69 100644 --- a/lib/sisu/v3dv/shared_html_lite.rb +++ b/lib/sisu/v3dv/shared_html_lite.rb @@ -109,16 +109,16 @@ module SiSU_FormatShared %{
[#{png}]#{caption}} else %{[#{png}] #{caption}} end - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else u=case u when /^https?:\/\// u when /^:/ - u.gsub!(/^:/,'') + u=u.gsub(/^:/,'') "#{@env.url.root}/#{u}" when /^\.\.\// # can remove - u.gsub!(/^\.\.\//,'') + u=u.gsub(/^\.\.\//,'') "#{@env.url.root}/#{u}" else "#{@env.url.root}/#{@md.fnb}/#{map_nametags[u][:segname]}#{Sfx[:html]}##{u}" @@ -127,8 +127,8 @@ module SiSU_FormatShared png=m.scan(/\S+/)[0].strip link=link.strip ins=%{#{link}} - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins) - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins). + gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) word end word @@ -140,32 +140,32 @@ module SiSU_FormatShared end def markup_generic(s) s=s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') - s=s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') - s=s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - s=s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"') - s=s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+') - s=s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-') - s=s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1') - s=s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1') - s=s.gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1') # tt, kbd - s=s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') end def markup_object(t_o) s=t_o.obj - if t_o.is !='code' + s=if t_o.is !='code' s=markup_generic(s) if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)|\S+/) words=urls(wm) - s.gsub!(/.+/m,words) + s=s.gsub(/.+/m,words) end - s.gsub!(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - s.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - s.gsub!(/#{Mx[:url_o]}[_\\](\S+?)#{Mx[:url_c]}/,'\1') #http ftp matches escaped, no decoration - s.gsub!(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1\2') #special case \{ e.g. \}http://url - s.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{\\1#{@brace_url.xml_open}\\2#{@brace_url.xml_close}\\3}) #http ftp matches with decoration + s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:url_o]}[_\\](\S+?)#{Mx[:url_c]}/,'\1'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1\2'). #special case \{ e.g. \}http://url + gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{\\1#{@brace_url.xml_open}\\2#{@brace_url.xml_close}\\3}) #http ftp matches with decoration else - s.gsub!(//m,'>') + s.gsub(//m,'>') end s end @@ -176,11 +176,11 @@ module SiSU_FormatShared words=urls(wm) s=s.gsub(/.+/m,words) end - s=s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - s=s.gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - s=s.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1\2') #http ftp matches escaped, no decoration - s=s.gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1\2') #special case \{ e.g. \}http://url - s=s.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration + s=s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1\2'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1\2'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration end def paragraph %{

#{@txt}

\n} # << "\n" @@ -252,39 +252,39 @@ GSUB @txt.split(/\n/).each do |parablock| m=parablock[//,1] @@tablefoot << m if m - parablock.gsub!(//,'') + parablock=parablock.gsub(//,'') @@tablehead=1 if parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u - parablock.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+)#{Mx[:gr_c]}/, - %{

#{id}:

#{info}

}) + parablock=parablock.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+)#{Mx[:gr_c]}/, + %{
}) if parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ tablefoot=[] @@tablefoot.each {|x| tablefoot << %{

#{x}

\n}} @@tablefoot=[] - parablock.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/, + parablock=parablock.gsub(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/, %{#{@vz.table_close}\n}) # + end if @@tablehead==1 if parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u - parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{\n} + - %{\n') + parablock=parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{\n} + + %{\n') @@tablehead=0 end parablock else - parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{\n} + - %{\n') + parablock=parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{\n} + + %{\n') parablock end @new_content << parablock diff --git a/lib/sisu/v3dv/shared_markup_alt.rb b/lib/sisu/v3dv/shared_markup_alt.rb index 27092050..9719dd3e 100644 --- a/lib/sisu/v3dv/shared_markup_alt.rb +++ b/lib/sisu/v3dv/shared_markup_alt.rb @@ -68,61 +68,61 @@ module SiSU_TextRepresentation def strip_clean_of_extra_spaces # dal output tuned @s=@s.dup @s=@s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless @s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ - @s=@s.gsub(/ [ ]+/,' ') - @s=@s.gsub(/^ [ ]+/,'') - @s=@s.gsub(/ [ ]+$/,'') - @s=@s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') - @s=@s.gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') + @s=@s.gsub(/ [ ]+/,' '). + gsub(/^ [ ]+/,''). + gsub(/ [ ]+$/,''). + gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2'). + gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') end def strip_clean_of_markup # text form used in sql db search, used for digest, define rules, make same as in db clean @s=@s.dup #% same as db clean --> - @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]') - @s=@s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_hilite_o]}(.+?)#{Mx[:fa_hilite_c]}/,'\1') - @s=@s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - @s=@s.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'') # endnote removed - @s=@s.gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'') # endnote removed - @s=@s.gsub(/(?:#{Mx[:nbsp]})+/,' ') - @s=@s.gsub(/(?:#{Mx[:br_nl]})+/,"\n") - @s=@s.gsub(/(?:#{Mx[:br_paragraph]})+/,"\n") - @s=@s.gsub(/(?:#{Mx[:br_line]})+/,"\n") - @s=@s.gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<') - @s=@s.gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>') - @s=@s.gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&') - @s=@s.gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - @s=@s.gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - @s=@s.gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - @s=@s.gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') - @s=@s.gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - @s=@s.gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - @s=@s.gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') - @s=@s.gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - @s=@s.gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') - @s=@s.gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') - @s=@s.gsub(/\s\s+/,' ') - @s=@s.gsub(/\s\s+/,' ') - @s=@s.strip + @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'\1'). + gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:fa_hilite_o]}(.+?)#{Mx[:fa_hilite_c]}/,'\1'). + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~'). + gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,''). # endnote removed + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,''). # endnote removed + gsub(/(?:#{Mx[:nbsp]})+/,' '). + gsub(/(?:#{Mx[:br_nl]})+/,"\n"). + gsub(/(?:#{Mx[:br_paragraph]})+/,"\n"). + gsub(/(?:#{Mx[:br_line]})+/,"\n"). + gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). + gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>'). + gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&'). + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©'). + gsub(/\s\s+/,' '). + gsub(/\s\s+/,' '). + strip end def semi_revert_markup # used for digest, define rules, make same as in db clean if @t_o - @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*{\1}*') - @s=@s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/{\1}/') - @s=@s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_{\1}_') - @s=@s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"{\1}"') - @s=@s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+') - @s=@s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-') - @s=@s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^{\1}^') - @s=@s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,',{\1},') - @s=@s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - @s=@s.gsub(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/,'~{\1}~') # endnote marker marked up - @s=@s.gsub(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/,'~[\1]~') # endnote marker marked up + @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*{\1}*'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/{\1}/'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_{\1}_'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"{\1}"'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^{\1}^'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,',{\1},'). + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~'). + gsub(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/,'~{\1}~'). # endnote marker marked up + gsub(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/,'~[\1]~') # endnote marker marked up if @t_o.is=='heading' or @t_o.is=='para' @s=@s.gsub(/ [ ]+/,' ') @s=@s.gsub(/(?:#{Mx[:nbsp]})+/,' ') @@ -153,28 +153,28 @@ module SiSU_TextRepresentation end def html_lite #test whether eventually can be used in db_import replacing shared_html_lite (search for SiSU_FormatShared) if @t_o - @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"') - @s=@s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+') - @s=@s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-') - @s=@s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1') - @s=@s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1') - @s=@s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') + @s=@s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') if @t_o.is !='code' if @s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ wm=@s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)|\S+/) words=urls(wm) @s=@s.gsub(/.+/m,words) end - @s=@s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - @s=@s.gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - @s=@s.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') #http ftp matches escaped, no decoration - @s=@s.gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1\2\3') #special case \{ e.g. \}http://url - @s=@s.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@url_brace.xml_open}\\1#{@url_brace.xml_close}}) #http ftp matches with decoration + @s=@s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1\2\3'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@url_brace.xml_open}\\1#{@url_brace.xml_close}}) #http ftp matches with decoration else - @s=@s.gsub(//m,'>') + @s=@s.gsub(//m,'>') end if @t_o.is=='paragraph' if @t_o.bullet_ diff --git a/lib/sisu/v3dv/shared_metadata.rb b/lib/sisu/v3dv/shared_metadata.rb index f3834059..56856116 100644 --- a/lib/sisu/v3dv/shared_metadata.rb +++ b/lib/sisu/v3dv/shared_metadata.rb @@ -434,7 +434,7 @@ module SiSU_Metadata @md.creator.author_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :author: ' + x else nil end @@ -446,7 +446,7 @@ module SiSU_Metadata @md.creator.contributor_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :contributor: ' + x else nil end @@ -458,7 +458,7 @@ module SiSU_Metadata @md.creator.illustrator_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :illustrator: ' + x else nil end @@ -470,7 +470,7 @@ module SiSU_Metadata @md.creator.photographer_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :photographer: ' + x else nil end @@ -482,7 +482,7 @@ module SiSU_Metadata @md.creator.translator_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :translator: ' + x else nil end @@ -494,7 +494,7 @@ module SiSU_Metadata @md.creator.audio_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :audio: ' + x else nil end @@ -506,7 +506,7 @@ module SiSU_Metadata @md.creator.digitized_by_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :digitized_by: ' + x else nil end @@ -518,7 +518,7 @@ module SiSU_Metadata @md.creator.prepared_by_detail.each do |n| x += "#{n[:the]}, #{n[:others]}; " end - x.gsub!(/;\s*$/,'') + x=x.gsub(/;\s*$/,'') ' :prepared_by: ' + x else nil end @@ -736,107 +736,107 @@ module SiSU_Metadata def utf8 if @s \ and @s.class==String - @s.gsub!(//u,Mx[:br_paragraph]) - @s.gsub!(//um,'>') # '>' # > - @s.gsub!(/¢/um,'¢') # '¢' # ¢ - @s.gsub!(/£/um,'£') # '£' # £ - @s.gsub!(/¥/um,'¥') # '¥' # ¥ - @s.gsub!(/§/um,'§') # '§' # § - @s.gsub!(/©/um,'©') # '©' # © - @s.gsub!(/ª/um,'ª') # 'ª' # ª - @s.gsub!(/«/um,'«') # '«' # « - @s.gsub!(/®/um,'®') # '®' # ® - @s.gsub!(/°/um,'°') # '°' # ° - @s.gsub!(/±/um,'±') # '±' # ± - @s.gsub!(/²/um,'²') # '²' # ² - @s.gsub!(/³/um,'³') # '³' # ³ - @s.gsub!(/µ/um,'µ') # 'µ' # µ - @s.gsub!(/¶/um,'¶') # '¶' # ¶ - @s.gsub!(/¹/um,'¹') # '¹' # ¹ - @s.gsub!(/º/um,'º') # 'º' # º - @s.gsub!(/»/um,'»') # '»' # » - @s.gsub!(/¼/um,'¼') # '¼' # ¼ - @s.gsub!(/½/um,'½') # '½' # ½ - @s.gsub!(/¾/um,'¾') # '¾' # ¾ - @s.gsub!(/×/um,'×') # '×' # × - @s.gsub!(/÷/um,'÷') # '÷' # ÷ - @s.gsub!(/¿/um,'¿') # '¿' # ¿ - @s.gsub!(/À/um,'À') # 'À' # À - @s.gsub!(/Á/um,'Á') # 'Á' # Á - @s.gsub!(/Â/um,'Â') # 'Â' # Â - @s.gsub!(/Ã/um,'Ã') # 'Ã' # Ã - @s.gsub!(/Ä/um,'Ä') # 'Ä' # Ä - @s.gsub!(/Å/um,'Å') # 'Å' # Å - @s.gsub!(/Æ/um,'Æ') # 'Æ' # Æ - @s.gsub!(/Ç/um,'Ç') # 'Ç' # Ç - @s.gsub!(/È/um,'È') # 'È' # È - @s.gsub!(/É/um,'É') # 'É' # É - @s.gsub!(/Ê/um,'Ê') # 'Ê' # Ê - @s.gsub!(/Ë/um,'Ë') # 'Ë' # Ë - @s.gsub!(/Ì/um,'Ì') # 'Ì' # Ì - @s.gsub!(/Í/um,'Í') # 'Í' # Í - @s.gsub!(/Î/um,'Î') # 'Î' # Î - @s.gsub!(/Ï/um,'Ï') # 'Ï' # Ï - @s.gsub!(/Ð/um,'Ð') # 'Ð' # Ð - @s.gsub!(/Ñ/um,'Ñ') # 'Ñ' # Ñ - @s.gsub!(/Ò/um,'Ò') # 'Ò' # Ò - @s.gsub!(/Ó/um,'Ó') # 'Ó' # Ó - @s.gsub!(/Ô/um,'Ô') # 'Ô' # Ô - @s.gsub!(/Õ/um,'Õ') # 'Õ' # Õ - @s.gsub!(/Ö/um,'Ö') # 'Ö' # Ö - @s.gsub!(/Ø/um,'Ø') # 'Ø' # Ø - @s.gsub!(/Ù/um,'Ù') # 'Ù' # Ù - @s.gsub!(/Ú/um,'Ú') # 'Ú' # Ú - @s.gsub!(/Û/um,'Û') # 'Û' # Û - @s.gsub!(/Ü/um,'Ü') # 'Ü' # Ü - @s.gsub!(/Ý/um,'Ý') # 'Ý' # Ý - @s.gsub!(/Þ/um,'Þ') # 'Þ' # Þ - @s.gsub!(/ß/um,'ß') # 'ß' # ß - @s.gsub!(/à/um,'à') # 'à' # à - @s.gsub!(/á/um,'á') # 'á' # á - @s.gsub!(/â/um,'â') # 'â' # â - @s.gsub!(/ã/um,'ã') # 'ã' # ã - @s.gsub!(/ä/um,'ä') # 'ä' # ä - @s.gsub!(/å/um,'å') # 'å' # å - @s.gsub!(/æ/um,'æ') # 'æ' # æ - @s.gsub!(/ç/um,'ç') # 'ç' # ç - @s.gsub!(/è/um,'è') # 'è' # è - @s.gsub!(/é/um,'é') # '´' # é - @s.gsub!(/ê/um,'ê') # 'ˆ' # ê - @s.gsub!(/ë/um,'ë') # 'ë' # ë - @s.gsub!(/ì/um,'ì') # 'ì' # ì - @s.gsub!(/í/um,'í') # '´' # í - @s.gsub!(/î/um,'î') # 'î' # î - @s.gsub!(/ï/um,'ï') # 'ï' # ï - @s.gsub!(/ð/um,'ð') # 'ð' # ð - @s.gsub!(/ñ/um,'ñ') # 'ñ' # ñ - @s.gsub!(/ò/um,'ò') # 'ò' # ò - @s.gsub!(/ó/um,'ó') # 'ó' # ó - @s.gsub!(/ô/um,'ô') # 'ô' # ô - @s.gsub!(/õ/um,'õ') # 'õ' # õ - @s.gsub!(/ö/um,'ö') # 'ö' # ö - @s.gsub!(/ø/um,'ø') # 'ø' # ø - @s.gsub!(/ù/um,'ú') # 'ù' # ú - @s.gsub!(/ú/um,'û') # 'ú' # û - @s.gsub!(/û/um,'ü') # 'û' # ü - @s.gsub!(/ü/um,'ý') # 'ü' # ý - @s.gsub!(/þ/um,'þ') # 'þ' # þ - @s.gsub!(/ÿ/um,'ÿ') # 'ÿ' # ÿ - @s.gsub!(/‘/um,'‘') # '‘' # ‘ - @s.gsub!(/’/um,'’') # '’' # ’ - @s.gsub!(/“/um,'“') # “ # “ - @s.gsub!(/”/um,'”') # ” # ” - @s.gsub!(/–/um,'–') # – # – - @s.gsub!(/—/um,'—') # — # — - @s.gsub!(/∝/um,'∝') # ∝ # ∝ - @s.gsub!(/∞/um,'∞') # ∞ # ∞ - @s.gsub!(/™/um,'™') # ™ # ™ - @s.gsub!(/✠/um,'✠') # ✗ # ✠ - @s.gsub!(/ /um,' ') # space identify - @s.gsub!(/ /um,' ') # space identify - @s.gsub!(/#{Mx[:br_paragraph]}/u,'
') + @s=@s.gsub(//u,Mx[:br_paragraph]). + gsub(//um,'>'). # '>' # > + gsub(/¢/um,'¢'). # '¢' # ¢ + gsub(/£/um,'£'). # '£' # £ + gsub(/¥/um,'¥'). # '¥' # ¥ + gsub(/§/um,'§'). # '§' # § + gsub(/©/um,'©'). # '©' # © + gsub(/ª/um,'ª'). # 'ª' # ª + gsub(/«/um,'«'). # '«' # « + gsub(/®/um,'®'). # '®' # ® + gsub(/°/um,'°'). # '°' # ° + gsub(/±/um,'±'). # '±' # ± + gsub(/²/um,'²'). # '²' # ² + gsub(/³/um,'³'). # '³' # ³ + gsub(/µ/um,'µ'). # 'µ' # µ + gsub(/¶/um,'¶'). # '¶' # ¶ + gsub(/¹/um,'¹'). # '¹' # ¹ + gsub(/º/um,'º'). # 'º' # º + gsub(/»/um,'»'). # '»' # » + gsub(/¼/um,'¼'). # '¼' # ¼ + gsub(/½/um,'½'). # '½' # ½ + gsub(/¾/um,'¾'). # '¾' # ¾ + gsub(/×/um,'×'). # '×' # × + gsub(/÷/um,'÷'). # '÷' # ÷ + gsub(/¿/um,'¿'). # '¿' # ¿ + gsub(/À/um,'À'). # 'À' # À + gsub(/Á/um,'Á'). # 'Á' # Á + gsub(/Â/um,'Â'). # 'Â' # Â + gsub(/Ã/um,'Ã'). # 'Ã' # Ã + gsub(/Ä/um,'Ä'). # 'Ä' # Ä + gsub(/Å/um,'Å'). # 'Å' # Å + gsub(/Æ/um,'Æ'). # 'Æ' # Æ + gsub(/Ç/um,'Ç'). # 'Ç' # Ç + gsub(/È/um,'È'). # 'È' # È + gsub(/É/um,'É'). # 'É' # É + gsub(/Ê/um,'Ê'). # 'Ê' # Ê + gsub(/Ë/um,'Ë'). # 'Ë' # Ë + gsub(/Ì/um,'Ì'). # 'Ì' # Ì + gsub(/Í/um,'Í'). # 'Í' # Í + gsub(/Î/um,'Î'). # 'Î' # Î + gsub(/Ï/um,'Ï'). # 'Ï' # Ï + gsub(/Ð/um,'Ð'). # 'Ð' # Ð + gsub(/Ñ/um,'Ñ'). # 'Ñ' # Ñ + gsub(/Ò/um,'Ò'). # 'Ò' # Ò + gsub(/Ó/um,'Ó'). # 'Ó' # Ó + gsub(/Ô/um,'Ô'). # 'Ô' # Ô + gsub(/Õ/um,'Õ'). # 'Õ' # Õ + gsub(/Ö/um,'Ö'). # 'Ö' # Ö + gsub(/Ø/um,'Ø'). # 'Ø' # Ø + gsub(/Ù/um,'Ù'). # 'Ù' # Ù + gsub(/Ú/um,'Ú'). # 'Ú' # Ú + gsub(/Û/um,'Û'). # 'Û' # Û + gsub(/Ü/um,'Ü'). # 'Ü' # Ü + gsub(/Ý/um,'Ý'). # 'Ý' # Ý + gsub(/Þ/um,'Þ'). # 'Þ' # Þ + gsub(/ß/um,'ß'). # 'ß' # ß + gsub(/à/um,'à'). # 'à' # à + gsub(/á/um,'á'). # 'á' # á + gsub(/â/um,'â'). # 'â' # â + gsub(/ã/um,'ã'). # 'ã' # ã + gsub(/ä/um,'ä'). # 'ä' # ä + gsub(/å/um,'å'). # 'å' # å + gsub(/æ/um,'æ'). # 'æ' # æ + gsub(/ç/um,'ç'). # 'ç' # ç + gsub(/è/um,'è'). # 'è' # è + gsub(/é/um,'é'). # '´' # é + gsub(/ê/um,'ê'). # 'ˆ' # ê + gsub(/ë/um,'ë'). # 'ë' # ë + gsub(/ì/um,'ì'). # 'ì' # ì + gsub(/í/um,'í'). # '´' # í + gsub(/î/um,'î'). # 'î' # î + gsub(/ï/um,'ï'). # 'ï' # ï + gsub(/ð/um,'ð'). # 'ð' # ð + gsub(/ñ/um,'ñ'). # 'ñ' # ñ + gsub(/ò/um,'ò'). # 'ò' # ò + gsub(/ó/um,'ó'). # 'ó' # ó + gsub(/ô/um,'ô'). # 'ô' # ô + gsub(/õ/um,'õ'). # 'õ' # õ + gsub(/ö/um,'ö'). # 'ö' # ö + gsub(/ø/um,'ø'). # 'ø' # ø + gsub(/ù/um,'ú'). # 'ù' # ú + gsub(/ú/um,'û'). # 'ú' # û + gsub(/û/um,'ü'). # 'û' # ü + gsub(/ü/um,'ý'). # 'ü' # ý + gsub(/þ/um,'þ'). # 'þ' # þ + gsub(/ÿ/um,'ÿ'). # 'ÿ' # ÿ + gsub(/‘/um,'‘'). # '‘' # ‘ + gsub(/’/um,'’'). # '’' # ’ + gsub(/“/um,'“'). # “ # “ + gsub(/”/um,'”'). # ” # ” + gsub(/–/um,'–'). # – # – + gsub(/—/um,'—'). # — # — + gsub(/∝/um,'∝'). # ∝ # ∝ + gsub(/∞/um,'∞'). # ∞ # ∞ + gsub(/™/um,'™'). # ™ # ™ + gsub(/✠/um,'✠'). # ✗ # ✠ + gsub(/ /um,' '). # space identify + gsub(/ /um,' '). # space identify + gsub(/#{Mx[:br_paragraph]}/u,'
') end @s end @@ -910,32 +910,32 @@ WOK def meta_para url_brace=SiSU_Viz::Skin.new.url_decoration if @inf.class==String - @inf.gsub!(//,'>') - @inf.gsub!(/<br(?: \/)?>/,'
') + @inf=@inf.gsub(//,'>'). + gsub(/<br(?: \/)?>/,'
') if @inf =~/&/ inf_array=[] word=@inf.scan(/\S+|\n/) word.each do |w| # _ - / # | : ! ^ ~ - w.gsub!(/ /,' ') + w=w.gsub(/ /,' ') if w !~/&\S{2,7}?;/ - w.gsub!(/&/,'&') + w=w.gsub(/&/,'&') end inf_array << w end @inf=inf_array.join(' ') end - @inf.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '\1') #http ftp matches escaped, no decoration - @inf.gsub!(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - '\1\2') #special case \{ e.g. \}http://url - if @inf =~/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/ - @inf.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + @inf=@inf.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '\1'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + '\1\2') #special case \{ e.g. \}http://url + @inf=if @inf =~/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/ + @inf.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{url_brace.xml_open}\\1#{url_brace.xml_close}}) #http ftp matches with decoration else - @inf.gsub!(/(https?:\/\/[^<>()'"\s]+)/, + @inf.gsub(/(https?:\/\/[^<>()'"\s]+)/, %{#{url_brace.xml_open}\\1#{url_brace.xml_close}}) #http ftp matches with decoration end - @inf.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, + @inf=@inf.gsub(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, %{#{url_brace.xml_open}\\1#{url_brace.xml_close}}) if @inf !~/http:\/\// # improve upon, document crash where url contains '@' symbol end </,'
') - @para.gsub!(/#{Mx[:br_nl]}/,"\n\n") + @para=@para.gsub(/
/,'
'). + gsub(/#{Mx[:br_nl]}/,"\n\n") words=@para.scan(/\n\n|
|\S+/m) while words != '' word=words.shift diff --git a/lib/sisu/v3dv/shared_xml.rb b/lib/sisu/v3dv/shared_xml.rb index 78611ccc..dbaed6d8 100644 --- a/lib/sisu/v3dv/shared_xml.rb +++ b/lib/sisu/v3dv/shared_xml.rb @@ -116,399 +116,404 @@ module SiSU_XML_Munge if str #¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü #¢£¥§©ª«®°±²³µ¶¹º»¼½¾×÷ - str.gsub!(//um,'>') # '>' # > - str.gsub!(/¢/um,'¢') # '¢' # ¢ - str.gsub!(/£/um,'£') # '£' # £ - str.gsub!(/¥/um,'¥') # '¥' # ¥ - str.gsub!(/§/um,'§') # '§' # § - str.gsub!(/©/um,'©') # '©' # © - str.gsub!(/ª/um,'ª') # 'ª' # ª - str.gsub!(/«/um,'«') # '«' # « - str.gsub!(/®/um,'®') # '®' # ® - str.gsub!(/°/um,'°') # '°' # ° - str.gsub!(/±/um,'±') # '±' # ± - str.gsub!(/²/um,'²') # '²' # ² - str.gsub!(/³/um,'³') # '³' # ³ - str.gsub!(/µ/um,'µ') # 'µ' # µ - str.gsub!(/¶/um,'¶') # '¶' # ¶ - str.gsub!(/¹/um,'¹') # '¹' # ¹ - str.gsub!(/º/um,'º') # 'º' # º - str.gsub!(/»/um,'»') # '»' # » - str.gsub!(/¼/um,'¼') # '¼' # ¼ - str.gsub!(/½/um,'½') # '½' # ½ - str.gsub!(/¾/um,'¾') # '¾' # ¾ - str.gsub!(/×/um,'×') # '×' # × - str.gsub!(/÷/um,'÷') # '÷' # ÷ - str.gsub!(/¿/um,'¿') # '¿' # ¿ - str.gsub!(/À/um,'À') # 'À' # À - str.gsub!(/Á/um,'Á') # 'Á' # Á - str.gsub!(/Â/um,'Â') # 'Â' #  - str.gsub!(/Ã/um,'Ã') # 'Ã' # à - str.gsub!(/Ä/um,'Ä') # 'Ä' # Ä - str.gsub!(/Å/um,'Å') # 'Å' # Å - str.gsub!(/Æ/um,'Æ') # 'Æ' # Æ - str.gsub!(/Ç/um,'Ç') # 'Ç' # Ç - str.gsub!(/È/um,'È') # 'È' # È - str.gsub!(/É/um,'É') # 'É' # É - str.gsub!(/Ê/um,'Ê') # 'Ê' # Ê - str.gsub!(/Ë/um,'Ë') # 'Ë' # Ë - str.gsub!(/Ì/um,'Ì') # 'Ì' # Ì - str.gsub!(/Í/um,'Í') # 'Í' # Í - str.gsub!(/Î/um,'Î') # 'Î' # Î - str.gsub!(/Ï/um,'Ï') # 'Ï' # Ï - str.gsub!(/Ð/um,'Ð') # 'Ð' # Ð - str.gsub!(/Ñ/um,'Ñ') # 'Ñ' # Ñ - str.gsub!(/Ò/um,'Ò') # 'Ò' # Ò - str.gsub!(/Ó/um,'Ó') # 'Ó' # Ó - str.gsub!(/Ô/um,'Ô') # 'Ô' # Ô - str.gsub!(/Õ/um,'Õ') # 'Õ' # Õ - str.gsub!(/Ö/um,'Ö') # 'Ö' # Ö - str.gsub!(/Ø/um,'Ø') # 'Ø' # Ø - str.gsub!(/Ù/um,'Ù') # 'Ù' # Ù - str.gsub!(/Ú/um,'Ú') # 'Ú' # Ú - str.gsub!(/Û/um,'Û') # 'Û' # Û - str.gsub!(/Ü/um,'Ü') # 'Ü' # Ü - str.gsub!(/Ý/um,'Ý') # 'Ý' # Ý - str.gsub!(/Þ/um,'Þ') # 'Þ' # Þ - str.gsub!(/ß/um,'ß') # 'ß' # ß - str.gsub!(/à/um,'à') # 'à' # à - str.gsub!(/á/um,'á') # 'á' # á - str.gsub!(/â/um,'â') # 'â' # â - str.gsub!(/ã/um,'ã') # 'ã' # ã - str.gsub!(/ä/um,'ä') # 'ä' # ä - str.gsub!(/å/um,'å') # 'å' # å - str.gsub!(/æ/um,'æ') # 'æ' # æ - str.gsub!(/ç/um,'ç') # 'ç' # ç - str.gsub!(/è/um,'è') # 'è' # è - str.gsub!(/é/um,'é') # '´' # é - str.gsub!(/ê/um,'ê') # 'ˆ' # ê - str.gsub!(/ë/um,'ë') # 'ë' # ë - str.gsub!(/ì/um,'ì') # 'ì' # ì - str.gsub!(/í/um,'í') # '´' # í - str.gsub!(/î/um,'î') # 'î' # î - str.gsub!(/ï/um,'ï') # 'ï' # ï - str.gsub!(/ð/um,'ð') # 'ð' # ð - str.gsub!(/ñ/um,'ñ') # 'ñ' # ñ - str.gsub!(/ò/um,'ò') # 'ò' # ò - str.gsub!(/ó/um,'ó') # 'ó' # ó - str.gsub!(/ô/um,'ô') # 'ô' # ô - str.gsub!(/õ/um,'õ') # 'õ' # õ - str.gsub!(/ö/um,'ö') # 'ö' # ö - str.gsub!(/ø/um,'ø') # 'ø' # ø - str.gsub!(/ù/um,'ú') # 'ù' # ú - str.gsub!(/ú/um,'û') # 'ú' # û - str.gsub!(/û/um,'ü') # 'û' # ü - str.gsub!(/ü/um,'ý') # 'ü' # ý - str.gsub!(/þ/um,'þ') # 'þ' # þ - str.gsub!(/ÿ/um,'ÿ') # 'ÿ' # ÿ - str.gsub!(/‘/um,'‘') # '‘' # ‘ - str.gsub!(/’/um,'’') # '’' # ’ - str.gsub!(/“/um,'“') # “ # “ - str.gsub!(/”/um,'”') # ” # ” - str.gsub!(/–/um,'–') # – # – - str.gsub!(/—/um,'—') # — # — - str.gsub!(/∝/um,'∝') # ∝ # ∝ - str.gsub!(/∞/um,'∞') # ∞ # ∞ - str.gsub!(/™/um,'™') # ™ # ™ - str.gsub!(/✠/um,'✠') # ✗ # ✠ - str.gsub!(/ /um,' ') # space identify - str.gsub!(/ /um,' ') # space identify + str=str.gsub(//um,'>'). # '>' # > + gsub(/¢/um,'¢'). # '¢' # ¢ + gsub(/£/um,'£'). # '£' # £ + gsub(/¥/um,'¥'). # '¥' # ¥ + gsub(/§/um,'§'). # '§' # § + gsub(/©/um,'©'). # '©' # © + gsub(/ª/um,'ª'). # 'ª' # ª + gsub(/«/um,'«'). # '«' # « + gsub(/®/um,'®'). # '®' # ® + gsub(/°/um,'°'). # '°' # ° + gsub(/±/um,'±'). # '±' # ± + gsub(/²/um,'²'). # '²' # ² + gsub(/³/um,'³'). # '³' # ³ + gsub(/µ/um,'µ'). # 'µ' # µ + gsub(/¶/um,'¶'). # '¶' # ¶ + gsub(/¹/um,'¹'). # '¹' # ¹ + gsub(/º/um,'º'). # 'º' # º + gsub(/»/um,'»'). # '»' # » + gsub(/¼/um,'¼'). # '¼' # ¼ + gsub(/½/um,'½'). # '½' # ½ + gsub(/¾/um,'¾'). # '¾' # ¾ + gsub(/×/um,'×'). # '×' # × + gsub(/÷/um,'÷'). # '÷' # ÷ + gsub(/¿/um,'¿'). # '¿' # ¿ + gsub(/À/um,'À'). # 'À' # À + gsub(/Á/um,'Á'). # 'Á' # Á + gsub(/Â/um,'Â'). # 'Â' #  + gsub(/Ã/um,'Ã'). # 'Ã' # à + gsub(/Ä/um,'Ä'). # 'Ä' # Ä + gsub(/Å/um,'Å'). # 'Å' # Å + gsub(/Æ/um,'Æ'). # 'Æ' # Æ + gsub(/Ç/um,'Ç'). # 'Ç' # Ç + gsub(/È/um,'È'). # 'È' # È + gsub(/É/um,'É'). # 'É' # É + gsub(/Ê/um,'Ê'). # 'Ê' # Ê + gsub(/Ë/um,'Ë'). # 'Ë' # Ë + gsub(/Ì/um,'Ì'). # 'Ì' # Ì + gsub(/Í/um,'Í'). # 'Í' # Í + gsub(/Î/um,'Î'). # 'Î' # Î + gsub(/Ï/um,'Ï'). # 'Ï' # Ï + gsub(/Ð/um,'Ð'). # 'Ð' # Ð + gsub(/Ñ/um,'Ñ'). # 'Ñ' # Ñ + gsub(/Ò/um,'Ò'). # 'Ò' # Ò + gsub(/Ó/um,'Ó'). # 'Ó' # Ó + gsub(/Ô/um,'Ô'). # 'Ô' # Ô + gsub(/Õ/um,'Õ'). # 'Õ' # Õ + gsub(/Ö/um,'Ö'). # 'Ö' # Ö + gsub(/Ø/um,'Ø'). # 'Ø' # Ø + gsub(/Ù/um,'Ù'). # 'Ù' # Ù + gsub(/Ú/um,'Ú'). # 'Ú' # Ú + gsub(/Û/um,'Û'). # 'Û' # Û + gsub(/Ü/um,'Ü'). # 'Ü' # Ü + gsub(/Ý/um,'Ý'). # 'Ý' # Ý + gsub(/Þ/um,'Þ'). # 'Þ' # Þ + gsub(/ß/um,'ß'). # 'ß' # ß + gsub(/à/um,'à'). # 'à' # à + gsub(/á/um,'á'). # 'á' # á + gsub(/â/um,'â'). # 'â' # â + gsub(/ã/um,'ã'). # 'ã' # ã + gsub(/ä/um,'ä'). # 'ä' # ä + gsub(/å/um,'å'). # 'å' # å + gsub(/æ/um,'æ'). # 'æ' # æ + gsub(/ç/um,'ç'). # 'ç' # ç + gsub(/è/um,'è'). # 'è' # è + gsub(/é/um,'é'). # '´' # é + gsub(/ê/um,'ê'). # 'ˆ' # ê + gsub(/ë/um,'ë'). # 'ë' # ë + gsub(/ì/um,'ì'). # 'ì' # ì + gsub(/í/um,'í'). # '´' # í + gsub(/î/um,'î'). # 'î' # î + gsub(/ï/um,'ï'). # 'ï' # ï + gsub(/ð/um,'ð'). # 'ð' # ð + gsub(/ñ/um,'ñ'). # 'ñ' # ñ + gsub(/ò/um,'ò'). # 'ò' # ò + gsub(/ó/um,'ó'). # 'ó' # ó + gsub(/ô/um,'ô'). # 'ô' # ô + gsub(/õ/um,'õ'). # 'õ' # õ + gsub(/ö/um,'ö'). # 'ö' # ö + gsub(/ø/um,'ø'). # 'ø' # ø + gsub(/ù/um,'ú'). # 'ù' # ú + gsub(/ú/um,'û'). # 'ú' # û + gsub(/û/um,'ü'). # 'û' # ü + gsub(/ü/um,'ý'). # 'ü' # ý + gsub(/þ/um,'þ'). # 'þ' # þ + gsub(/ÿ/um,'ÿ'). # 'ÿ' # ÿ + gsub(/‘/um,'‘'). # '‘' # ‘ + gsub(/’/um,'’'). # '’' # ’ + gsub(/“/um,'“'). # “ # “ + gsub(/”/um,'”'). # ” # ” + gsub(/–/um,'–'). # – # – + gsub(/—/um,'—'). # — # — + gsub(/∝/um,'∝'). # ∝ # ∝ + gsub(/∞/um,'∞'). # ∞ # ∞ + gsub(/™/um,'™'). # ™ # ™ + gsub(/✠/um,'✠'). # ✗ # ✠ + gsub(/ /um,' '). # space identify + gsub(/ /um,' ') # space identify end dob=if defined? dob.obj dob.obj=str dob - elsif dob.class==String; dob + elsif dob.class==String + str end dob end end def html(dob='') if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn - dob.obj.gsub!(/ /u,' ') # space identify - dob.obj.gsub!(/ /u,' ') # space identify + dob.obj=dob.obj.gsub(/ /u,' '). # space identify + gsub(/ /u,' ') # space identify else - dob.obj.gsub!(/¢/u,'¢') # ¢ - dob.obj.gsub!(/£/u,'£') # £ - dob.obj.gsub!(/¥/u,'¥') # ¥ - dob.obj.gsub!(/§/u,'§') # § - dob.obj.gsub!(/©/u,'©') # © - dob.obj.gsub!(/ª/u,'ª') # ª - dob.obj.gsub!(/«/u,'«') # « - dob.obj.gsub!(/®/u,'®') # ® - dob.obj.gsub!(/°/u,'°') # ° - dob.obj.gsub!(/±/u,'±') # ± - dob.obj.gsub!(/²/u,'²') # ² - dob.obj.gsub!(/³/u,'³') # ³ - dob.obj.gsub!(/µ/u,'µ') # µ - dob.obj.gsub!(/¶/u,'¶') # ¶ - dob.obj.gsub!(/¹/u,'¹') # ¹ - dob.obj.gsub!(/º/u,'º') # º - dob.obj.gsub!(/»/u,'»') # » - dob.obj.gsub!(/¼/u,'¼') # ¼ - dob.obj.gsub!(/½/u,'½') # ½ - dob.obj.gsub!(/¾/u,'¾') # ¾ - dob.obj.gsub!(/×/u,'×') # × - dob.obj.gsub!(/÷/u,'÷') # ÷ - dob.obj.gsub!(/¿/u,'¿') # ¿ - dob.obj.gsub!(/À/u,'À') # À - dob.obj.gsub!(/Á/u,'Á') # Á - dob.obj.gsub!(/Â/u,'Â') #  - dob.obj.gsub!(/Ã/u,'Ã') # à - dob.obj.gsub!(/Ä/u,'Ä') # Ä - dob.obj.gsub!(/Å/u,'Å') # Å - dob.obj.gsub!(/Æ/u,'Æ') # Æ - dob.obj.gsub!(/Ç/u,'Ç') # Ç - dob.obj.gsub!(/È/u,'È') # È - dob.obj.gsub!(/É/u,'É') # É - dob.obj.gsub!(/Ê/u,'Ê') # Ê - dob.obj.gsub!(/Ë/u,'Ë') # Ë - dob.obj.gsub!(/Ì/u,'Ì') # Ì - dob.obj.gsub!(/Í/u,'Í') # Í - dob.obj.gsub!(/Î/u,'Î') # Î - dob.obj.gsub!(/Ï/u,'Ï') # Ï - dob.obj.gsub!(/Ð/u,'Ð') # Ð - dob.obj.gsub!(/Ñ/u,'Ñ') # Ñ - dob.obj.gsub!(/Ò/u,'Ò') # Ò - dob.obj.gsub!(/Ó/u,'Ó') # Ó - dob.obj.gsub!(/Ô/u,'Ô') # Ô - dob.obj.gsub!(/Õ/u,'Õ') # Õ - dob.obj.gsub!(/Ö/u,'Ö') # Ö - dob.obj.gsub!(/Ø/u,'Ø') # Ø - dob.obj.gsub!(/Ù/u,'Ù') # Ù - dob.obj.gsub!(/Ú/u,'Ú') # Ú - dob.obj.gsub!(/Û/u,'Û') # Û - dob.obj.gsub!(/Ü/u,'Ü') # Ü - dob.obj.gsub!(/Ý/u,'Ý') # Ý - dob.obj.gsub!(/Þ/u,'Þ') # Þ - dob.obj.gsub!(/ß/u,'ß') # ß - dob.obj.gsub!(/à/u,'à') # à - dob.obj.gsub!(/á/u,'á') # á - dob.obj.gsub!(/â/u,'â') # â - dob.obj.gsub!(/ã/u,'ã') # ã - dob.obj.gsub!(/ä/u,'ä') # ä - dob.obj.gsub!(/å/u,'å') # å - dob.obj.gsub!(/æ/u,'æ') # æ - dob.obj.gsub!(/ç/u,'ç') # ç - dob.obj.gsub!(/è/u,'è') # è - dob.obj.gsub!(/é/u,'´') # é - dob.obj.gsub!(/ê/u,'ˆ') # ê - dob.obj.gsub!(/ë/u,'ë') # ë - dob.obj.gsub!(/ì/u,'ì') # ì - dob.obj.gsub!(/í/u,'´') # í - dob.obj.gsub!(/î/u,'î') # î - dob.obj.gsub!(/ï/u,'ï') # ï - dob.obj.gsub!(/ð/u,'ð') # ð - dob.obj.gsub!(/ñ/u,'ñ') # ñ - dob.obj.gsub!(/ò/u,'ò') # ò - dob.obj.gsub!(/ó/u,'ó') # ó - dob.obj.gsub!(/ô/u,'ô') # ô - dob.obj.gsub!(/õ/u,'õ') # õ - dob.obj.gsub!(/ö/u,'ö') # ö - dob.obj.gsub!(/ø/u,'ø') # ø - dob.obj.gsub!(/ù/u,'ù') # ú - dob.obj.gsub!(/ú/u,'ú') # û - dob.obj.gsub!(/û/u,'û') # ü - dob.obj.gsub!(/ü/u,'ü') # ý - dob.obj.gsub!(/þ/u,'þ') # þ - dob.obj.gsub!(/ÿ/u,'ÿ') # ÿ - dob.obj.gsub!(/‘/u,'&#lsquo;') # ‘ # ‘ - dob.obj.gsub!(/’/u,'&#rsquo;') # ’ # ’ - dob.obj.gsub!(/“/u,'“') # “ # “ - dob.obj.gsub!(/”/u,'”') # ” # ” - dob.obj.gsub!(/–/u,'–') # – # – - dob.obj.gsub!(/—/u,'—') # — # — - dob.obj.gsub!(/∝/u,'∝') # ∝ # ∝ - dob.obj.gsub!(/∞/u,'∞') # ∞ # ∞ - dob.obj.gsub!(/™/u,'™') # ™ # ™ - dob.obj.gsub!(/✠/u,'✠') # ✠ - #par.obja.gsub!(/✠/u '†') # † # † incorrect replacement † - dob.obj.gsub!(/ /u,' ') # space identify - dob.obj.gsub!(/ /u,' ') # space identify + dob.obj=dob.obj.gsub(/¢/u,'¢'). # ¢ + gsub(/£/u,'£'). # £ + gsub(/¥/u,'¥'). # ¥ + gsub(/§/u,'§'). # § + gsub(/©/u,'©'). # © + gsub(/ª/u,'ª'). # ª + gsub(/«/u,'«'). # « + gsub(/®/u,'®'). # ® + gsub(/°/u,'°'). # ° + gsub(/±/u,'±'). # ± + gsub(/²/u,'²'). # ² + gsub(/³/u,'³'). # ³ + gsub(/µ/u,'µ'). # µ + gsub(/¶/u,'¶'). # ¶ + gsub(/¹/u,'¹'). # ¹ + gsub(/º/u,'º'). # º + gsub(/»/u,'»'). # » + gsub(/¼/u,'¼'). # ¼ + gsub(/½/u,'½'). # ½ + gsub(/¾/u,'¾'). # ¾ + gsub(/×/u,'×'). # × + gsub(/÷/u,'÷'). # ÷ + gsub(/¿/u,'¿'). # ¿ + gsub(/À/u,'À'). # À + gsub(/Á/u,'Á'). # Á + gsub(/Â/u,'Â'). #  + gsub(/Ã/u,'Ã'). # à + gsub(/Ä/u,'Ä'). # Ä + gsub(/Å/u,'Å'). # Å + gsub(/Æ/u,'Æ'). # Æ + gsub(/Ç/u,'Ç'). # Ç + gsub(/È/u,'È'). # È + gsub(/É/u,'É'). # É + gsub(/Ê/u,'Ê'). # Ê + gsub(/Ë/u,'Ë'). # Ë + gsub(/Ì/u,'Ì'). # Ì + gsub(/Í/u,'Í'). # Í + gsub(/Î/u,'Î'). # Î + gsub(/Ï/u,'Ï'). # Ï + gsub(/Ð/u,'Ð'). # Ð + gsub(/Ñ/u,'Ñ'). # Ñ + gsub(/Ò/u,'Ò'). # Ò + gsub(/Ó/u,'Ó'). # Ó + gsub(/Ô/u,'Ô'). # Ô + gsub(/Õ/u,'Õ'). # Õ + gsub(/Ö/u,'Ö'). # Ö + gsub(/Ø/u,'Ø'). # Ø + gsub(/Ù/u,'Ù'). # Ù + gsub(/Ú/u,'Ú'). # Ú + gsub(/Û/u,'Û'). # Û + gsub(/Ü/u,'Ü'). # Ü + gsub(/Ý/u,'Ý'). # Ý + gsub(/Þ/u,'Þ'). # Þ + gsub(/ß/u,'ß'). # ß + gsub(/à/u,'à'). # à + gsub(/á/u,'á'). # á + gsub(/â/u,'â'). # â + gsub(/ã/u,'ã'). # ã + gsub(/ä/u,'ä'). # ä + gsub(/å/u,'å'). # å + gsub(/æ/u,'æ'). # æ + gsub(/ç/u,'ç'). # ç + gsub(/è/u,'è'). # è + gsub(/é/u,'´'). # é + gsub(/ê/u,'ˆ'). # ê + gsub(/ë/u,'ë'). # ë + gsub(/ì/u,'ì'). # ì + gsub(/í/u,'´'). # í + gsub(/î/u,'î'). # î + gsub(/ï/u,'ï'). # ï + gsub(/ð/u,'ð'). # ð + gsub(/ñ/u,'ñ'). # ñ + gsub(/ò/u,'ò'). # ò + gsub(/ó/u,'ó'). # ó + gsub(/ô/u,'ô'). # ô + gsub(/õ/u,'õ'). # õ + gsub(/ö/u,'ö'). # ö + gsub(/ø/u,'ø'). # ø + gsub(/ù/u,'ù'). # ú + gsub(/ú/u,'ú'). # û + gsub(/û/u,'û'). # ü + gsub(/ü/u,'ü'). # ý + gsub(/þ/u,'þ'). # þ + gsub(/ÿ/u,'ÿ'). # ÿ + gsub(/‘/u,'&#lsquo;'). # ‘ # ‘ + gsub(/’/u,'&#rsquo;'). # ’ # ’ + gsub(/“/u,'“'). # “ # “ + gsub(/”/u,'”'). # ” # ” + gsub(/–/u,'–'). # – # – + gsub(/—/u,'—'). # — # — + gsub(/∝/u,'∝'). # ∝ # ∝ + gsub(/∞/u,'∞'). # ∞ # ∞ + gsub(/™/u,'™'). # ™ # ™ + gsub(/✠/u,'✠'). # ✠ + #gsub(/✠/u '†'). # † # † incorrect replacement † + gsub(/ /u,' '). # space identify + gsub(/ /u,' ') # space identify end end self end def tidywords(wordlist) + wordlist_new=[] wordlist.each do |x| #imperfect solution will not catch all possible cases - x.gsub!(/&/,'&') unless x =~/&\S+;/ - x.gsub!(/&([A-Z])/,'&\1') + x=x.gsub(/&/,'&') unless x =~/&\S+;/ + x=x.gsub(/&([A-Z])/,'&\1') + wordlist_new << x end + wordlist_new end def markup(dob='') wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 dob.obj=tidywords(wordlist).join(' ').strip unless dob.is=='table' - dob.obj.gsub!(/#{Mx[:br_line]}/u,'
') - dob.obj.gsub!(/#{Mx[:br_paragraph]}/u,'
') - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') - end - dob.obj.gsub!(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') - 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[:gl_c]}|\s+)<\s+/,'\1< '); dob.obj.gsub!(/\s+>(\s+|$)/,' >\1') - #dob.obj.gsub!(/#{Mx[:fa_emphasis_o]}(.+?)#{Mx[:fa_emphasis_c]}/,'\1') #reinstate - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/m,'\1') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/m,'\1') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1') - dob.obj.gsub!(/<:pb>\s*/,'') #Fix - dob.obj.gsub!(/<+[-~]#>+/,'') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/u,'
'). + gsub(/#{Mx[:br_paragraph]}/u,'
'). + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') + end + dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,''). + gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;'). + gsub(/(^|#{Mx[:gl_c]}|\s+)<\s+/,'\1< ').gsub(/\s+>(\s+|$)/,' >\1'). + #gsub(/#{Mx[:fa_emphasis_o]}(.+?)#{Mx[:fa_emphasis_c]}/,'\1'). #reinstate + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/m,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/m,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). + gsub(/<:pb>\s*/,''). #Fix + gsub(/<+[-~]#>+/,'') if dob.is !~/^code/ #embeds a red-bullet image --> - dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1') - dob.obj.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is=='table' - dob.obj.gsub!(/#{Mx[:br_page]}\s*/,'') - dob.obj.gsub!(/#{Mx[:br_page_new]}\s*/,'') - dob.obj.gsub!(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,''); dob.obj.gsub!(/<[-~]#>/,'') - dob.obj.gsub!(/href="#{Xx[:segment]}/m,'href="') - dob.obj.gsub!(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\.\.\/\S+?)#{Mx[:rel_c]}/, - '\1') - dob.obj.gsub!(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/, - '\1') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/, - '\1') - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{[\\1] \\4}) - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{\\1}) - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/, - %{[\\1] \\4}) - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}image/, - %{\\1}) - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - '\1') #watch, compare html_tune - dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '\1') #escaped urls not linked, deal with later + dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1') + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is=='table' + dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*/,''). + gsub(/#{Mx[:br_page_new]}\s*/,''). + gsub(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,''). + gsub(/<[-~]#>/,''). + gsub(/href="#{Xx[:segment]}/m,'href="'). + gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\.\.\/\S+?)#{Mx[:rel_c]}/, + '\1'). + gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/, + '\1'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/, + '\1'). + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{[\\1] \\4}). + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{\\1}). + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/, + %{[\\1] \\4}). + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}image/, + %{\\1}). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + '\1'). #watch, compare html_tune + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '\1') #escaped urls not linked, deal with later else - dob.obj.gsub!(//m,'>') + dob.obj=dob.obj.gsub(//m,'>') end if dob.of=='block' - dob.obj.gsub!(/#{Mx[:gl_bullet]}/,'● ') + dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ') end - dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, - %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) - dob.obj.gsub!(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}") - dob.obj.gsub!(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}") - dob.obj.gsub!(/ |#{Mx[:nbsp]}/m,' ') + dob.obj=dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}). + gsub(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}"). + gsub(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}"). + gsub(/ |#{Mx[:nbsp]}/m,' ') dob end def markup_light(dob='') - dob.obj.gsub!(/\/\{(.+?)\}\//,'\1') - dob.obj.gsub!(/[*!]\{(.+?)\}[*!]/,'\1') - dob.obj.gsub!(/_\{(.+?)\}_/,'\1') - dob.obj.gsub!(/-\{(.+?)\}-/,'\1') - dob.obj.gsub!(//,'
') - dob.obj.gsub!(/<:pb>\s*/,'') - dob.obj.gsub!(/<[-~]#>/,'') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort - dob.obj.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax - dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, - "#{@md.file.output_path.xml.rel_image}\/\\1") - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') + dob.obj=dob.obj.gsub(/\/\{(.+?)\}\//,'\1'). + gsub(/[*!]\{(.+?)\}[*!]/,'\1'). + gsub(/_\{(.+?)\}_/,'\1'). + gsub(/-\{(.+?)\}-/,'\1'). + gsub(//,'
'). + gsub(/<:pb>\s*/,''). + gsub(/<[-~]#>/,''). + gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort + gsub(/&([^;]{1,5})/,'&\1'). #sort, rough estimate, revisit #WATCH found in node not sax + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, + "#{@md.file.output_path.xml.rel_image}\/\\1"). + gsub(/ |#{Mx[:nbsp]}/,' ') wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 dob.obj=tidywords(wordlist).join(' ').strip dob end def markup_fictionbook(dob='') - dob.obj.gsub!(/~\{([\d*+]+).+?\}~/,'[\1]') - dob.obj.gsub!(/\/\{(.+?)\}\//,'\1') - dob.obj.gsub!(/[*!]\{(.+?)\}[*!]/,'\1') - dob.obj.gsub!(/_\{(.+?)\}_/,'\1') - dob.obj.gsub!(/-\{(.+?)\}-/,'\1') - dob.obj.gsub!(//,'
') - dob.obj.gsub!(/<:pb>\s*/,'') - dob.obj.gsub!(/<[-~]#>/,'') - #temporary --> - dob.obj.gsub!(/<:\S+?>/,'') - #<-- temporary - dob.obj.gsub!(/<[-~]#>/,'') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort - dob.obj.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax - dob.obj.gsub!(/(#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, - "#{@md.file.output_path.xml.rel_image}\/\\1") - dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') + dob.obj.gsub(/~\{([\d*+]+).+?\}~/,'[\1]'). + gsub(/\/\{(.+?)\}\//,'\1'). + gsub(/[*!]\{(.+?)\}[*!]/,'\1'). + gsub(/_\{(.+?)\}_/,'\1'). + gsub(/-\{(.+?)\}-/,'\1'). + gsub(//,'
'). + gsub(/<:pb>\s*/,''). + gsub(/<[-~]#>/,''). + #temporary --> + gsub(/<:\S+?>/,''). + #<-- temporary + gsub(/<[-~]#>/,''). + gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort + gsub(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax + gsub(/(#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, + "#{@md.file.output_path.xml.rel_image}\/\\1"). + gsub(/ |#{Mx[:nbsp]}/,' ') wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 dob.obj=tidywords(wordlist).join(' ').strip dob end def markup_group(dob='') - dob.obj.gsub!(//,'>') - dob.obj.gsub!(/<:?br(?:\s+\/)?>/,'
') - dob.obj.gsub!(/<(link xmlns:xlink=".+?")>/,'<\1>') - dob.obj.gsub!(/<(\/link)>/,'<\1>') - dob.obj.gsub!(/<(\/?en)>/,'<\1>') + dob.obj=dob.obj.gsub(//,'>'). + gsub(/<:?br(?:\s+\/)?>/,'
'). + gsub(/<(link xmlns:xlink=".+?")>/,'<\1>'). + gsub(/<(\/link)>/,'<\1>'). + gsub(/<(\/?en)>/,'<\1>') dob end def markup_block(dob='') - dob.obj.gsub!(//,'>') - dob.obj.gsub!(/<:?br(?:\s+\/)?>/,'
') - dob.obj.gsub!(/<(link xmlns:xlink=".+?")>/,'<\1>') - dob.obj.gsub!(/<(\/link)>/,'<\1>') - dob.obj.gsub!(/<(\/?en)>/,'<\1>') + dob.obj=dob.obj.gsub(//,'>'). + gsub(/<:?br(?:\s+\/)?>/,'
'). + gsub(/<(link xmlns:xlink=".+?")>/,'<\1>'). + gsub(/<(\/link)>/,'<\1>'). + gsub(/<(\/?en)>/,'<\1>') dob end def xml_sem_block_paired(matched) # colon depth: many, recurs - matched.gsub!(/\b(au):\{(.+?)\}:\1\b/m, %{\\2}) - matched.gsub!(/\b(vol):\{(.+?)\}:\1\b/m, %{\\2}) - matched.gsub!(/\b(pub):\{(.+?)\}:\1\b/m, %{\\2}) - matched.gsub!(/\b(ref):\{(.+?)\}:\1\b/m, %{\\2}) - matched.gsub!(/\b(desc):\{(.+?)\}:\1\b/m,%{\\2}) - matched.gsub!(/\b(conv):\{(.+?)\}:\1\b/m,%{\\2}) - matched.gsub!(/\b(ct):\{(.+?)\}:\1\b/m, %{\\2}) - matched.gsub!(/\b(cty):\{(.+?)\}:\1\b/m, %{\\2}) - matched.gsub!(/\b(org):\{(.+?)\}:\1\b/m, %{\\2}) - matched.gsub!(/\b(dt):\{(.+?)\}:\1\b/m, %{\\2}) - matched.gsub!(/\b(n):\{(.+?)\}:\1\b/m, %{\\2}) - matched.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m,'\2') + matched=matched.gsub(/\b(au):\{(.+?)\}:\1\b/m, %{\\2}). + gsub(/\b(vol):\{(.+?)\}:\1\b/m, %{\\2}). + gsub(/\b(pub):\{(.+?)\}:\1\b/m, %{\\2}). + gsub(/\b(ref):\{(.+?)\}:\1\b/m, %{\\2}). + gsub(/\b(desc):\{(.+?)\}:\1\b/m,%{\\2}). + gsub(/\b(conv):\{(.+?)\}:\1\b/m,%{\\2}). + gsub(/\b(ct):\{(.+?)\}:\1\b/m, %{\\2}). + gsub(/\b(cty):\{(.+?)\}:\1\b/m, %{\\2}). + gsub(/\b(org):\{(.+?)\}:\1\b/m, %{\\2}). + gsub(/\b(dt):\{(.+?)\}:\1\b/m, %{\\2}). + gsub(/\b(n):\{(.+?)\}:\1\b/m, %{\\2}). + gsub(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m,'\2') end def xml_semantic_tags(dob) if @md.sem_tag dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) } dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) } dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) } - dob.obj.gsub!(/:\{(.+?)\}:au\b/m, %{\\1}) - dob.obj.gsub!(/:\{(.+?)\}:n\b/m, %{\\1}) - dob.obj.gsub!(/:\{(.+?)\}:ti\b/m, %{\\1}) - dob.obj.gsub!(/:\{(.+?)\}:ref\b/m, %{\\1}) - dob.obj.gsub!(/:\{(.+?)\}:desc\b/m, %{\\1}) - dob.obj.gsub!(/:\{(.+?)\}:cty\b/m, %{\\1}) - dob.obj.gsub!(/:\{(.+?)\}:org\b/m, %{\\1}) - dob.obj.gsub!(/:\{(.+?)\}:([a-z]+(?:[_:.][a-z]+)*)/m,'\1') - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ti\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};qt\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ref\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ed\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};v\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};desc\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};def\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};trans\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};y\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ab\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};pg\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};fn?\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};mn?\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};ln?\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};in\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};uni\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};fac\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};inst\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};dept\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};org\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};com?\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};cty\b/m, %{\\1}) - dob.obj.gsub!(/;\{([^}]+(?![;]))\};([a-z]+(?:[_:.][a-z]+)*)/m,'\1') + dob.obj=dob.obj.gsub(/:\{(.+?)\}:au\b/m, %{\\1}). + gsub(/:\{(.+?)\}:n\b/m, %{\\1}). + gsub(/:\{(.+?)\}:ti\b/m, %{\\1}). + gsub(/:\{(.+?)\}:ref\b/m, %{\\1}). + gsub(/:\{(.+?)\}:desc\b/m, %{\\1}). + gsub(/:\{(.+?)\}:cty\b/m, %{\\1}). + gsub(/:\{(.+?)\}:org\b/m, %{\\1}). + gsub(/:\{(.+?)\}:([a-z]+(?:[_:.][a-z]+)*)/m,'\1'). + gsub(/;\{([^}]+(?![;]))\};ti\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};qt\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};ref\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};ed\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};v\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};desc\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};def\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};trans\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};y\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};ab\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};pg\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};fn?\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};mn?\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};ln?\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};in\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};uni\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};fac\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};inst\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};dept\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};org\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};com?\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};cty\b/m, %{\\1}). + gsub(/;\{([^}]+(?![;]))\};([a-z]+(?:[_:.][a-z]+)*)/m,'\1') end dob end @@ -647,7 +652,7 @@ module SiSU_XML_Tags #Format def meta_content_clean(content='') content unless content.nil? - content.tr!('"',"'") + content=content.tr('"',"'") content=SiSU_XML_Munge::Trans.new(@md).char_enc.utf8(content) end content diff --git a/lib/sisu/v3dv/sisupod_make.rb b/lib/sisu/v3dv/sisupod_make.rb index 5fe93429..4b1a5ef9 100644 --- a/lib/sisu/v3dv/sisupod_make.rb +++ b/lib/sisu/v3dv/sisupod_make.rb @@ -183,7 +183,7 @@ module SiSU_Doc file_array.each do |f| #% work area if f !~/^%+\s/ skin << f.scan(@rgx_skin).uniq.flatten if f =~@rgx_skin - f.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if f !~/^%+\s/ \ and f =~@rgx_image images=images_extract(f,images) @@ -238,10 +238,9 @@ module SiSU_Doc #2. need images used by skin, scan skin?? if images \ and images.length > 1 - images.flatten! - images.uniq! + images=images.flatten.uniq images.delete_if {|x| x =~/https?:\/\// } - #images.sort! + #images=images.sort path_pod="#{@env.processing_path.processing}/sisupod" path_pod_conf="#{@env.processing_path.processing}/sisupod/_sisu" images_path_pod="#{path_pod}/image" diff --git a/lib/sisu/v3dv/spell.rb b/lib/sisu/v3dv/spell.rb index 1a8dc35b..58b86af3 100644 --- a/lib/sisu/v3dv/spell.rb +++ b/lib/sisu/v3dv/spell.rb @@ -70,23 +70,23 @@ module SiSU_SpellUtility end def check @input.each do |data| - data.gsub!(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' ') - data.gsub!(/( |#{Mx[:nbsp]})/i,' ') - data.gsub!(/<\/?(table|tr|td|b|p|href).*?>/i,' ') - data.gsub!(/(<==.+|<:\S+>||^@\S+?:.+|\{\{\{|~)/,' ') - data.gsub!(/(["|<>)(\n'`'.;&_-]|\=)/,' ') - data.gsub!(/\b(altExternal| - target|externalimg| - srcimagebext| - img|src|toc|pdf| - cd|org| - helvetica|roman - )\b/i,' ') - data.gsub!(/EOF/,'') + data=data.gsub(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' '). + gsub(/( |#{Mx[:nbsp]})/i,' '). + gsub(/<\/?(table|tr|td|b|p|href).*?>/i,' '). + gsub(/(<==.+|<:\S+>||^@\S+?:.+|\{\{\{|~)/,' '). + gsub(/(["|<>)(\n'`'.;&_-]|\=)/,' '). + gsub(/\b(altExternal| + target|externalimg| + srcimagebext| + img|src|toc|pdf| + cd|org| + helvetica|roman + )\b/i,' '). + gsub(/EOF/,'') @words=data.scan(/\S+/) @words.each { |y| @allwords << y } end - @allwords.uniq! + @allwords=@allwords.uniq if @flg =~ /S/ File.open('/home/ralph/spell_error','a+') do |file| #fix file.puts %{\n\n<<#{@filename}>>} diff --git a/lib/sisu/v3dv/sysenv.rb b/lib/sisu/v3dv/sysenv.rb index dea32c98..1b1a5857 100644 --- a/lib/sisu/v3dv/sysenv.rb +++ b/lib/sisu/v3dv/sysenv.rb @@ -544,8 +544,7 @@ module SiSU_Env @m << { m: fn[:manifest], l: lng } end end - @m.uniq! - @m + @m=@m.uniq end def filename(code,name,suffix) #d=SiSU_Env::InfoEnv.new(@fns) @@ -626,7 +625,7 @@ module SiSU_Env fnsp=SiSU_Env::InfoEnv.new(filename).source_file_with_path if program_found?(program) encoding=%x{file -L #{fnsp}}.strip - encoding.gsub!(/#{fnsp}:(\s+|$)/,'') + encoding=encoding.gsub(/#{fnsp}:(\s+|$)/,'') encoding=if encoding \ and not encoding.empty? encoding @@ -1118,8 +1117,7 @@ module SiSU_Env paths=[] flv=SiSU_Env::EnvCall.new(opt.fns).document_language_versions_found flv[:f].each {|l| lng_dirs << l[:l] } - lng_dirs.uniq! - lng_dirs.each do |lng| + lng_dirs.uniq.each do |lng| paths << "#{spp}/doc/#{lng}" end paths \ @@ -2744,7 +2742,9 @@ WOK @zap=z.local_sisu_source if @opt.cmd =~ /[hH]/ @zap=Dir.glob(@zap).join(' ') - if @opt.cmd !~ /w/; @zap.gsub!(/#{@source_path}\/concordance.html/,'') + @zap=if @opt.cmd !~ /w/ + @zap.gsub(/#{@source_path}\/concordance.html/,'') + else @zap end end @env=SiSU_Env::InfoEnv.new diff --git a/lib/sisu/v3dv/texinfo.rb b/lib/sisu/v3dv/texinfo.rb index 45af0550..121cf1ae 100644 --- a/lib/sisu/v3dv/texinfo.rb +++ b/lib/sisu/v3dv/texinfo.rb @@ -156,24 +156,24 @@ module SiSU_TexInfo if dob.is =='table' @@flag['tables']='y' # KLUDGE get from param end - dob.obj.gsub!(/<:p[bn]>/,'') - dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1(\2 [linked to:] \3)') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') + dob.obj=dob.obj.gsub(/<:p[bn]>/,''). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1(\2 [linked to:] \3)'). + gsub(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') do_mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) dob.obj=do_mono.spec_char(dob.obj) end data end def endnote - data=@data + data,data_new=@data,[] data.each do |dob| if dob.of=~/para|block/ - dob.obj.gsub!(/\s*#{Mx[:en_a_o]}(?:\d+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') - dob.obj.gsub!(/\s*#{Mx[:en_a_o]}(\*+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') + dob.obj=dob.obj.gsub(/\s*#{Mx[:en_a_o]}(?:\d+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} '). + gsub(/\s*#{Mx[:en_a_o]}(\*+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') end - dob + data_new << dob end - data + data_new end def poem data=@data @@ -216,16 +216,17 @@ module SiSU_TexInfo end end def code_lines - data=@data + data,data_new=@data,[] data.each do |line| if line =~ /\S/ \ and line !~ /#{Mx[:gr_o]}(code|verse).+/ #fix - if @@flag['code'] - line.gsub!(/^\s*(.+)/m,"\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") + line=if @@flag['code'] + line.gsub(/^\s*(.+)/m,"\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") @@counting+=1 if @@flag['code'] - else line.gsub!(/(.+)/m,'\noindent\1') + else line.gsub(/(.+)/m,'\noindent\1') end end + data_new << line end end def tables @@ -275,10 +276,10 @@ module SiSU_TexInfo @subsubmenu[n_submenu] << toc.menu end else - dob.obj.gsub!(/\s*(?:<:?br>|
)\s*/,"\n\n") + dob.obj=dob.obj.gsub(/\s*(?:<:?br>|
)\s*/,"\n\n") end end - texinfo_menu.compact! + texinfo_menu=texinfo_menu.compact texinfo_menu << "* Dublin Core::" @tex_file << texinfo_menu @tex_file << "* Index::\n" + @@ -326,7 +327,7 @@ module SiSU_TexInfo end end #%case with endnotes - dob.obj.gsub!(/\s*[0-8]\\+(\S+)?\s+/,' ') if dob.obj + dob.obj=dob.obj.gsub(/\s*[0-8]\\+(\S+)?\s+/,' ') if dob.obj @tex_file << dob.obj if dob.obj and dob.is !~/structure|comment/ #sort exceptions end data=@tex_file @@ -343,13 +344,13 @@ module SiSU_TexInfo and dob.obj !~ /#{Rx[:meta]}/ if dob.obj =~ /^[1-6]\\+(?:~\S+)?\s*/ \ and dob.obj !~ /<:\d-endnotes>/ - header=dob.obj[//m, 1].gsub!(/-/m,'.') - dob.obj.gsub!(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*/, + header=dob.obj[//m, 1].gsub(/-/m,'.') + dob.obj=dob.obj.gsub(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*/, "\\1 #{header} ") end elsif dob.obj=~ /|||/ if dob.obj=~ // - dob.obj.gsub!(//,'\1 ') + dob.obj=dob.obj.gsub(//,'\1 ') end end @tex_file << dob.obj @@ -363,8 +364,7 @@ module SiSU_TexInfo data << tex.tail end def output - data=@data - data.compact! + data=@data.compact filename_texinfo=%{#{@env.processing_path.texi}/#{@md.fnb}.texinfo} file_texinfo=File.new(filename_texinfo,'w+') puts filename_texinfo if @md.opt.cmd =~/M/ diff --git a/lib/sisu/v3dv/texinfo_format.rb b/lib/sisu/v3dv/texinfo_format.rb index fc7ffde2..30d40e20 100644 --- a/lib/sisu/v3dv/texinfo_format.rb +++ b/lib/sisu/v3dv/texinfo_format.rb @@ -81,20 +81,20 @@ module SiSU_TexInfoFormat year=t.year filename=%{#{@md.fns}}[/(.+?)\.\w\w\d\d$/,1] title=spec_char(@md.title.full) - title=title.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} ") - title.gsub!(/\$/,"\\$") - title.gsub!(/[,]\s*/,' - ') + title=title.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). + gsub(/\$/,"\\$"). + gsub(/[,]\s*/,' - ') if @md.title.sub subtitle=spec_char(@md.title.sub) - subtitle=subtitle.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} ") - subtitle.gsub!(/\$/,"\\$") - subtitle.gsub!(/[,]\s*/,' - ') + subtitle=subtitle.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). + gsub(/\$/,"\\$"). + gsub(/[,]\s*/,' - ') subtitle="@subtitle @value{VERSION}, @value{UPDATED}\n" #bugwatch end subtitle ||='' author=@md.author if @md.author author ||='' - author.gsub!(/[\*]/,'') #if author + author=author.gsub(/[\*]/,'') #if author v=SiSU_Env::InfoVersion.instance.get_version head =<|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} ") - txt.gsub!(/\$/,"\\$") - txt.gsub!(/[,]\s*/,' - ') + txt=txt.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). + gsub(/\$/,"\\$"). + gsub(/[,]\s*/,' - ') "@c %% 4\n" + "@ifnottex\n" + "@node Top\n" + @@ -298,15 +298,14 @@ WOK and dob.obj !~/##{dob.ocn}/ dob.obj="#{dob.obj} ##{dob.ocn}" end - dob.obj.gsub!(/<:#>/,'') - dob.obj.strip! + dob.obj=dob.obj.gsub(/<:#>/,'').strip dob end def menu dob=clean(@dob) m=dob.obj - m.gsub!(/[:,]\s*/,' - ') - m.gsub!(/@footnote\{.+?\}\s+/,'') + m=m.gsub(/[:,]\s*/,' - '). + gsub(/@footnote\{.+?\}\s+/,'') m="* #{m}::" end def level1 @@ -347,80 +346,79 @@ WOK end def submenu @dob.obj=@dob.obj.join("\n") - @dob.obj.gsub!(/[5]\\+~\S+/,'') + @dob.obj=@dob.obj.gsub(/[5]\\+~\S+/,'') dob=clean(@dob) dob.obj="@menu\n#{dob.obj}\n@end menu\n\n" - dob.obj.gsub!(/.+/m,"#{dob.obj}") + dob.obj=dob.obj.gsub(/.+/m,"#{dob.obj}") end def subsubmenu @dob.obj=@dob.obj.join("\n") - @dob.obj.gsub!(/[6]\\+~\S+/,'') + @dob.obj=@dob.obj.gsub(/[6]\\+~\S+/,'') dob=clean(@dob) dob.obj="@menu\n#{dob.obj}\n@end menu\n\n" - dob.obj.gsub!(/.+/m,"#{dob.obj}") + dob.obj=dob.obj.gsub(/.+/m,"#{dob.obj}") end def indent1 - @dob.obj.gsub!(/<:i1>(.*)/,'\1') + @dob.obj=@dob.obj.gsub(/<:i1>(.*)/,'\1') end def indent2 - @dob.obj.gsub!(/<:i2>(.*)/,'\1') + @dob.obj=@dob.obj.gsub(/<:i2>(.*)/,'\1') end def spec_char(txt) # special characters - txt.gsub!(/#{Mx[:br_eof]}/i,'') - txt.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)') - txt.gsub!(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<'); txt.gsub!(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>') - txt.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'); txt.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - txt.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - txt.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - txt.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - txt.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - txt.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - txt.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - txt.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') - txt.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n") # watch - txt.gsub!(/&atild;<\/font><\/sup>/,' ') - #txt.gsub!(/\\/,'\\backslash ') - txt.gsub!(/<:pb>/,'\\newpage') - txt.gsub!(/\\backslash copyright/,'\\copyright ') - txt.gsub!(/\^/,'\\wedge ') - txt.gsub!(/(\$)/,"\\$") - txt.gsub!(/\~/,'\\~') - txt.gsub!(/#{Mx[:url_o]}(https?:\S+?)#{Mx[:url_c]}/,'<\1>') - txt.gsub!(/#{Mx[:url_o]}_(https?:\S+?)#{Mx[:url_c]}/,'\1') - txt.gsub!(/§/i,'\S') - txt.gsub!(/£/i,'\pounds') - txt.gsub!(/å/,'\aa'); txt.gsub!(/Å/,'\AA') - txt.gsub!(/æ/,'\ae'); txt.gsub!(/Æ/,'\AE') - txt.gsub!(/ø/,'\o'); txt.gsub!(/Ø/,'\O') - txt.gsub!(//i,' ') - txt.gsub!(/<\/a>/i,' ') - txt.gsub!(//i,' ') - txt.gsub!(/#{Mx[:br_paragrph]}/i,'') #watch - txt.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*\1*') - txt.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/\1/') - txt.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_\1_') - txt.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]') - txt.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^') - txt.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+\1+') - txt.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"') - txt.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'-\1-') - txt.gsub!(/@/i,'@@') - txt.gsub!(/\{/,'@{'); txt.gsub!(/\}/,'@}') - txt.gsub!(/(?: |#{Mx[:nbsp]})+/,' ') # ~ character for hardspace - txt.gsub!(/&(\S+?);/,' ') - txt.gsub!(/&/,'<=and>') - txt.gsub!(/(\s+&\s+)/,' and ') - txt.gsub!(/(\&)/,"\\&") - txt.gsub!(/"(.+?)"/,"`\\1'") # open & close " - txt.gsub!(/\s+"/," `") # open " - txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`') # open " - txt.gsub!(/"(\s|\.|,|:|;)/,"'\\1") # close " - txt.gsub!(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1") # close " - txt.gsub!(/"(\.|,)/,"'") # close " - txt.gsub!(/\s+'/," `") # open ' - txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`') # open ' - txt.gsub!(/(|<\/font>)/,'') - txt + txt=txt.gsub(/#{Mx[:br_eof]}/i,''). + gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)'). + gsub(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>'). + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~'). + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\'). + gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n"). # watch + gsub(/&atild;<\/font><\/sup>/,' '). + #gsub(/\\/,'\\backslash '). + gsub(/<:pb>/,'\\newpage'). + gsub(/\\backslash copyright/,'\\copyright '). + gsub(/\^/,'\\wedge '). + gsub(/(\$)/,"\\$"). + gsub(/\~/,'\\~'). + gsub(/#{Mx[:url_o]}(https?:\S+?)#{Mx[:url_c]}/,'<\1>'). + gsub(/#{Mx[:url_o]}_(https?:\S+?)#{Mx[:url_c]}/,'\1'). + gsub(/§/i,'\S'). + gsub(/£/i,'\pounds'). + gsub(/å/,'\aa').gsub(/Å/,'\AA'). + gsub(/æ/,'\ae').gsub(/Æ/,'\AE'). + gsub(/ø/,'\o').gsub(/Ø/,'\O'). + gsub(//i,' '). + gsub(/<\/a>/i,' '). + gsub(//i,' '). + gsub(/#{Mx[:br_paragrph]}/i,''). #watch + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*\1*'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/\1/'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_\1_'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+\1+'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'-\1-'). + gsub(/@/i,'@@'). + gsub(/\{/,'@{').gsub(/\}/,'@}'). + gsub(/(?: |#{Mx[:nbsp]})+/,' '). # ~ character for hardspace + gsub(/&(\S+?);/,' '). + gsub(/&/,'<=and>'). + gsub(/(\s+&\s+)/,' and '). + gsub(/(\&)/,"\\&"). + gsub(/"(.+?)"/,"`\\1'"). # open & close " + gsub(/\s+"/," `"). # open " + gsub(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`'). # open " + gsub(/"(\s|\.|,|:|;)/,"'\\1"). # close " + gsub(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1"). # close " + gsub(/"(\.|,)/,"'"). # close " + gsub(/\s+'/," `"). # open ' + gsub(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`'). # open ' + gsub(/(|<\/font>)/,'') end def longtable @end_table="\\end{longtable}" @@ -440,28 +438,28 @@ WOK @colW=@colW.join @@start_table="\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{longtable}[hb]#{@colW}\n" - @dob.obj.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") #fix + @dob.obj=@dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") #fix end if @dob =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ #fix - @dob.obj.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #{@end_table}") #fix + @dob.obj=@dob.obj.gsub(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #{@end_table}") #fix end - @dob.obj.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @dob.obj=@dob.obj.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') if @@tableheader==1 if @dob =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u tablefoot=para[/\/,1] - @dob.obj.gsub!(/\/,'') - @dob.obj.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u, - "{\\begin{tiny} {\\bfseries \\1}\\end{tiny}}&") - @dob.obj.gsub!(/&>\s*$/, - " #{@row_break} \\hline\\endhead #{@row_break}") + @dob.obj=@dob.obj.gsub(/\/,''). + gsub(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u, + "{\\begin{tiny} {\\bfseries \\1}\\end{tiny}}&"). + gsub(/&>\s*$/, + " #{@row_break} \\hline\\endhead #{@row_break}") @dob="#{@dob} \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader=0 @@number_of_cols=0 end else if @dob =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - @dob.obj.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") - @dob.obj.gsub!(/&>\s*$/," #{@row_break}") + @dob.obj=@dob.obj.gsub(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&"). + gsub(/&>\s*$/," #{@row_break}") end end @dob @@ -482,10 +480,10 @@ WOK @colW << "p{#{col_w}cm}" if col_w end @@start_table="\\begin{tabular}{#{@colW}}\n" - @dob.obj.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") #fix + @dob.obj=@dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") #fix end if @dob =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ #fix - @dob.obj.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#{@end_table}") #fix + @dob.obj=@dob.obj.gsub(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#{@end_table}") #fix @@table_pg_break_counter=1 end if @dob =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u @@ -496,21 +494,21 @@ WOK "#{@@start_table}\n" @@table_pg_break_counter=1 else - @dob.obj.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @dob.obj=@dob.obj.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') @@table_pg_break_counter+=1 tablefoot=@dob[/\/] - @dob.obj.gsub!(/\/,'') + @dob.obj=@dob.obj.gsub(/\/,'') end end if @dob =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - @dob.obj.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") - @dob.obj.gsub!(/&>\s*$/,"#{@row_break}") + @dob.obj=@dob.obj.gsub(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&"). + gsub(/&>\s*$/,"#{@row_break}") end @dob end def graphics dir=SiSU_Env::InfoEnv.new(@md.fns) - @dob.obj.gsub!(/<::\s+(\S+?)\s+>/i, #watch + @dob.obj=@dob.obj.gsub(/<::\s+(\S+?)\s+>/i, #watch "\\includegraphics*[width=11pt]{#{dir.path.image_source_include}/c_\\1.png}") end def image @@ -518,17 +516,17 @@ WOK width="100" width=@dob[/<:image.+?width=``(\d+)''.+?>/im,1] width=width.to_i*0.4 - @dob.obj.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, - "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/\\2}}") - @dob.obj.gsub!(/<:image\s+(\S+)\s+.+\s+?>/i, - "\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/\\1}") + @dob.obj=@dob.obj.gsub(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, + "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/\\2}}"). + gsub(/<:image\s+(\S+)\s+.+\s+?>/i, + "\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/\\1}") end def png # very messy clean up ! - work area, testing z=@dob[/\\\{(.+?)\}(?:image|png)/,1] # match operator for z \\ fragile ! image,w,x,y=z.scan(/\S+/) - image.gsub!(/\\/,'') - @dob.obj.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"") # fragile match operator\\ fragile ! + image=image.gsub(/\\/,'') + @dob.obj=@dob.obj.gsub(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"") # fragile match operator\\ fragile ! end def http # very messy clean up ! - work area, testing @@ -536,7 +534,7 @@ WOK url=@dob[/((?:https?|file|ftp):\S+)/im,1] if @dob =~/\.(png|jpg|gif)/ image,w,x,y=z.scan(/\S+/) - image.gsub!(/\\/,'') + image=image.gsub(/\\/,'') width=200 width=z[/w=(\d+)/im,1] if z =~/w=(\d+)/ width=width.to_i*0.8 @@ -546,11 +544,11 @@ WOK end if image dir=SiSU_Env::InfoEnv.new(@md.fns) - @dob.obj.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/, # fragile match operator\\ fragile ! + @dob.obj=@dob.obj.gsub(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/, # fragile match operator\\ fragile ! "\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_include}/#{image}}}#{caption}") else link=z[/(.+?)\\/im,1] - @dob.obj.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+#{Mx[:url_c]}/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! + @dob.obj=@dob.obj.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+#{Mx[:url_c]}/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! end end end @@ -563,23 +561,21 @@ WOK and txt !~/##{dob.ocn}/ txt="#{dob.obj} ##{dob.ocn}" end - txt.gsub!(/<:#>/,'') - txt.strip! - txt + txt=txt.gsub(/<:#>/,'').strip end def submenu txt=@txt.join("\n") - txt.gsub!(/[5]\\+~\S+/,'') + txt=txt.gsub(/[5]\\+~\S+/,'') txt=clean(@dob,txt) txt="@menu\n#{txt}\n@end menu\n\n" - txt.gsub!(/.+/m,"#{txt}") + txt=txt.gsub(/.+/m,"#{txt}") end def subsubmenu txt=@txt.join("\n") - txt.gsub!(/[6]\\+~\S+/,'') + txt=txt.gsub(/[6]\\+~\S+/,'') txt=clean(@dob,txt) txt="@menu\n#{dob.obj}\n@end menu\n\n" - txt.gsub!(/.+/m,"#{txt}") + txt=txt.gsub(/.+/m,"#{txt}") end end end diff --git a/lib/sisu/v3dv/texpdf.rb b/lib/sisu/v3dv/texpdf.rb index ee623cec..f8010511 100644 --- a/lib/sisu/v3dv/texpdf.rb +++ b/lib/sisu/v3dv/texpdf.rb @@ -208,8 +208,8 @@ module SiSU_TeX when /\.(?:-|ssm\.)?sst$/ if FileTest.directory?(@env.processing_path.tex)==true Dir.chdir(@env.processing_path.tex) - texfile=@md.fns.gsub(/$/,".#{ps}.tex") - texfile=texfile.gsub(/~/,'-') + texfile=@md.fns.gsub(/$/,".#{ps}.tex"). + gsub(/~/,'-') if File.exist?(texfile) \ and File.size(texfile) > 0 @tex_f_no+=1 @@ -347,7 +347,7 @@ module SiSU_TeX dob.tmp=dob.obj #.dup if dob.is=='para' \ or dob.is=='heading' - dob.tmp.gsub!(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') + dob.tmp=dob.tmp.gsub(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') dob.tmp=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp).special_characters if dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ dob.tmp=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob.tmp).url_str_internal(dob.tmp) @@ -374,9 +374,9 @@ module SiSU_TeX data.each do |dob| # EMBEDDED FOOTNOTES / ENDNOTES should be straightforward but not quite a synch. if dob.tmp =~/#{Mx[:en_a_o]}[\d*+]+\s|#{Mx[:en_b_o]}([*+]\d+)\s/ - dob.tmp.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\footnote[\\1]{%\n \\2} ") - dob.tmp.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/m,"\\FootnoteA{\\1}{%\n \\2} ") - dob.tmp.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\FootnoteA{\\1}{%\n \\2} ") + dob.tmp=dob.tmp.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\footnote[\\1]{%\n \\2} "). + gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/m,"\\FootnoteA{\\1}{%\n \\2} "). + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/m,"\\FootnoteA{\\1}{%\n \\2} ") end end data @@ -416,14 +416,14 @@ module SiSU_TeX def box_boites(dob,ocn) sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp,dob.is) dob.tmp=sp_char.special_characters_safe - dob.tmp.gsub!(/(#{Mx[:nbsp]})/m,'{\color{mywhite}\1}') - #dob.tmp.gsub!(/#{Mx[:nbsp]}/m,'{~}') # dob.tmp.gsub!(/#{Mx[:nbsp]}\s*/m,'{~}') - dob.tmp.gsub!(/#{Mx[:vline]}/m,'\vline') - dob.tmp.gsub!(/ \\( |#{Mx[:br_nl]})/,' {\textbackslash}\1') - dob.tmp.gsub!(/#{Mx[:br_nl]}\s*\Z/m,'') - dob.tmp.gsub!(/#{Mx[:br_nl]}{2}/,'\newline \\\\\\ ') - dob.tmp.gsub!(/#{Mx[:br_nl]}/,' \\\\\\ ') - dob.tmp.gsub!(/\n\n\n/m," \\newline\n\n") + dob.tmp=dob.tmp.gsub(/(#{Mx[:nbsp]})/m,'{\color{mywhite}\1}'). + #dob.tmp.gsub(/#{Mx[:nbsp]}/m,'{~}') # dob.tmp.gsub(/#{Mx[:nbsp]}\s*/m,'{~}') + gsub(/#{Mx[:vline]}/m,'\vline'). + gsub(/ \\( |#{Mx[:br_nl]})/,' {\textbackslash}\1'). + gsub(/#{Mx[:br_nl]}\s*\Z/m,''). + gsub(/#{Mx[:br_nl]}{2}/,'\newline \\\\\\ '). + gsub(/#{Mx[:br_nl]}/,' \\\\\\ '). + gsub(/\n\n\n/m," \\newline\n\n") ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob) dob.tmp = ocn \ + @tex_ml.paraskip_small \ @@ -439,11 +439,11 @@ module SiSU_TeX def box_listings(dob,ocn) sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp,dob.is) dob.tmp=sp_char.characters_code_listings - dob.tmp.gsub!(/^\s+/m,'') #bug, fix earlier, should be made unecessary - dob.tmp.gsub!(/#{Mx[:nbsp]}/m,' ') - dob.tmp.gsub!(/#{Mx[:vline]}/m,'|') - dob.tmp.gsub!(/#{Mx[:br_nl]}(?:\s?\n)?/m,"\n") - dob.tmp.gsub!(/\n\n\n/m," \n\n") + dob.tmp=dob.tmp.gsub(/^\s+/m,''). #bug, fix earlier, should be made unecessary + gsub(/#{Mx[:nbsp]}/m,' '). + gsub(/#{Mx[:vline]}/m,'|'). + gsub(/#{Mx[:br_nl]}(?:\s?\n)?/m,"\n"). + gsub(/\n\n\n/m," \n\n") ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob) dob.tmp = ocn \ + @tex_ml.paraskip_small \ @@ -466,9 +466,9 @@ module SiSU_TeX if dob.of=='block' @lineone=case dob.is when /block|group|alt|verse/ - dob.tmp.gsub!(/#{Mx[:nbsp]}/m,'{~}') - dob.tmp.gsub!(/#{Mx[:gl_bullet]}/m,'$\txtbullet$\hspace{\enspace}') #Bullet environment not used for grouped text, ∴ no hanging indent here - dob.tmp.gsub!(/#{Mx[:br_nl]}+/m,"\n\n") #match not ideal, but currently not inserting extra newlines anyway + dob.tmp=dob.tmp.gsub(/#{Mx[:nbsp]}/m,'{~}'). + gsub(/#{Mx[:gl_bullet]}/m,'$\txtbullet$\hspace{\enspace}'). #Bullet environment not used for grouped text, ∴ no hanging indent here + gsub(/#{Mx[:br_nl]}+/m,"\n\n") #match not ideal, but currently not inserting extra newlines anyway ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob) dob.tmp=if dob.is=='group' \ or dob.is=='block' \ @@ -568,16 +568,16 @@ module SiSU_TeX and (dob.indent != dob.hang or dob.indent =~/[1-9]/) dob.tmp=tst.hang else - dob.tmp.strip! + dob.tmp=dob.tmp.strip dob=enclose(dob) unless dob.tmp =~/^$/ end else - dob.tmp.strip! unless dob.is=='code' + dob.tmp=dob.tmp.strip unless dob.is=='code' dob=enclose(dob) unless dob.tmp =~/^$/ end if dob.class==String - dob.tmp.gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,' \newline ') #% tread with care - dob.tmp.gsub!(/(\.#{Tex[:tilde]}\S*\s*|<:\S+>|#{Mx[:fa_o]}.*?#{Mx[:fa_c]}|#{Mx[:gr_o]}.*?#{Mx[:gr_c]}||)/,' ') #% tread with care + dob.tmp=dob.tmp.gsub(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,' \newline '). #% tread with care + gsub(/(\.#{Tex[:tilde]}\S*\s*|<:\S+>|#{Mx[:fa_o]}.*?#{Mx[:fa_c]}|#{Mx[:gr_o]}.*?#{Mx[:gr_c]}||)/,' ') #% tread with care end dob end @@ -872,12 +872,16 @@ WOK ps,h,fn=o[:ps],o[:h],o[:filename] if h[ps] \ and (h[ps][:p] and h[ps][:l]) - h[ps][:p].gsub!(/[ ]+$/m,'') if h[ps][:p] - h[ps][:l].gsub!(/[ ]+$/m,'') if h[ps][:l] - #h[ps][:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:p] - #h[ps][:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:l] - h[ps][:p].gsub!(/\n\n\n+/m,"\n\n") if h[ps][:p] - h[ps][:l].gsub!(/\n\n\n+/m,"\n\n") if h[ps][:l] + if h[ps][:p] + h[ps][:p]=h[ps][:p].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + if h[ps][:l] + h[ps][:l]=h[ps][:l].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + #h[ps][:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:p] + #h[ps][:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:l] if h[ps][:p] !~/\A\s*\Z/ fn[:portrait].puts h[ps][:p],"\n" end @@ -885,12 +889,16 @@ WOK fn[:landscape].puts h[ps][:l],"\n" end elsif (h[:p] and h[:l]) - h[:p].gsub!(/[ ]+$/m,'') if h[:p] - h[:l].gsub!(/[ ]+$/m,'') if h[:l] - #h[:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:p] - #h[:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:l] - h[:p].gsub!(/\n\n\n+/m,"\n\n") if h[:p] - h[:l].gsub!(/\n\n\n+/m,"\n\n") if h[:l] + if h[:p] + h[:p]=h[:p].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + if h[:l] + h[:l]=h[:l].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + #h[:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:p] + #h[:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:l] if h[:p] !~/\A\s*\Z/ fn[:portrait].puts h[:p],"\n" end @@ -901,9 +909,7 @@ WOK end end def output(array) - array.flatten! - array.compact! - @array=array + @array=array=array.flatten.compact fns_l=@md.fns.gsub(/~/,'-') #this is a sorry fix, but necessary as it appears latex programs like not ~ @md.papersize_array.each do |ps| file={ @@ -924,7 +930,7 @@ WOK and morph.tmp.class==String if morph.is !='code' \ && morph.of !='block' - morph.tmp.gsub!(/^\s+/,'') + morph.tmp=morph.tmp.gsub(/^\s+/,'') else morph.tmp end if morph.tmp !~/\A\s*\Z/ \ diff --git a/lib/sisu/v3dv/texpdf_format.rb b/lib/sisu/v3dv/texpdf_format.rb index a4b590a1..2eddf72c 100644 --- a/lib/sisu/v3dv/texpdf_format.rb +++ b/lib/sisu/v3dv/texpdf_format.rb @@ -65,17 +65,17 @@ module SiSU_TeX_Pdf @brace_url=SiSU_Viz::Skin.new.url_decoration end def bare_urls - @dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, - "#{@brace_url.tex_open}\\1#{@brace_url.tex_close}") - @dob.tmp.gsub!(/(^|[^\\])_/m,'\1\_') #watch may not work - @dob.tmp.gsub!(/(^|[^#{Mx[:lnk_c]}])#{Mx[:url_o]}_?(?:\\?_)?(\S+?)#{Mx[:url_c]}/m, - "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}") + @dob.obj=@dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + "#{@brace_url.tex_open}\\1#{@brace_url.tex_close}") + @dob.tmp=@dob.tmp.gsub(/(^|[^\\])_/m,'\1\_'). #watch may not work + gsub(/(^|[^#{Mx[:lnk_c]}])#{Mx[:url_o]}_?(?:\\?_)?(\S+?)#{Mx[:url_c]}/m, + "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}") @dob end def bare_urls_in_code - @dob.tmp.gsub!(/(^|[^\\])_/m,'\1\_') #watch may not work - @dob.tmp.gsub!(/(https?:\/\/\S+?)([{]|[.,;)\]]?(?: |$))/m, - '\begin{scriptsize}\url{\1}\end{scriptsize}\2') + @dob.tmp=@dob.tmp.gsub(/(^|[^\\])_/m,'\1\_'). #watch may not work + gsub(/(https?:\/\/\S+?)([{]|[.,;)\]]?(?: |$))/m, + '\begin{scriptsize}\url{\1}\end{scriptsize}\2') @dob end end @@ -109,17 +109,16 @@ module SiSU_TeX_Pdf "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}\\hspace{0mm}\\hypertarget{#{dob.ocn}}{#{dob.ocn}}\\end{tiny}}}" #ocn object citation numbering end def table_special_characters(r) - r.gsub!(/#{Mx[:tc_p]}|$/u,'&') - r.gsub!(/%/,'\%') - r.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}') - r.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}') - r.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}') # ulem - r.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''") # quote #CHECK - r.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}') # ulem - r.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}') # ulem - r.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$") - r.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") - r + r=r.gsub(/#{Mx[:tc_p]}|$/u,'&'). + gsub(/%/,'\%'). + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}'). # ulem + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''"). # quote #CHECK + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}'). # ulem + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}'). # ulem + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") end def longtable_landscape end_table='\end{longtable}' @@ -147,19 +146,21 @@ module SiSU_TeX_Pdf "\\begin{tiny}\n\\begin{longtable}#{colW}\n" rows=@dob.obj.split(/#{Mx[:br_nl]}/) if @dob.head_ #result imperfect, check on - rows[0].gsub!(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&') - rows[0].gsub!(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") + rows[0]=rows[0].gsub(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&'). + gsub(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") end + rows_new=[] rows.each do |r| r=table_special_characters(r) - r.gsub!(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ + r=r.gsub(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ if r=~/\/ # not tested table footer if any tablefoot=$1 - r.gsub!(/\/,'') + r=r.gsub(/\/,'') r="#{r} \\multicolumn{#{@dob.cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" end + rows_new << r end - table=rows.join #@dob[:dal].obj=rows.join + table=rows_new.join #@dob[:dal].obj=rows.join ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}" else '' end @@ -190,19 +191,21 @@ module SiSU_TeX_Pdf "\\begin{tiny}\n\\begin{longtable}#{colW}\n" rows=@dob.obj.split(/#{Mx[:br_nl]}/) if @dob.head_ - rows[0].gsub!(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&') - rows[0].gsub!(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") + rows[0]=rows[0].gsub(/(^|.+?)(?:#{Mx[:tc_p]}|$)/u,'\bfseries \1&'). + gsub(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") end + rows_new=[] rows.each do |r| r=table_special_characters(r) - r.gsub!(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ + r=r.gsub(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ if r=~/\/ # not tested table footer if any tablefoot=$1 - r.gsub!(/\/,'') + r=r.gsub(/\/,'') r="#{r} \\multicolumn{#{@dob.cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" end + rows_new << r end - table=rows.join #@dob[:dal].obj=rows.join + table=rows_new.join #@dob[:dal].obj=rows.join ocn_display(@dob) + start_table + table + " #{end_table}\n\\end{tiny}" else '' end @@ -210,17 +213,17 @@ module SiSU_TeX_Pdf def heading_major dob=@dob title=@md.title.full - dob.tmp.strip! if dob.tmp - dob.tmp.gsub!(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') + dob.tmp=dob.tmp.strip if dob.tmp + dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') cont_ln=dob.tmp.dup - cont_ln.gsub!(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2') - cont_ln.gsub!(@@tex_pattern_margin_number,'') + cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). + gsub(@@tex_pattern_margin_number,'') clearp=(dob.lv =~/B/ && dob.obj =='Metadata') ? "\\clearpage\n" : '' if dob.tmp =~/\\[Ff]ootnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') - cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). + gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - dob.tmp.gsub!(/^(.*)\n?$/m, + dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, "#{clearp}\\part*{\\1} \\addcontentsline{toc}{section}{#{cont_ln}} \\markboth{#{title}}\n") @@ -228,23 +231,23 @@ module SiSU_TeX_Pdf end def level4 dob=@dob - dob.tmp.strip! if dob.tmp - dob.tmp.gsub!(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') + dob.tmp=dob.tmp.strip if dob.tmp + dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') cont_ln=dob.tmp.dup - cont_ln.gsub!(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2') - cont_ln.gsub!(@@tex_pattern_margin_number,'') - cont_ln.gsub!(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}") # added w42 - cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). + gsub(@@tex_pattern_margin_number,''). + gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42 + gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 title=@md.title.full if dob.name =~/endnotes/ - dob.tmp.gsub!(/.+/m,'') + dob.tmp=dob.tmp.gsub(/.+/m,'') end if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') - cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). + gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - dob.tmp.gsub!(/^(.*)?\n?$/m,"\\subsubsection*{\\1} + dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsection}{#{cont_ln}} \\markright{#{title}}") dob @@ -252,19 +255,19 @@ module SiSU_TeX_Pdf def level5 dob=@dob # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@txt*, same for next section 2002w46 - dob.tmp.strip! if dob.tmp - dob.tmp.gsub!(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') + dob.tmp=dob.tmp.strip if dob.tmp + dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') cont_ln=dob.tmp.dup - cont_ln.gsub!(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2') - cont_ln.gsub!(@@tex_pattern_margin_number,'') - cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - cont_ln.gsub!(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa + cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). + gsub(@@tex_pattern_margin_number,''). + gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + gsub(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') - cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). + gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - dob.tmp.gsub!(/^(.*)?\n?$/m, + dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, "\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ }") @@ -273,22 +276,22 @@ module SiSU_TeX_Pdf def level6 dob=@dob # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@txt*, same for previous section 2002w46 - dob.tmp.strip! if dob.tmp - dob.tmp.gsub!(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') + dob.tmp=dob.tmp.strip if dob.tmp + dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2') cont_ln=dob.tmp.dup - cont_ln.gsub!(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2') - cont_ln.gsub!(@@tex_pattern_margin_number,'') - cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). + gsub(@@tex_pattern_margin_number,''). + gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 + gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! - cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') - cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') + cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). + gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - dob.tmp.gsub!(/^(.*)?\n?$/m, + dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, "\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{~~~~#{cont_ln} \\\\ }") - #dob.tmp.gsub!(/^(.*)?\n?$/m, + #dob.tmp.gsub(/^(.*)?\n?$/m, # '\subsubsection*{\1}') dob end @@ -569,8 +572,7 @@ module SiSU_TeX_Pdf #? (str.sub!(rgx_url_internal,"\\hyperlink{#{url}}{#{link}}")) \ #: (str.sub!(rgx_url_internal,"#{@brace_rel.tex_open}\\hyperlink{#{url}}{#{link}}#{@brace_rel.tex_close}")) end - str.gsub!(/#{Xx[:protect]}/,'') - str + str=str.gsub(/#{Xx[:protect]}/,'') end def url_str(str) rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m @@ -582,7 +584,7 @@ module SiSU_TeX_Pdf link=z.strip link.gsub!(/&/,"#{Xx[:protect]}&") str.sub!(rgx_url_generic,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}") - str.gsub!(/#{Xx[:protect]}/,'') + str=str.gsub(/#{Xx[:protect]}/,'') str else str end @@ -607,6 +609,8 @@ module SiSU_TeX_Pdf link.gsub!(/&/,"#{Xx[:protect]}&") dob.tmp.sub!(rgx_url_generic,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}#{punctuate}") dob.tmp.gsub!(/#{Xx[:protect]}/,'') + #dob.tmp=dob.tmp.sub(rgx_url_generic,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}#{punctuate}"). + # gsub(/#{Xx[:protect]}/,'') dob else dob end @@ -797,7 +801,7 @@ module SiSU_TeX_Pdf end if lang_char_arr.length > 0 lang_char_arr.slice(1..9).each { |ch| otherlang << @lang.list[ch][:xlp] } - otherlang.uniq! + otherlang=otherlang.uniq end otherlang=otherlang.join(',') { mainlang: mainlang, otherlang: otherlang } @@ -1182,11 +1186,11 @@ WOK para_array=[] str=if word word.each do |w| # _ - / # | : ! ^ ~ - w.gsub!(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<'); w.gsub!(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>') - w.gsub!(/[\\]?~/,'~') - w.gsub!(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,"\n") #watch - w.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~') #126 usual - w.gsub!(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + w=w.gsub(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>'). + gsub(/[\\]?~/,'~'). + gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,"\n"). #watch + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). #126 usual + gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX para_array << w end str=para_array.join(' ') @@ -1194,34 +1198,33 @@ WOK str else '' end - str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' ') - str.gsub!(/.+?<-#>/,'') - str.gsub!(/#{Mx[:br_eof]}/,'') - str.gsub!(/#{Mx[:br_endnotes]}/,'') + str=str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' '). + gsub(/.+?<-#>/,''). + gsub(/#{Mx[:br_eof]}/,''). + gsub(/#{Mx[:br_endnotes]}/,''). #problem sequence -> - str.gsub!(/&(?:lt|#060);/,'<') # < SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'>') # > SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') # { SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') # } SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~') # ~ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') # # SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') # ! SiSU not really special sisu character but done, also LaTeX - #str.gsub!(/(^|\s)\*\s/,'\1\asterisk ') # * should you wish to escape astrisk e.g. describing \*{bold}* - str.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') # * should you wish to escape astrisk e.g. describing \*{bold}* - str.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') # - SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+') # + SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',') # + SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'&') #unless @txt=~/<:code>/ # / SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') # / SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') # \ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') # _ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') # | SiSU not really special sisu character but done, also LaTeX - str.gsub!(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':') # : SiSU not really special sisu character but done, also LaTeX - str.gsub!(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'^') # ^ SiSU not really special sisu character but done, also LaTeX + gsub(/&(?:lt|#060);/,'<'). # < SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'>'). # > SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). # { SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}'). # } SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~'). # ~ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#'). # # SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). # ! SiSU not really special sisu character but done, also LaTeX + #gsub(/(^|\s)\*\s/,'\1\asterisk '). # * should you wish to escape astrisk e.g. describing \*{bold}* + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*'). # * should you wish to escape astrisk e.g. describing \*{bold}* + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). # - SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+'). # + SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,','). # + SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'&'). #unless @txt=~/<:code>/ # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/'). # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\'). # \ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_'). # _ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|'). # | SiSU not really special sisu character but done, also LaTeX + gsub(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':'). # : SiSU not really special sisu character but done, also LaTeX + gsub(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'^'). # ^ SiSU not really special sisu character but done, also LaTeX ##watch placement, problem sequence ^ - str.gsub!(/&atild;<\/font><\/sup>/,' ') - str.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript - str + gsub(/&atild;<\/font><\/sup>/,' '). + gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript end def xetex_special_characters_1(str,is='') # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list #str=Iconv.conv('ISO-8859-1', 'UTF-8', @txt) # `require': iconv will be deprecated in the future, use String#encode instead. @@ -1232,16 +1235,16 @@ WOK if w !~/https?:/ \ and w=~/\/\S+?\// \ and w.length > 6 - w.gsub!(/([_.\/])/,'\1\-') + w=w.gsub(/([_.\/])/,'\1\-') end - w.gsub!(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<'); w.gsub!(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>') - w.gsub!(/[\\]?~/,'<=tilde>') - w.gsub!(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,' \newline ') #watch - w.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') #126 usual - w.gsub!(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'\pipe') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + w=w.gsub(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<').gsub(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>'). + gsub(/[\\]?~/,'<=tilde>'). + gsub(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,' \newline '). #watch + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>'). #126 usual + gsub(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'\pipe') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX if w !~/#{Mx[:rel_o]}/ \ and w !~/#{Mx[:gl_o]}#/ - w.gsub!(/\#/,'<=hash>') + w=w.gsub(/\#/,'<=hash>') end para_array << w end @@ -1250,137 +1253,132 @@ WOK str else '' end - str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' ') - str.gsub!(/.+?<-#>/,'') - str.gsub!(/#{Mx[:br_eof]}/,'') - str.gsub!(/#{Mx[:br_endnotes]}/,'') + str=str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' '). + gsub(/.+?<-#>/,''). + gsub(/#{Mx[:br_eof]}/,''). + gsub(/#{Mx[:br_endnotes]}/,'') #problem sequence -> - str.gsub!(/&(?:nbsp);|#{Mx[:nbsp]}/,'\hardspace') unless is=='code' # < SiSU special character also LaTeX - str.gsub!(/&(?:lt|#060);/,'\lt') # < SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'\gt') # > SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'\curlyopen') # { SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'\curlyclose') # } SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') # ~ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'\#') # # SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') # ! SiSU not really special sisu character but done, also LaTeX - str.gsub!(/(^|\s)\*\s/,'\1\asterisk ') # * should you wish to escape astrisk e.g. describing \*{bold}* - str.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'\*') # * should you wish to escape astrisk e.g. describing \*{bold}* - str.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') # - SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+') # + SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',') # + SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/ # / SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'\slash') # / SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\textbackslash') # \ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>') # _ SiSU special character also LaTeX - str.gsub!(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') # | SiSU not really special sisu character but done, also LaTeX - str.gsub!(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':') # : SiSU not really special sisu character but done, also LaTeX - str.gsub!(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'\caret') # ^ SiSU not really special sisu character but done, also LaTeX + str=str.gsub(/&(?:nbsp);|#{Mx[:nbsp]}/,'\hardspace') unless is=='code' # < SiSU special character also LaTeX + str=str.gsub(/&(?:lt|#060);/,'\lt'). # < SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'\gt'). # > SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'\curlyopen'). # { SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'\curlyclose'). # } SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>'). # ~ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'\#'). # # SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!'). # ! SiSU not really special sisu character but done, also LaTeX + gsub(/(^|\s)\*\s/,'\1\asterisk '). # * should you wish to escape astrisk e.g. describing \*{bold}* + gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'\*'). # * should you wish to escape astrisk e.g. describing \*{bold}* + gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-'). # - SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+'). # + SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,','). # + SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>'). #unless @txt=~/<:code>/ # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'\slash'). # / SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\textbackslash'). # \ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>'). # _ SiSU special character also LaTeX + gsub(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|'). # | SiSU not really special sisu character but done, also LaTeX + gsub(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':'). # : SiSU not really special sisu character but done, also LaTeX + gsub(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'\caret'). # ^ SiSU not really special sisu character but done, also LaTeX ##watch placement, problem sequence ^ - str.gsub!(/&atild;<\/font><\/sup>/,' ') - str.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript - str + gsub(/&atild;<\/font><\/sup>/,' '). + gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript end def xetex_special_characters_2(str,is='') - str.gsub!(/#{Mx[:gl_o]}#156#{Mx[:gl_c]}/,'\oe ') - str.gsub!(/\$/,'\$') - str.gsub!(/\#/,'\#') - str.gsub!(/\%/,'\%') - str.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes + str=str.gsub(/#{Mx[:gl_o]}#156#{Mx[:gl_c]}/,'\oe '). + gsub(/\$/,'\$'). + gsub(/\#/,'\#'). + gsub(/\%/,'\%'). + gsub(/\~/,'\~') #revist, should not be necessary to mark remaining tildes if str !~/^\s*#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\s/ - str.gsub!(/_/,'\_') + str=str.gsub(/_/,'\_') end - str.gsub!(/\{/,'\{') - str.gsub!(/\}/,'\}') - if is=='code' - str.gsub!(/&/,'{\\\&}') - str.gsub!(/\\~(\\\{)/,'{$\tilde$}\1') - str.gsub!(/(\\\})\\~/,'\1{$\tilde$}') - str.gsub!(/\\~(\[)/,'{$\tilde$}\1') - str.gsub!(/(\])\\~/,'\1{$\tilde$}') - str.gsub!(/<=tilde>/,'{$\tilde$}') - str.gsub!(/<=hash>/,'{\#}') + str=str.gsub(/\{/,'\{'). + gsub(/\}/,'\}') + str=if is=='code' + str.gsub(/&/,'{\\\&}'). + gsub(/\\~(\\\{)/,'{$\tilde$}\1'). + gsub(/(\\\})\\~/,'\1{$\tilde$}'). + gsub(/\\~(\[)/,'{$\tilde$}\1'). + gsub(/(\])\\~/,'\1{$\tilde$}'). + gsub(/<=tilde>/,'{$\tilde$}'). + gsub(/<=hash>/,'{\#}') else - str.gsub!(/ |#{Mx[:nbsp]}/,'~') # ~ character for hardspace - str.gsub!(/&/,'<=amp>') + str.gsub(/ |#{Mx[:nbsp]}/,'~'). # ~ character for hardspace + gsub(/&/,'<=amp>') end - str.gsub!(/&\S+?;/,' ') - str.gsub!(/§/u,'\S') #latex: space between next character not preserved? #str.gsub!(/§ /,'\S ') - str.gsub!(/£/u,'\pounds') - str.gsub!(//,' ') - str.gsub!(/<\/a>/,' ') - str.gsub!(/((?:^|\s)#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url - str.gsub!(/#{Mx[:url_o]}\\_(\S+?)#{Mx[:url_c]}/, - '\begin{scriptsize}\url{\1}\end{scriptsize}') #special case \{ e.g. \}http://url - str.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, - '\begin{scriptsize}\\url{\1}\end{scriptsize}') #specially escaped url no decoration + str=str.gsub(/&\S+?;/,' '). + gsub(/§/u,'\S'). #latex: space between next character not preserved? #str.gsub(/§ /,'\S ') + gsub(/£/u,'\pounds'). + gsub(//,' '). + gsub(/<\/a>/,' '). + gsub(/((?:^|\s)#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}\\_(\S+?)#{Mx[:url_c]}/, + '\begin{scriptsize}\url{\1}\end{scriptsize}'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, + '\begin{scriptsize}\\url{\1}\end{scriptsize}') #specially escaped url no decoration unless is=='code' - str.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, + str=str.gsub(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start - else #code-block: angle brackets special characters, note _ already escaped - str.gsub!(/\\_/m,'{\UseTextSymbol{OML}{>}}') end - str.gsub!(/<:ee>/,'') - str.gsub!(//,' ') + str=str.gsub(/<:ee>/,''). + gsub(//,' '). #proposed change, insert, but may be redundant - str.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} ") # Work Area - str.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}') - str.gsub!(/(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}') - str.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}') - str.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}') # ulem - str.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''") # quote #CHECK - str.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}') # ulem - str.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}') # ulem - str.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$") - str.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") - str.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\begin{monosp}\1\end{monosp}') + gsub(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). # Work Area + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}'). + gsub(/(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}'). # ulem + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''"). # quote #CHECK + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}'). # ulem + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}'). # ulem + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$"). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$"). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\begin{monosp}\1\end{monosp}') unless is=='code' - str.gsub!(/"(.+?)"/,'“\1”') # quote marks / quotations open & close " need condition exclude for code - str.gsub!(/\s+"/,' “') # open " - str.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*"/,'\1“') #fix Mx[:lv_o] # open " - str.gsub!(/"(\s|\.|,|:|;)/,'”\1') # close " - str.gsub!(/"(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*$/,'”\1') #fix Mx[:lv_o] # close " - str.gsub!(/"(\.|,)/,'”') # close " - str.gsub!(/\s+'/,' `') # open ' - str.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`') #fix Mx[:lv_o] # open ' + str=str.gsub(/"(.+?)"/,'“\1”'). # quote marks / quotations open & close " need condition exclude for code + gsub(/\s+"/,' “'). # open " + gsub(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*"/,'\1“'). #fix Mx[:lv_o] # open " + gsub(/"(\s|\.|,|:|;)/,'”\1'). # close " + gsub(/"(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*$/,'”\1'). #fix Mx[:lv_o] # close " + gsub(/"(\.|,)/,'”'). # close " + gsub(/\s+'/,' `'). # open ' + gsub(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`') #fix Mx[:lv_o] # open ' end - str.gsub!(/(|<\/font>)/,'') - str.gsub!(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1') + str=str.gsub(/(|<\/font>)/,''). + gsub(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1') str end def xetex_special_characters_3(str) - str.gsub!(/])/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder - str.gsub!(/([^<][^b][^r]\s+)\/>/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + str=str.gsub(/])/,'\1'). # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + gsub(/([^<][^b][^r]\s+)\/>/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder while str =~/(https?:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text #FIX - str.gsub!(/(https?:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') + str=str.gsub(/(https?:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') end - str.gsub!(/<=tilde>/,'{$\tilde$}') - str.gsub!(/(https?:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text #FIX - str.gsub!(/<=hash>/,'{\#}') + str=str.gsub(/<=tilde>/,'{$\tilde$}'). + gsub(/(https?:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2'). #hash in urls \href treated differently from text #FIX + gsub(/<=hash>/,'{\#}') while str =~/(https?:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text #FIX - str.gsub!(/(https?:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') + str=str.gsub(/(https?:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') end - str.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 - str.gsub!(/<=copymark>\s*(.+)/, - '^\copyright \textnormal{\1} \2') # watch likely to be problematic + str=str.gsub(/<=amp>/,'{\\\&}'). #changed ... 2005 + gsub(/<=copymark>\s*(.+)/, + '^\copyright \textnormal{\1} \2') # watch likely to be problematic str end def special_characters_safe_close(str) - str.gsub!(/<=tilde>/,'{$\tilde$}') - str.gsub!(/<=hash>/,'{\#}') - str.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 - str.gsub!(/<=copymark>\s*(.+)/, - '^\copyright \textnormal{\1} \2') # watch likely to be problematic - str + str=str.gsub(/<=tilde>/,'{$\tilde$}'). + gsub(/<=hash>/,'{\#}'). + gsub(/<=amp>/,'{\\\&}'). #changed ... 2005 + gsub(/<=copymark>\s*(.+)/, + '^\copyright \textnormal{\1} \2') # watch likely to be problematic end def special_characters_code_fix(str) - str.gsub!(/<=tilde>/,'{$\tilde$}') + str=str.gsub(/<=tilde>/,'{$\tilde$}') str end def special_characters_unsafe_1(str) #depreciated, make obsolete # some substitutions are sequence sensitive, rearrange with care. - str.gsub!(/\\textbackslash (copyright|clearpage|newpage)/,"\\\\\\1") #kludge bad solution, find out where tail is sent through specChar ! + str=str.gsub(/\\textbackslash (copyright|clearpage|newpage)/,"\\\\\\1") #kludge bad solution, find out where tail is sent through specChar ! str end def special_characters #special characters - some substitutions are sequence sensitive, rearrange with care. @@ -1393,8 +1391,8 @@ WOK end def special_word_break_points str=@txt - str.gsub!(/([_,.;:\/|=])/,'\1\-') - str.gsub!(/(--)(\S{4,})/,'\1\-\2') + str=str.gsub(/([_,.;:\/|=])/,'\1\-'). + gsub(/(--)(\S{4,})/,'\1\-\2') @txt=str end def special_number_break_points @@ -1416,7 +1414,7 @@ WOK end def special_characters_code str=@txt - str.gsub!(/ \\\\([ #{Mx[:br_nl]}]+|$)/,' \textbackslash\textbackslash\hardspace\1') + str=str.gsub(/ \\\\([ #{Mx[:br_nl]}]+|$)/,' \textbackslash\textbackslash\hardspace\1') str end end diff --git a/lib/sisu/v3dv/xhtml.rb b/lib/sisu/v3dv/xhtml.rb index f444323a..bf1c964a 100644 --- a/lib/sisu/v3dv/xhtml.rb +++ b/lib/sisu/v3dv/xhtml.rb @@ -135,12 +135,12 @@ module SiSU_XHTML end protected def embedded_endnotes(dob='') - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, - '\1\2 ') - dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, - '\1\2 ') - dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, - '\1\2 ') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, + '\1\2 '). + gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, + '\1\2 '). + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, + '\1\2 ') 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]})/) @@ -148,26 +148,26 @@ module SiSU_XHTML s=e.to_s util=SiSU_TextUtils::Wrap.new(s,70) wrap=util.line_wrap - wrap.gsub!(/^(\d+)\s+(.+?)\s*\Z/m, < #{Ax[:tab]*2}\\1. \\2 #{Ax[:tab]*1} WOK -) - wrap.gsub!(/^([*+]\d+)\s+(.+?)\s*\Z/m, < #{Ax[:tab]*2}\\1 \\2 #{Ax[:tab]*1} WOK -) - wrap.gsub!(/^([*+]+)\s+(.+?)\s*\Z/m, < #{Ax[:tab]*2}\\1 \\2 #{Ax[:tab]*1} WOK ) #KEEP alternative presentation of endnotes -# wrap.gsub!(/^(\d+)\s+(.+?)\s*\Z/m, < ##{Ax[:tab]*2}\\1. \\2 ##{Ax[:tab]*1}

@@ -200,8 +200,8 @@ WOK else lv=nil end extract_endnotes(dob) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'\1') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'\1'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean util=SiSU_TextUtils::Wrap.new(dob.obj,70) wrapped=util.line_wrap @@xml[:body] << if defined? dob.ocn @@ -219,9 +219,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]}/,'\1') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean + dob.obj=dob.obj.strip. + gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'\1'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean @@xml[:body] << %{#{Ax[:tab]*0}} @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} @@xml[:body] << %{#{Ax[:tab]*1}#{named}#{Ax[:tab]*1}} @@ -232,9 +232,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]}/,'\1') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean + dob.obj=dob.obj.strip. + gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'\1'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean @@xml[:body] << %{#{Ax[:tab]*0}} @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} @@xml[:body] << %{#{Ax[:tab]*1}#{named}#{Ax[:tab]*1}} @@ -245,7 +245,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}} @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} @@xml[:body] << %{#{Ax[:tab]*1}#{named}#{Ax[:tab]*1}} @@ -256,8 +256,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}} @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} @@xml[:body] << %{#{Ax[:tab]*1}#{named}#{Ax[:tab]*1}} @@ -342,7 +341,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| @@ -379,7 +378,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 @@ -393,7 +392,7 @@ WOK 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 diff --git a/lib/sisu/v3dv/xhtml_table.rb b/lib/sisu/v3dv/xhtml_table.rb index e06cdaae..cea438a2 100644 --- a/lib/sisu/v3dv/xhtml_table.rb +++ b/lib/sisu/v3dv/xhtml_table.rb @@ -78,8 +78,8 @@ module SiSU_XHTML_Table table_row_with_columns=table_row.split(Mx[:tc_p]) trc,nc=[],0 table_row_with_columns.each do |c| - c.gsub!(/^~$/,'') # tilde / empty cell - c.gsub!(/<:br>/,'
') + c=c.gsub(/^~$/,''). # tilde / empty cell + gsub(/<:br>/,'
') trc <<= if table_obj.head_ and nr==0; %{
} else %{} end diff --git a/lib/sisu/v3dv/xml.rb b/lib/sisu/v3dv/xml.rb index a0755375..776c0376 100644 --- a/lib/sisu/v3dv/xml.rb +++ b/lib/sisu/v3dv/xml.rb @@ -134,12 +134,12 @@ module SiSU_XML_SAX end protected def embedded_endnotes(dob='') - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, - '\1\2 ') - dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, - '\1\2 ') - dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, - '\1\2 ') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, + '\1\2 '). + gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, + '\1\2 '). + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, + '\1\2 ') 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]})/) @@ -147,7 +147,7 @@ module SiSU_XML_SAX s=e.to_s util=SiSU_TextUtils::Wrap.new(s,70) wrap=util.line_wrap - wrap.gsub!(/^(\d+)\s+(.+?)\s*\Z/m, < #{Ax[:tab]*2}\\1 #{Ax[:tab]*2} @@ -155,8 +155,8 @@ module SiSU_XML_SAX #{Ax[:tab]*2} #{Ax[:tab]*1} WOK -) - wrap.gsub!(/^([*+]\d+)\s+(.+?)\s*\Z/m, < #{Ax[:tab]*2}\\1 #{Ax[:tab]*2} @@ -164,8 +164,8 @@ WOK #{Ax[:tab]*2} #{Ax[:tab]*1} WOK -) - wrap.gsub!(/^([*+]+)\s+(.+?)\s*\Z/m, < #{Ax[:tab]*2}\\1 #{Ax[:tab]*2} @@ -211,8 +211,8 @@ WOK else lv=nil end extract_endnotes(dob) - dob.obj.gsub!(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'\1') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'\1'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean #if defined? dob.obj #t_ograph="#{dob.obj}" util=SiSU_TextUtils::Wrap.new(dob.obj,70) @@ -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]}/,'\1') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'\1'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean dob=@trans.markup_block(dob) - dob.obj.strip! + dob.obj=dob.obj.strip @@xml[:body] << %{#{Ax[:tab]*0}} @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} @@xml[:body] << %{#{Ax[:tab]*1}#{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]}/,'\1') #footnote/endnote clean - dob.obj.gsub!(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'\1'). #footnote/endnote clean + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean dob=@trans.markup_group(dob) - dob.obj.strip! + dob.obj=dob.obj.strip @@xml[:body] << %{#{Ax[:tab]*0}} @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} @@xml[:body] << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} @@ -262,8 +262,8 @@ WOK end def poem_structure(dob='') dob=@trans.markup_group(dob) - #dob.obj.gsub!(/\s\s/,'  ') - dob.obj.strip! + #dob.obj.gsub(/\s\s/,'  ') + dob.obj=dob.obj.strip @@xml[:body] << %{#{Ax[:tab]*0}} @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} @@xml[:body] << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} @@ -273,8 +273,7 @@ WOK end def code_structure(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}} @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} @@xml[:body] << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} @@ -380,7 +379,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| @@ -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 @@ -435,7 +434,7 @@ WOK 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 diff --git a/lib/sisu/v3dv/xml_dom.rb b/lib/sisu/v3dv/xml_dom.rb index dd4dcd44..ae45100d 100644 --- a/lib/sisu/v3dv/xml_dom.rb +++ b/lib/sisu/v3dv/xml_dom.rb @@ -130,12 +130,12 @@ module SiSU_XML_DOM end protected def xml_markup(dob='') - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, - '\1\2 ') - dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, - '\1\2 ') - dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, - '\1\2 ') + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/, + '\1\2 '). + gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/, + '\1\2 '). + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, + '\1\2 ') end def xml_head metadata=SiSU_Metadata::Summary.new(@md).xml_dom.metadata @@ -309,27 +309,24 @@ WOK end def block_structure(dob) dob=@trans.markup_block(dob) #decide check & FIX - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m, - '\1\2 ') - dob.obj.strip! + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m, + '\1\2 ').strip dob end def group_structure(dob) dob=@trans.markup_group(dob) #decide check & FIX - dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m, - '\1\2 ') - dob.obj.strip! + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m, + '\1\2 ').strip dob end def poem_structure(dob) dob=@trans.markup_group(dob) #decide check & FIX - dob.obj.strip! + dob.obj=dob.obj.strip dob end def code_structure(dob) dob=@trans.markup_group(dob) #decide check & FIX - dob.obj.gsub!(/\s\s/,'  ') - dob.obj.strip! + dob.obj=dob.obj.gsub(/\s\s/,'  ').strip dob end def table_structure(dob) #tables @@ -450,7 +447,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 @content_flag=true @@ -497,7 +494,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[:head],@@xml[:body],@@xml[:tail]=[],[],[] # check whether should be nil end @@ -512,7 +509,7 @@ WOK SiSU_Env::FileOp.new(@md).mkdir filename_xml=@file.write_file.xml_dom @data.each do |str| - str.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') + str=str.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') filename_xml.puts str unless str.empty? end filename_xml.close diff --git a/lib/sisu/v3dv/xml_fictionbook.rb b/lib/sisu/v3dv/xml_fictionbook.rb index 8a0819eb..8fe1e7c1 100644 --- a/lib/sisu/v3dv/xml_fictionbook.rb +++ b/lib/sisu/v3dv/xml_fictionbook.rb @@ -151,11 +151,11 @@ WOK @data.each do |para| @endnotes << para.scan(/~\{(.+?)\}~/m) end - @endnotes.flatten! + @endnotes=@endnotes.flatten end def endnotes @endnotes.each do |endnote| - endnote.strip! + endnote=endnote.strip endnote=@trans.markup_fictionbook(endnote) endnote="

#{endnote}

" util=SiSU_TextUtils::Wrap.new(endnote,80,10) @@ -171,7 +171,7 @@ WOK put(tail) end def markup(para,type='') - para.strip! + para=para.strip para=@trans.markup_fictionbook(para) para=if type.empty?; "

#{para}

" else "<#{type}>

#{para}

" diff --git a/lib/sisu/v3dv/xml_format.rb b/lib/sisu/v3dv/xml_format.rb index e3e4b380..db3e8f25 100644 --- a/lib/sisu/v3dv/xml_format.rb +++ b/lib/sisu/v3dv/xml_format.rb @@ -1372,17 +1372,18 @@ WOK end def gsub_body #fix - case @txt + @txt=case @txt when /^\s*\((i+|iv|v|vi+|ix|x|xi+)\)/ - @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1(\2)') + @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1(\2)') when /^\s*\(?(\d|[a-z])+\)/ - @txt.gsub!(/^\((\d+|[a-z])+\)/,'(\1)') - @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1(\2)') + @txt.gsub(/^\((\d+|[a-z])+\)/,'(\1)'). + gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1(\2)') when /^\s*\d{1,3}\.\s/ - @txt.gsub!(/^\s*(\d+\.)/,'\1') + @txt.gsub(/^\s*(\d+\.)/,'\1') when /^\s*[A-Z]\.\s/ - @txt.gsub!(/^\s*([A-Z]\.)/,'\1') + @txt.gsub(/^\s*([A-Z]\.)/,'\1') + else @txt end end def bold_para @@ -1395,8 +1396,8 @@ WOK #{@vz.table_close}} end def bold_header - @txt.gsub!(/[1-9]~(\S+)/,'') - @txt.gsub!(/[1-9]~/,'') + @txt=@txt.gsub(/[1-9]~(\S+)/,''). + gsub(/[1-9]~/,'') %{

#{@txt}

@@ -1492,9 +1493,9 @@ WOK note='' if txt =~/(#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}\s*)/m note=$1 - note.gsub!(/[\n\s]+/m,' ') - txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') - txt.gsub!(/ \d+<\/sup> /m,'') + note=note.gsub(/[\n\s]+/m,' ') + txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' '). + gsub(/ \d+<\/sup> /m,'') end %{<#{tag} class="#{attrib}"> #{txt} #{note} @@ -1508,7 +1509,7 @@ WOK end #% para sisu def header_sub(tag,attrib) - @txt.gsub!(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + @txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') %{
#{@p_num.ocn_display} diff --git a/lib/sisu/v3dv/xml_md_oai_pmh_dc.rb b/lib/sisu/v3dv/xml_md_oai_pmh_dc.rb index 8397b15a..eb2bb09c 100644 --- a/lib/sisu/v3dv/xml_md_oai_pmh_dc.rb +++ b/lib/sisu/v3dv/xml_md_oai_pmh_dc.rb @@ -184,7 +184,7 @@ WOK end def meta_content_clean(content='') unless content.nil? - content.tr!('"',"'") + content=content.tr('"',"'") end content end diff --git a/lib/sisu/v3dv/xml_tables.rb b/lib/sisu/v3dv/xml_tables.rb index 7782bb88..5457a2fc 100644 --- a/lib/sisu/v3dv/xml_tables.rb +++ b/lib/sisu/v3dv/xml_tables.rb @@ -83,10 +83,10 @@ module SiSU_Tables def table m=@parablock[//,1] @@tablefoot << m if m - @parablock.gsub!(//,'') + @parablock=@parablock.gsub(//,'') @@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+);\w\d+;\w\d+#{Mx[:gr_c]}/u, + @parablock=@parablock.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+);\w\d+;\w\d+#{Mx[:gr_c]}/u, %{\n#{@ocn}
} + - %{#{para_table}}) - parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{} + - %{#{para_table}}) - parablock.gsub!(/#{Mx[:tc_c]}/, '
} + + %{#{para_table}}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{} + + %{#{para_table}}). + gsub(/#{Mx[:tc_c]}/, '
} + - %{#{para_table}}) - parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{} + - %{#{para_table}}) - parablock.gsub!(/#{Mx[:tc_c]}/, '
} + + %{#{para_table}}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{} + + %{#{para_table}}). + gsub(/#{Mx[:tc_c]}/, '
#{c}#{c}
}) end if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ @@ -96,28 +96,28 @@ module SiSU_Tables end if @@tablehead==1 if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, %{\n") + #{@vz.paragraph_table_xml}}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{\n") @@tablehead=0 end @parablock else - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, %{\n\n") + #{@vz.paragraph_table_xml}}). + gsub(/#{Mx[:tc_c]}/,"\n\n\n") end @parablock end @@ -159,7 +159,7 @@ module SiSU_Tables def table m=@parablock[//,1] @@tablefoot << m if m - @parablock.gsub!(//,'') + @parablock=@parablock.gsub(//,'') @@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+);\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head($1) end @@ -173,26 +173,26 @@ module SiSU_Tables if @@tablehead==1 if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true)) + @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true)) end if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true)) + @parablock=@parablock.gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true)) end if @parablock =~/#{Mx[:tc_c]}/ - @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close(true)) + @parablock=@parablock.gsub(/#{Mx[:tc_c]}/,table_row_close(true)) end @@tablehead=0 end @parablock else if @parablock =~/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1)) + @parablock=@parablock.gsub(/^#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1)) end if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1)) + @parablock=@parablock.gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1)) end if @parablock =~/#{Mx[:tc_c]}/ - @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close) + @parablock=@parablock.gsub(/#{Mx[:tc_c]}/,table_row_close) end @parablock end -- cgit v1.2.3
- #{@vz.paragraph_table_xml}}) - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{ - #{@vz.paragraph_table_xml}}) - @parablock.gsub!(/#{Mx[:tc_c]}/,"\n
+ #{@vz.paragraph_table_xml}}). + gsub(/#{Mx[:tc_c]}/,"\n
- #{@vz.paragraph_table_xml}}) - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{ + #{@vz.paragraph_table_xml}}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{ - #{@vz.paragraph_table_xml}}) - @parablock.gsub!(/#{Mx[:tc_c]}/,"\n