aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3dv/texpdf_format.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3dv/texpdf_format.rb')
-rw-r--r--lib/sisu/v3dv/texpdf_format.rb424
1 files changed, 211 insertions, 213 deletions
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</a>#{@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</a>#{@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=~/\<!f(.+?)!\>/ # not tested table footer if any
tablefoot=$1
- r.gsub!(/\<!f(.+?)!\>/,'')
+ r=r.gsub(/\<!f(.+?)!\>/,'')
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=~/\<!f(.+?)!\>/ # not tested table footer if any
tablefoot=$1
- r.gsub!(/\<!f(.+?)!\>/,'')
+ r=r.gsub(/\<!f(.+?)!\>/,'')
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!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ')
- str.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript
- str
+ gsub(/<sup><font face=symbol>&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!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ')
- str.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript
- str
+ gsub(/<sup><font face=symbol>&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!(/&nbsp;|#{Mx[:nbsp]}/,'~') # ~ character for hardspace
- str.gsub!(/&/,'<=amp>')
+ str.gsub(/&nbsp;|#{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!(/<a href=".+?">/,' ')
- 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(/<a href=".+?">/,' ').
+ 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 <url> 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}{<}}')
- 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+>(.+?)<\/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+>(.+?)<\/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.*?>|<\/font>)/,'')
- str.gsub!(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1')
+ str=str.gsub(/(<font.*?>|<\/font>)/,'').
+ gsub(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1')
str
end
def xetex_special_characters_3(str)
- str.gsub!(/<br(\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.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(/<br(\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
+ 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