diff options
Diffstat (limited to 'lib/sisu/v0/texpdf_format.rb')
| -rw-r--r-- | lib/sisu/v0/texpdf_format.rb | 447 | 
1 files changed, 251 insertions, 196 deletions
diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 0fa439f0..5c2b7ec5 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -68,7 +68,7 @@ module SiSU_TeX_Pdf      @@sys=SiSU_Env::System_call.new      @@tex_backslash="\\\\"      @@tilde='\\\\\\~' #?? debug crazy -    @@tex_pattern_margin_number=/\\begin\{tiny\}~\\end\{tiny\}\{\\marginpar.+?\}\}\}/ +    @@tex_pattern_margin_number=/\\begin\{tiny\}\\hspace\{0mm\}\\end\{tiny\}\{\\marginpar.+?\}\}\}/      @@tableheader={        'a4' => { :p => 0, :l => 0 },        'a5' => { :p => 0, :l => 0 }, @@ -78,8 +78,24 @@ module SiSU_TeX_Pdf      }      @@sys=SiSU_Env::System_call.new      @@dp=nil -    def initialize(md,string,string1=nil) -      @md,@string,@string1=md,string,string1 +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt =t_o[:txt]            || nil +        @title =t_o[:title]        || nil +        @subtitle =t_o[:subtitle]  || nil +        @ps =t_o[:paper_size]      || nil +        @ocn =t_o[:ocn]            || nil +        @words =t_o[:words]        || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        p t_o.class +        p caller +      end +        if defined? @md.image \        and @md.image =~/center/          @center_begin,@center_end='\begin{center}','\end{center}' @@ -90,12 +106,11 @@ module SiSU_TeX_Pdf        @tx=SiSU_Env::Get_init.instance.tex        @url_brace=SiSU_Viz::Skin.new.url_decoration        @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine -      @ps=string1 if string1=~/(?:a4|letter|legal|book|a5|b5)/i      end      def longtable_landscape        @end_table='\end{longtable}'        @row_break='\\\\\\' -      if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] +      if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u]          no_of_cols,cols_width,ocn=$1,$2,$3          tw=case @ps          when /a4/i;      @tx.a4.landscape.w     #European default, SiSU default @@ -106,10 +121,9 @@ module SiSU_TeX_Pdf          else             @tx.a4.landscape.w     #default currently A4          end          textwidth=(tw.to_i/2) - 24 -        @@tableheader[@ps][:l]=1 if @string =~/#{Mx[:gr_o]}Th/ +        @@tableheader[@ps][:l]=1 if @txt =~/#{Mx[:gr_o]}Th/          w=cols_width.split(/;\s*/)          @@number_of_cols=no_of_cols ||=@@number_of_cols -        #@@number_of_cols=0 unless @@number_of_cols.to_i > 0          @colW=[]          @colW << '{'          w.each  do |x| @@ -122,36 +136,35 @@ module SiSU_TeX_Pdf          @colW=@colW.join          @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" +            "\\begin{tiny}\n\\begin{longtable}#@colW\n" -        @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table) +        @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table")        end -      if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ -        @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") +      if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ +        @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}")        end -      @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') +      @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'')        if @@tableheader[@ps][:l] == 1 -        if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u -          tablefoot=@string[/\<!f(.+?)!\>/,1] -          @string.gsub!(/\<!f(.+?)!\>/,'') -          @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') -          @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") -          @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u +          tablefoot=@txt[/\<!f(.+?)!\>/,1] +          @txt.gsub!(/\<!f(.+?)!\>/,'') +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') +          @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") +          @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot            @@tableheader[@ps][:l]=0 -          #@@tableheader[@ps][:l],@@number_of_cols=0,0          end        else -        if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u -          @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,'\1&') -          @string.gsub!(/&\s*$/," #@row_break") +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') +          @txt.gsub!(/&\s*$/," #@row_break")          end        end -      @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string -      else @string +      @txt=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @txt +      else @txt        end      end      def longtable_portrait        @end_table='\end{longtable}'        @row_break='\\\\\\' -      if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] +      if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u]          no_of_cols,cols_width,ocn=$1,$2,$3          tw=case @ps          when /a4/i;      @tx.a4.portrait.w     #European default, SiSU default @@ -162,15 +175,14 @@ module SiSU_TeX_Pdf          else             @tx.a4.portrait.w     #default currently A4          end          textwidth=tw.to_i - 20 -        @@tableheader[@ps][:p]=1 if @string =~/#{Mx[:gr_o]}Th/ +        @@tableheader[@ps][:p]=1 if @txt =~/#{Mx[:gr_o]}Th/          w=cols_width.split(/;\s*/)          @@number_of_cols=no_of_cols ||=@@number_of_cols          @colW=[]          @colW << '{'          w.each  do |x|            x.strip! -          x=(x.to_i * textwidth)/100 -          #x=(x.to_i/100.0 * 160) +          x=(x.to_i * textwidth)/100 #x=(x.to_i/100.0 * 160)            col_w=x.to_s # x.gsub(/.+/,'l\|') #unless x.nil?            @colW << "p{#{col_w}mm}" if col_w          end @@ -178,30 +190,29 @@ module SiSU_TeX_Pdf          @colW=@colW.join          @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" +            "\\begin{tiny}\n\\begin{longtable}#@colW\n" -        @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table") +        @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table)        end -      if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ -        @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") +      if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ +        @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}")        end -      @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') +      @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'')        if @@tableheader[@ps][:p] == 1 -        if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u -          tablefoot=@string[/\<!f(.+?)!\>/,1] -          @string.gsub!(/\<!f(.+?)!\>/,'') -          @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') -          @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") -          @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u +          tablefoot=@txt[/\<!f(.+?)!\>/,1] +          @txt.gsub!(/\<!f(.+?)!\>/,'') +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') +          @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") +          @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot            @@tableheader[@ps][:p]=0 -          #@@tableheader[@ps][:p],@@number_of_cols=0,0          end        else -        if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u -          @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') -          @string.gsub!(/&\s*$/," #@row_break") +        if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u +          @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') +          @txt.gsub!(/&\s*$/," #@row_break")          end        end -      @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string -      else @string +      @txt=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @txt +      else @txt        end      end      def scopedtable @@ -210,7 +221,7 @@ module SiSU_TeX_Pdf        @end_table="\\end{tabular}"        @row_break='\\\\\\\\'        @break_page="#@row_break\n#@row_break \n" -      if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/u] +      if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/u]          no_of_cols,cols_width=$1,$2          @w=cols_width.split(/;\s*/)          @colW=[] @@ -219,28 +230,28 @@ module SiSU_TeX_Pdf            @colW << "p{#{col_w}cm}" if col_w          end          @start_table="\\begin{tabular}{#@colW}\n" -        @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#@start_table}") +        @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#@start_table}")        end -      if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ -        @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") +      if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ +        @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table")          @@table_pg_break_counter=1        end -      if @string =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u +      if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u          if @@table_pg_break_counter == 28 # taken from 34 ideal for portrait to 28 which suits landscape -          @string="\n\n#@end_table \n#@break_page#@start_table\n" +          @txt="\n\n#@end_table \n#@break_page#@start_table\n"            @@table_pg_break_counter=1          else -          @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') +          @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'')            @@table_pg_break_counter+=1 -          tablefoot=@string[/\<!f(.+?)!\>/,1] -          @string.gsub!(/\<!f(.+?)!\>/,'') +          tablefoot=@txt[/\<!f(.+?)!\>/,1] +          @txt.gsub!(/\<!f(.+?)!\>/,'')          end        end -      if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u -        @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u,"\\1&") -        @string.gsub!(/&\s*$/,"#@row_break") +      if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u +        @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u,"\\1&") +        @txt.gsub!(/&\s*$/,"#@row_break")        end -      @string +      @txt      end      def heading_major(para,lev) #\emph{        title=@md.title @@ -264,90 +275,90 @@ module SiSU_TeX_Pdf  para      end      def level1 -      heading_major(@string,1) +      heading_major(@txt,1)      end      def level2 -      heading_major(@string,2) +      heading_major(@txt,2)      end      def level3 -      heading_major(@string,3) +      heading_major(@txt,3)      end      def level4 -      @string.strip! if @string -      @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') -      cont_ln=@string.dup +      @txt.strip! if @txt +      @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') +      cont_ln=@txt.dup        cont_ln.gsub!(@@tex_pattern_margin_number,'')        cont_ln.gsub!(/#{@@tex_backslash*2}/,"#{@@tex_backslash*4}") # added w42        cont_ln.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'')        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        title=@md.title -      @string.gsub!(/#{@md.lv4}\s+(#{@md.lv4})/m,'\1') -      if @string =~/#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|<:4-endnotes>/ +      @txt.gsub!(/#{@md.lv4}\s+(#{@md.lv4})/m,'\1') +      if @txt =~/#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|<:4-endnotes>/          # watch exclusion removes endnotes marker from pdf 2003w03 -        @string.gsub!(/.+/m,'') +        @txt.gsub!(/.+/m,'')        end -      if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! +      if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings!          cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ')          cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')        end -      if @string !~/#{Mx[:lv_o]}4:/ -        @string.gsub!(/(#{@md.lv4}.*)\n?$/m,"\\subsubsection*{\\1} +      if @txt !~/#{Mx[:lv_o]}4:/ +        @txt.gsub!(/(#{@md.lv4}.*)\n?$/m,"\\subsubsection*{\\1}  \\addcontentsline{toc}{subsection}{#{cont_ln}}  \\markright{#{title}}")        else -        @string.gsub!(/^\s*#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.*)?\n?$/m,"\\subsubsection*{\\1} +        @txt.gsub!(/^\s*#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.*)?\n?$/m,"\\subsubsection*{\\1}  \\addcontentsline{toc}{subsection}{#{cont_ln}}  \\markright{#{title}}")        end -      @string.gsub!(/#{@md.lv4}\s*(.marginpar)/m,'\1') +      @txt.gsub!(/#{@md.lv4}\s*(.marginpar)/m,'\1')      end      def level5 -      # 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 \\@string*, same for next section 2002w46 -      @string.strip! if @string -      @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') -      cont_ln=@string.dup +      # 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 +      @txt.strip! if @txt +      @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') +      cont_ln=@txt.dup        cont_ln.gsub!(@@tex_pattern_margin_number,'')        cont_ln.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'')        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 -      @string.gsub!(/#{@md.lv5}\s+(#{@md.lv5})/m,'\1') -      if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! +      @txt.gsub!(/#{@md.lv5}\s+(#{@md.lv5})/m,'\1') +      if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings!          cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ')          cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')        end -      if @string !~/#{Mx[:lv_o]}5:/ -        @string.gsub!(/(#{@md.lv5}.*?)\n?$/m,"\\subsubsection*{\\1} +      if @txt !~/#{Mx[:lv_o]}5:/ +        @txt.gsub!(/(#{@md.lv5}.*?)\n?$/m,"\\subsubsection*{\\1}  \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\  }")        else -        @string.gsub!(/^\s*#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, +        @txt.gsub!(/^\s*#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m,            "\\subsubsection*{\\1}  \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\  }")        end -      @string.gsub!(/#{@md.lv5}\s*(.marginpar)/m,'\1') +      @txt.gsub!(/#{@md.lv5}\s*(.marginpar)/m,'\1')      end      def level6 -      # 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@string*, same for previous section 2002w46 -      @string.strip! if @string -      @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') -      cont_ln=@string.dup +      # 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 +      @txt.strip! if @txt +      @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') +      cont_ln=@txt.dup        cont_ln.gsub!(@@tex_pattern_margin_number,'')        cont_ln.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'')        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 -      @string.gsub!(/#{@md.lv6}\s+(#{@md.lv6})/m,'\1') -      if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! +      @txt.gsub!(/#{@md.lv6}\s+(#{@md.lv6})/m,'\1') +      if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings!          cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ')          cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')        end -      @string.gsub!(/(#{@md.lv6}.*)\n?$/m, -        "\\subsubsection*{\\1}") if (@string !~/#{Mx[:lv_o]}6:/) -      @string.gsub!(/^\s*#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, +      @txt.gsub!(/(#{@md.lv6}.*)\n?$/m, +        "\\subsubsection*{\\1}") if (@txt !~/#{Mx[:lv_o]}6:/) +      @txt.gsub!(/^\s*#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m,          '\subsubsection*{\1}') -      @string.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1') +      @txt.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1')        #end BUGWATCH      end      def indent(lev) @@ -362,25 +373,25 @@ para        when /8/; '70mm'        when /9/; '80mm'        end -      @string.gsub!(/#{Mx[:pa_o]}:i#{lev}#{Mx[:pa_c]}\s*(.*)/m, +      @txt.gsub!(/#{Mx[:pa_o]}:i#{lev}#{Mx[:pa_c]}\s*(.*)/m,          "\\begin{ParagraphIndent}{#{indent}}\\1  \\end{ParagraphIndent}}")      end      def symbol_graphic        dir=SiSU_Env::Info_env.new(@md.fns) -      image='c_' + /<:=\s*(\S+?)\s*>/m.match(@string).captures.join + '.png' #watch +      image='c_' + /<:=\s*(\S+?)\s*>/m.match(@txt).captures.join + '.png' #watch        if FileTest.file?("#{dir.path.image_source_tex}/#{image}") -        @string.gsub!(/<:=\s*(\S+?)\s*>/, +        @txt.gsub!(/<:=\s*(\S+?)\s*>/,            "\\includegraphics*[width=11pt]{#{dir.path.image_source_tex}/c_\\1.png}")        else          tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search path: #{dir.path.image_source_tex}")          tell.error2 unless @md.cmd =~/q/ -        @string.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! +        @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile !        end      end      def image        dir=SiSU_Env::Info_env.new(@md.fns) -      image,m=/<:image\s+(\S+)\s+.+?width=``(\d+)''.+?>/m.match(@string).captures +      image,m=/#{Mx[:lnk_o]}\s*(\S+)\s+.+?width=``(\d+)''.+?#{Mx[:lnk_c]}/m.match(@txt).captures        width=m[1] || '100'        width=width.to_i*0.4        image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ \ @@ -397,17 +408,17 @@ para          nil        end        if image_source -        @string.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/, +        @txt.gsub!(/#{Mx[:lnk_o]}\s*((?:https?|file|ftp):\/\/\S+)\s+(\S+).+?#{Mx[:lnk_c]}/,            @center_begin + "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{image_source}/\\2}}" + @center_end ) -        @string.gsub!(/<:image\s+(\S+)\s+.+\s+?>/, +        @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,            @center_begin + "\\includegraphics*[width=#{width}pt]{#{image_source}/\\1}" + @center_end ) -      else @string.gsub!(/<:image\s+(\S+)\s+.+\s+?>/,'\1}') +      else @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,'\1}')        end      end      def png #fc missing image check        dir=SiSU_Env::Info_env.new(@md.fns)        # messy clean up -      z=@string[/\\\{(\S.+?)\}(?:image|png)/,1].strip if @string =~ /\\\{\S.+?\}(?:image|png)/ # match operator for z \\ fragile ! +      z=@txt[/#{Mx[:lnk_o]}(\S.+?)#{Mx[:lnk_c]}(?:image|png)/,1].strip if @txt =~ /#{Mx[:lnk_o]}\S.+?#{Mx[:lnk_c]}(?:image|png)/ # match operator for z \\ fragile !        if z #debug 2004w14          image=z[/(\S+?\.(?:png|jpg|gif)\b)/m]          image.gsub!(/\\/,'') @@ -438,30 +449,29 @@ para          nil        end        if image_source -        @string.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/, # fragile match operator\\ fragile ! +        @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/, # fragile match operator\\ fragile !            "#@center_begin\n\\includegraphics*[width=#{width}pt]{#{image_source}/#{image}}#{caption}#@center_end") -      else -        @string.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,'') # fragile match operator\\ fragile ! +      else @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/,'')        end      end      def http_word_mode #(orientation='')        # clean up ! - work area, testing        dir=SiSU_Env::Info_env.new(@md.fns) -      @words=[] -      @url_generic_rgx=/\\\{.+?\\?\}(?:https?|file|ftp):\S+/ -      @string.each do |word| -        @words << if word=~@url_generic_rgx -          if word =~/\\\{(?:.+?)\\?\}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ -            regx_url=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ -            punctuate=/\\\{.+?\\?\}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.join +      @w=[] +      @url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/ +      @words.each do |word| +        @w << if word=~@url_generic_rgx +          if word =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ +            regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ +            punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?([;.,]?(?:\s|$))/.match(word).captures.join            else -            regx_url=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+)/ +            regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\S+)/              punctuate=''            end            z,url=regx_url.match(word).captures if word =~regx_url            url=url.strip -          if word =~/\{\s*\S+\.?(?:png|jpg|gif)/ \ -          and word=~/\s+\d+x\d+\s+/ +          if word =~/#{Mx[:lnk_o]}\s*\S+\.?(?:png|jpg|gif)/ \ +          and word=~/\s+\d+x\d+(\s+|\s*#{Mx[:lnk_c]})/              image,x,y=z.scan(/\S+/)              image.gsub!(/\\/,'')              width=if z =~/(\d+)x\d*/ @@ -486,56 +496,57 @@ para                "{\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}"              else ''              end -          elsif word =~/\{\s*(\S+\.?\.(?:png|jpg|gif))/ +          elsif word =~/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/              tell=SiSU_Screen::Ansi.new(@md.cmd,%{document built without image: "#{$1}" as image dimensions not provided (& librmagick-ruby is not installed)?\n})              tell.print_grey #unless @opt.cmd =~/q/            end            word=if image #most images fc etc. #% clean up !              word=if @md.fns =~/\.(?:ssm\.)?sst$/ \              and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") -              word=if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ +              word=if word =~ /(#{Mx[:lnk_o]}[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+)/                  "#@center_begin\\\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_local_tex}/#{image}}}#{caption} #@center_end"                end                word              elsif @md.fns =~/\.-ss[tm]$/ \              and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") -              word=if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ +              word=if word =~ /(#{Mx[:lnk_o]}[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+)/                  "#@center_begin\\\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_remote_tex}/#{image}}}#{caption}#@center_end"                end                word              elsif FileTest.file?("#{dir.path.image_source_tex}/#{image}") -              word=if word =~/(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ +              word=if word =~/(#{Mx[:lnk_o]}[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+)/                  "#@center_begin\\\n\\href{#{url}}\n{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/#{image}}}#{caption}#@center_end"                end                word              else                tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search locations: #{dir.path.image_source_local_tex},#{dir.path.image_source_remote_tex} and #{dir.path.image_source_tex}")                tell.error2 unless @md.cmd =~/q/ -              word='' if word =~ /\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/ +              word='' if word =~ /#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/                word              end            else              link=z.strip #[/(.+?)\\/m,1] -            word="\\href{#{url}}{#{link}}#{punctuate}" if word =~/\\\{.+?\\\}(?:https?|file|ftp):\/\/\S+/ +            word="\\href{#{url}}{#{link}}#{punctuate}" if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/              word            end          else word          end        end -      @words=@words.join -      @words +      @txt=@w.join +      @txt      end      def http -      wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) -      @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm,@ps).http_word_mode #GET PAPER SIZE AND USE IT +      wm=@txt.dup.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) +      txt_obj={:words =>wm,:paper_size =>@ps} +      @txt=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http_word_mode #GET PAPER SIZE AND USE IT      end      def title -      @string=SiSU_TeX_Pdf::Special_characters.new(@md,@string).special_characters_safe -      if @string1 -        @string1=SiSU_TeX_Pdf::Special_characters.new(@md,@string1).special_characters_safe -        @string1.gsub!(/\$/,"\\$") -        "\n\\title{#@string#{@@tex_backslash*2} \\textbf{\\normalsize #@string1}\\normalsize}" -      else "\n\\title{#@string}" +      @txt=SiSU_TeX_Pdf::Special_characters.new(@md,@title).special_characters_safe +      if @subtitle +        @subtitle=SiSU_TeX_Pdf::Special_characters.new(@md,@subtitle).special_characters_safe +        @subtitle.gsub!(/\$/,"\\$") +        "\n\\title{#@title#{@@tex_backslash*2} \\textbf{\\normalsize #@subtitle}\\normalsize}" +      else "\n\\title{#@txt}"        end      end      def title_landscape @@ -548,33 +559,49 @@ para        paranumber_display=if @md.markup.inspect =~/no_ocn/ \        or @md.mod.inspect =~/--no-ocn/          '' -      else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@string1\\end{tiny}}}" #ocn object citation numbering +      else "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}#@ocn\\end{tiny}}}" #ocn object citation numbering        end -      if @string !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ -        @string.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect +      if @txt !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ +        @txt.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect        else -        if (@string =~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})/) #watch - in 1-6 is suspect -          @string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #watch - in 1-6 is suspect -          #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\begin{bfseries}\\2 \\end{bfseries}\n") #watch - in 1-6 is suspect -          #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\emph{\\2}\n") #watch - in 1-6 is suspect -          @string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? -          #@string.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? +        if (@txt =~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})/) #watch - in 1-6 is suspect +          @txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #watch - in 1-6 is suspect +          #@txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\begin{bfseries}\\2 \\end{bfseries}\n") #watch - in 1-6 is suspect +          #@txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\emph{\\2}\n") #watch - in 1-6 is suspect +          @txt.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? +          #@txt.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT?          else -          @string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\1\n") -          #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\begin{bfseries}\\1 \\end{bfseries}\n") -          #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\emph{\\1}\n") +          @txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\1\n") +          #@txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\begin{bfseries}\\1 \\end{bfseries}\n") +          #@txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\emph{\\1}\n")          end        end -      @string +      @txt      end    end    class Format_head -    def initialize(md,ps,layout=nil,string1=nil) -      @md,@ps,@layout,@string1=md,ps,layout,string1 +    def initialize(md,t_o) +      @md,@t_o=md,t_o +      if t_o.class == Hash +        @txt =t_o[:txt]            || nil +        #@title =t_o[:title]        || nil +        @subtitle =t_o[:subtitle]  || nil +        @ps =t_o[:paper_size]      || nil +        @ocn =t_o[:ocn]            || nil +        @layout=t_o[:orientation]  || nil +      #elsif t_o.class == Array +      #  @txt =txt[0] +      #elsif t_o.class == String +      #  @txt =txt +      else +        p t_o.class +        p caller +      end +        @tx=SiSU_Env::Get_init.instance.tex        @url_brace=SiSU_Viz::Skin.new.url_decoration        @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine -      @ps=@string if @string=~/(?:a4|letter|legal|book|a5|b5)/i +      @ps=@txt if @txt=~/(?:a4|letter|legal|book|a5|b5)/i      end      def language        @lang=if @md.dc_language[:code] @@ -670,7 +697,7 @@ WOK      def tex_head_paper_landscape(d)        <<WOK  #{tex_head_info} -\\documentclass[#{d[:fontsize]},#{d[:papertype]},#{tex_head_lang}, landscape, titlepage, twocolumn]{scrartcl}        %with titlepage +\\documentclass[#{d[:fontsize]},#{d[:papertype]},#{tex_head_lang},landscape,titlepage,twocolumn]{scrartcl}        %with titlepage  \\setlength{\\textheight}{#{d[:textheight]}mm}  \\setlength{\\textwidth}{#{d[:textwidth]}mm}  \\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}}  \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}  \\setlength{\\topmargin}{#{d[:topmargin]}}  \\setlength{\\headheight}{#{d[:headheight]}} @@ -683,7 +710,7 @@ WOK      def tex_head_paper_portrait_dvi(d)        <<WOK  #{tex_head_info} -\\documentclass[#{d[:fontsize]},#{d[:papertype]},#{tex_head_lang},titlepage]{scrartcl}        %with titlepage +\\documentclass[#{d[:fontsize]},#{d[:papertype]},#{tex_head_lang},titlepage]{scrartcl}      %with titlepage  \\setlength{\\textheight}{#{d[:textheight]}mm}  \\setlength{\\textwidth}{#{d[:textwidth]}mm}  \\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}}  \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}  \\setlength{\\topmargin}{#{d[:topmargin]}}  \\setlength{\\headheight}{#{d[:headheight]}} @@ -729,12 +756,12 @@ WOK        when /landscape/          #d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w          d[:papertype],d[:fontsize]='a4paper','11pt' -        d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-8mm','-8mm','-18mm' +        d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='6mm','6mm','-12mm'          d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','40pt'          d[:marginparsep],d[:marginparwidth]='4mm','8mm'          case @ps #@md.papersize          when /a4/i                            #European default, SiSU default -          d[:papertype],d[:fontsize]='a4paper','12pt' +          d[:papertype],d[:fontsize]='a4paper','11pt'            d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w          when /letter/i                    #U.S. default            d[:papertype],d[:fontsize]='letterpaper','11pt' @@ -782,12 +809,11 @@ WOK        end        if @layout =~/portrait|landscape/        <<WOK -\\usepackage{url}  \\usepackage{alltt}  \\usepackage{thumbpdf}  \\usepackage[#{@tex2pdf},    #{color.strip} -  pdftitle={#@string1}, +  pdftitle={#{@txt}},  %  pdftitle={Untitled},    pdfauthor={LM-sisu-scribe},    pdfsubject={law}, @@ -820,10 +846,11 @@ WOK  \\definecolor{mygreen}{rgb}{0,0.5,0}  \\definecolor{myblue}{rgb}{0,0,0.5}  \\definecolor{mywhite}{rgb}{1,1,1} +\\usepackage{url} +%\\usepackage{breakurl}  WOK -      elsif @string =~/dvi/ +      elsif @txt =~/dvi/        <<WOK -\\usepackage{url}  \\usepackage{alltt}    #{color.strip}    pageanchor=true, @@ -840,6 +867,8 @@ WOK  \\definecolor{mygreen}{rgb}{0,0.5,0}  \\definecolor{myblue}{rgb}{0,0,0.5}  \\definecolor{mywhite}{rgb}{1,1,1} +\\usepackage{url} +%\\usepackage{breakurl}  WOK        end      end @@ -853,13 +882,13 @@ WOK  \\usepackage{graphicx}  \\makeatletter  \\parindent0pt -\\usepackage{mathptmx} +%\\usepackage{mathptmx}  \\usepackage{amssymb}  % amssymb used for backslash  WOK      end      def document_head_with_orientation -      endnotes=("\\usepackage{endnotes}" if @string =~/endnotes?/)||'' #not implemented see also def endnotes +      endnotes=("\\usepackage{endnotes}" if @txt =~/endnotes?/)||'' #not implemented see also def endnotes        language        <<WOK  #{tex_head_paper} @@ -870,8 +899,8 @@ WOK  \\setcounter{tocdepth}{4}  \\makeatletter  #{endnotes} -\\usepackage[multiple,marginal]{footmisc} -% \\setlength\\footnotemargin{40pt} +\\usepackage[multiple,ragged]{footmisc} +\\setlength\\footnotemargin{12pt}  \\usepackage[para]{manyfoot}  \\DeclareNewFootnote{A}  %\\DeclareNewFootnote[para]{A} @@ -922,7 +951,7 @@ WOK      @@flag_code=false      @@tex_backslash="\\\\"      def initialize(md,string) -      @md,@string=md,string +      @md,@txt=md,string        @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern        #@tx=SiSU_Env::Get_init.instance.tex        @url_brace=SiSU_Viz::Skin.new.url_decoration @@ -930,7 +959,7 @@ WOK      end      def pdftex_special_characters_1(string)             # ~ ^ $ & % _ { }  #LaTeX special characters - KEEP list        #p @@utf_8.list -      #@string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) +      #@txt=Iconv.conv('ISO-8859-1', 'UTF-8', @txt)        word=string.scan(/#{Mx[:mk_o]}\S+?#{Mx[:mk_c]}|\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/        para_array=[]        string=if word @@ -958,7 +987,7 @@ WOK        string.gsub!(/.+?<-#>/,'')        string.gsub!(/#{Mx[:br_eof]}|#{Mx[:br_endnotes]}/,'')        #problem sequence -> -      string.gsub!(/&(?:nbsp);/,'<=hardspace>')                                 # < SiSU special character also LaTeX +      string.gsub!(/&(?:nbsp);|#{Mx[:nbsp]}/,'<=hardspace>')                                 # < SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#nbsp#{Mx[:gl_c]}/,'<=hardspace>')                                 # < SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<=lt>')                                     # < SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'<=gt>')                                     # > SiSU special character also LaTeX @@ -972,7 +1001,7 @@ WOK        string.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-')                                                # - SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+')                                                # + SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',')                                                # + SiSU special character also LaTeX -      string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @string=~/<:code>/                   # / SiSU special character also LaTeX +      string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/                   # / SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>')                                         # / SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>')                                     # \ SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>')                                    # _ SiSU special character also LaTeX @@ -993,12 +1022,12 @@ WOK        string.gsub!(/\#/,'\#')        string.gsub!(/\%/,'\%')        string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes -      if string !~/^\s*<:image|\}:image\s/ +      if string !~/^\s*#{Mx[:lnk_o]}|#{Mx[:lnk_c]}image\s/          string.gsub!(/_/,'\_')        end        string.gsub!(/\{/,'\{')        #string.gsub!(/\}/,'\}') -      string.gsub!(/ /,'~') # ~ character for hardspace +      string.gsub!(/ |#{Mx[:nbsp]}/,'~') # ~ character for hardspace        # sequence important must appear after removal of { and }        string.gsub!(/&\S+?;/,'') #hmmm        # sequence imortant place before removal of & @@ -1013,11 +1042,15 @@ WOK        string.gsub!(/&\S+?;/,' ')        string.gsub!(/<a href=".+?">/,' ')        string.gsub!(/<\/a>/,' ') -      string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case -      string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url -      string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration +      string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, +        '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url +      string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, +        ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case +      string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, +        '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration        unless @@flag_code -        string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start +        string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, +          "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.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          string.gsub!(/\\_</,'{\UseTextSymbol{OML}{<}}')          string.gsub!(/\\_>/,'{\UseTextSymbol{OML}{>}}') @@ -1025,7 +1058,8 @@ WOK        string.gsub!(/<:ee>/,'')        string.gsub!(/<!>/,' ')        #proposed change, insert, but may be redundant -      string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/,' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # 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 +      string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/, +        ' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # 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        string.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area        string.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}')        #string.gsub!(/<em>(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') @@ -1049,7 +1083,8 @@ WOK          string.gsub!(/\s+'/,' `')                                # open '          string.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`')  # open '        end -      string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*#{Mx[:gl_bullet]}\s*/,'\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_ +      string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*#{Mx[:gl_bullet]}\s*/, +        '\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_        string.gsub!(/(<font.*?>|<\/font>)/,'')        string.gsub!(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1')        #string.gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_paragraph]}|\n)\*/,' \\\\ ') @@ -1065,16 +1100,22 @@ WOK        #string.gsub!(/<=lt>/,'\<')        #string.gsub!(/<=gt>/,'\>')        string.gsub!(/<=underscore>/,'\_') -      string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text -      string.gsub!(/<=tilde>/,'{\~~}') +      while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text +        string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') +      end +      string.gsub!(/<=tilde>/,'{$\sim$}')        string.gsub!(/<=pipe>/,'{\textbar}')        string.gsub!(/<=caret>/,'{\^{~}}')        #string.gsub!(/<=caret>/,'\^{}')        string.gsub!(/<=exclaim>/,'\Verbatim{!}') +      string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text        string.gsub!(/<=hash>/,'{\#}')        #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}')        #string.gsub!(/<=slash>/,'{\slash}')        string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 +      while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text +        string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') +      end        string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005        #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}')        string.gsub!(/<=slash>/,'{/}') @@ -1084,12 +1125,13 @@ WOK        #string.gsub!(/<=asterisk>/,'{\ast}')        #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic        #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' -      string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic +      string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/, +        '^\copyright \textnormal{\1} \2') # watch likely to be problematic        string      end      def xetex_special_characters_1(string)             # ~ ^ $ & % _ { }  #LaTeX special characters - KEEP list        #p @@utf_8.list -      #string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) +      #string=Iconv.conv('ISO-8859-1', 'UTF-8', @txt)        word=string.scan(/\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/        para_array=[]        string=if word @@ -1119,7 +1161,7 @@ WOK        string.gsub!(/#{Mx[:br_endnotes]}/,'')        #string.gsub!(/<ENDNOTES?>/,'')        #problem sequence -> -      string.gsub!(/&(?:nbsp);/,'<=hardspace>')                                 # < SiSU special character also LaTeX +      string.gsub!(/&(?:nbsp);|#{Mx[:nbsp]}/,'<=hardspace>')                                 # < SiSU special character also LaTeX        string.gsub!(/&(?:lt|#060);/,'<=lt>')                                     # < SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'<=gt>')                                     # > SiSU special character also LaTeX        #string.gsub!(/#{Mx[:gl_o]}(&#(?:[a-z]+|[0-9]+);)#{Mx[:gl_c]}/,'\1') @@ -1132,7 +1174,7 @@ WOK        string.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-')                                                # - SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+')                                                # + SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',')                                                # + SiSU special character also LaTeX -      string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @string=~/<:code>/                   # / SiSU special character also LaTeX +      string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/                   # / SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>')                                         # / SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>')                                     # \ SiSU special character also LaTeX        string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>')                                    # _ SiSU special character also LaTeX @@ -1153,12 +1195,12 @@ WOK        string.gsub!(/\#/,'\#')        string.gsub!(/\%/,'\%')        string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes -      if string !~/^\s*<:image|\}:image\s/ +      if string !~/^\s*#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\s/          string.gsub!(/_/,'\_')        end        string.gsub!(/\{/,'\{')        string.gsub!(/\}/,'\}') -      string.gsub!(/ /,'~') # ~ character for hardspace +      string.gsub!(/ |#{Mx[:nbsp]}/,'~') # ~ character for hardspace        # sequence important must appear after removal of { and }        string.gsub!(/&\S+?;/,'') #hmmm        # sequence imortant place before removal of & @@ -1166,18 +1208,23 @@ WOK        elsif string=~/#{Mx[:gr_o]}code-end#{Mx[:gr_c]}/; @@flag_code=false        end        if @@flag_code; string.gsub!(/&/,'{\\\&}') -      else string.gsub!(/(\s+&\s+)/,' and ') +      else string.gsub!(/&/,'<=amp>') +      #else string.gsub!(/(\s+&\s+)/,' and ')        end        string.gsub!(/§/u,'\S') #latex: space between next character not preserved? #string.gsub!(/§ /,'\S ')        string.gsub!(/£/u,'\pounds')        string.gsub!(/&\S+?;/,' ')        string.gsub!(/<a href=".+?">/,' ')        string.gsub!(/<\/a>/,' ') -      string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case -      string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url -      string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration +      string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, +        '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url +      string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, +        ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case +      string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, +        '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration        unless @@flag_code -        string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start +        string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, +          "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.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          string.gsub!(/\\_</,'{\UseTextSymbol{OML}{<}}')          string.gsub!(/\\_>/,'{\UseTextSymbol{OML}{>}}') @@ -1185,7 +1232,8 @@ WOK        string.gsub!(/<:ee>/,'')        string.gsub!(/<!>/,' ')        #proposed change, insert, but may be redundant -      string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/,' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # 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 +      string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/, +        ' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # 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        string.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area        string.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}')        #string.gsub!(/<em>(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') @@ -1230,16 +1278,22 @@ WOK        #string.gsub!(/<=lt>/,'\<')        #string.gsub!(/<=gt>/,'\>')        string.gsub!(/<=underscore>/,'\_') -      string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text -      string.gsub!(/<=tilde>/,'{\~~}') +      while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text +        string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2') +      end +      string.gsub!(/<=tilde>/,'{$\sim$}')        string.gsub!(/<=pipe>/,'{\textbar}')        string.gsub!(/<=caret>/,'{\^{~}}')        #string.gsub!(/<=caret>/,'\^{}')        string.gsub!(/<=exclaim>/,'\Verbatim{!}') +      string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text        string.gsub!(/<=hash>/,'{\#}')        #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}')        #string.gsub!(/<=slash>/,'{\slash}')        string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 +      while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text +        string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2') +      end        string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005        #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}')        string.gsub!(/<=slash>/,'{/}') @@ -1249,7 +1303,8 @@ WOK        #string.gsub!(/<=asterisk>/,'{\ast}')        #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic        #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' -      string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic +      string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/, +        '^\copyright \textnormal{\1} \2') # watch likely to be problematic        string      end      def special_characters_curly(string) @@ -1263,33 +1318,33 @@ WOK        string      end      def special_characters                                                       #special characters - some substitutions are sequence sensitive, rearrange with care. -      string=@string +      string=@txt        case @tex2pdf        when /pdf/          string=pdftex_special_characters_1(string) unless string.nil? -        string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@string) +        string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@txt)          string=pdftex_special_characters_2(string) unless string.nil?          string=pdftex_special_characters_3(string) unless string.nil?        when /xe/          string=xetex_special_characters_1(string) unless string.nil? -        string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@string) +        string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@txt)          string=xetex_special_characters_2(string) unless string.nil? #issues with xetex          string=xetex_special_characters_3(string) unless string.nil?        end -      @string=string +      @txt=string      end      def special_characters_safe                                                  #special characters - some substitutions are sequence sensitive, rearrange with care. -      string=@string +      string=@txt        case @tex2pdf        when /pdf/ -        string=pdftex_special_characters_1(@string) unless string.nil? -        string=pdftex_special_characters_2(@string) unless string.nil? -        #special_characters_3(@string) +        string=pdftex_special_characters_1(@txt) unless string.nil? +        string=pdftex_special_characters_2(@txt) unless string.nil? +        #special_characters_3(@txt)        when /xe/ -        string=xetex_special_characters_1(@string) unless string.nil? -        string=xetex_special_characters_2(@string) unless string.nil? # remove this to start with, causes issues +        string=xetex_special_characters_1(@txt) unless string.nil? +        string=xetex_special_characters_2(@txt) unless string.nil? # remove this to start with, causes issues        end -      @string=string +      @txt=string      end    end    class Use_TeX  | 
