diff options
| -rw-r--r-- | lib/sisu/v0/texpdf.rb | 406 | ||||
| -rw-r--r-- | lib/sisu/v0/texpdf_format.rb | 95 | 
2 files changed, 282 insertions, 219 deletions
| diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index b22b462b..ead5752b 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -125,8 +125,8 @@ module SiSU_TeX                                                                               #% needed needs to be reprogrammed !!!          SiSU_Env::Info_skin.new(@md).select          dal_array=SiSU_DAL::Source.new(@opt).get             # dal file drawn here -        SiSU_TeX::Source::LaTeX_create.new(dal_array,@md,'landscape').songsheet -        SiSU_TeX::Source::LaTeX_create.new(dal_array,@md,'portrait').songsheet +        SiSU_TeX::Source::LaTeX_create.new(dal_array,@md).songsheet +        #SiSU_TeX::Source::LaTeX_create.new(dal_array,@md,'portrait').songsheet          dal_array=''          pwd=Dir.pwd          SiSU_TeX::Source::LaTeX_to_pdf.new(@md).latexrun_selective @@ -234,14 +234,14 @@ module SiSU_TeX        include SiSU_Param        @@tex_backslash ||="\\\\"        @@tilde='\\\\\\~' #?? debug crazy -      @@tex_head_portrait,@@tex_head_landscape=nil,nil +      @@tex_head={ :p => nil, :l => nil }        @@flag_alt,@@flag_group,@@flag_code=false,false,false        @@dp,@@prefix_b=nil,nil -      def initialize(data,md,orientation) -        @data,@md,@orientation=data,md,orientation +      def initialize(data,md) +        @data,@md=data,md          @env=SiSU_Env::Info_env.new(@md.fns)          @st={ :tex=>{} } -        @tex=SiSU_TeX_Pdf::Use_TeX.new(@md,@orientation) +        @tex=SiSU_TeX_Pdf::Use_TeX.new(@md)          @vz=SiSU_Env::Get_init.instance.skin          @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern          vz=SiSU_Env::Get_init.instance.skin @@ -256,7 +256,7 @@ module SiSU_TeX            data=@data            @@tex_footnote_array=[]            @@rights=nil -          tell=SiSU_Screen::Ansi.new(@md.cmd,"pdfTex #@orientation") +          tell=SiSU_Screen::Ansi.new(@md.cmd,"pdfTex portrait & landscape")            tell.txt_grey unless @md.cmd =~/q/            if @md.dc_rights              use=@md.dc_rights.dup #dup is necessary, else contents of :rights changed @@ -286,7 +286,6 @@ module SiSU_TeX             end            data=number_paras(data,ocn)            data=markup(data) -          #data=markup(data).flatten #watch            output(data)          rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error          ensure @@ -331,19 +330,25 @@ module SiSU_TeX          end          @tex_file        end +      def tables_hash(md,para) +        para_p=para.dup #visit +        do_mono_l=SiSU_TeX_Pdf::Format_text_object.new(md,para) +        do_mono_p=SiSU_TeX_Pdf::Format_text_object.new(md,para_p) +        block={ +          :l => do_mono_l.longtable_landscape, +          :p => do_mono_p.longtable_portrait +        } +      end        def tables(data) +        @@tableheader={ :p => 0, :l => 0 }          @tex_file=[] -        @@tableheader=0          data.each do |para| -          if para =~/¡|<!T/ -            do_mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) -            case @orientation                                                   # using longtable latex package -            when /landscape/; para=do_mono.longtable_landscape -            when /portrait/; para=do_mono.longtable_portrait -            end +          @tex_file << if para =~/¡|<!T/ +            tables_hash(@md,para) #Hash result +          else para            end -          @tex_file << para          end +        @tex_file        end        def enclose(para,type='')          para.strip! @@ -353,6 +358,98 @@ module SiSU_TeX          else para          end        end +      def markup_common(para) +        tex_f=nil +        mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) +        if para =~/<:(?:code|alt|verse|group)>/ \ +        or @@flag_alt +          if para =~/<:(?:code|alt|verse|group)>/ +            @lineone=case para +            when /<:(?:alt|verse|group)>/; para +            when /<:code>/; "#{@tex.paraskip_small} \\begin{scriptsize} " + para +            else 'error' #should never occur +            end +          end +          if para =~/<=curly/ #takes care of escaped curly braces, expand +            do_mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) +            para=do_mono.special_characters_curly(para) +          end +          regx=/<:((?:code|alt|verse|group)(?:-end)?)>/m +          x=regx.match(para)[1] if para =~regx +          x=$1 +          para.gsub!(/\n<:(?:code|alt|verse|group)>\n/m,'') +          para=enclose(para,'code') unless para =~/^$/ +          if x =~/(?:alt|verse|group)/; @@flag_alt=true +            if x =~/group/; @@flag_group=true +            end +          elsif x =~/code/; @@flag_alt,@@flag_code=true,true +          elsif @@flag_alt; +            if para =~ /\}(?:https?|file|ftp)/m +              para=mono.http #(@orientation) +            end +            @group_collect << para #<< "\n\n" +          end +          if x =~/(?:code|alt|verse|group)-end/m +            regx=/(\\+marginpar\{\\+begin\{tiny\}\d+\\+end\{tiny\}\})/ +            y=if para =~regx +              regx.match(para)[1] +            else '' +            end +            para.gsub!(regx,'') +            #@group_collect.each{ |x| x.gsub!(/(<:\S+>|<!.*?!>|<!>)/,' ') } +            group_collect=[] +            group_collect << '\begin{footnotesize} ' unless @@flag_code +            @group_collect.each do |x| +              x.gsub!(/(<:\S+>|<!.*?!>|<!>)/,' ') +              x=x.split(/ \\\\ /) +              group_collect << x +            end +            group_collect << ' \end{footnotesize} ' unless @@flag_code +            @group_collect=group_collect.flatten +            @lineone.gsub!(/(<:\S+>|<!.*?!>|<!>)/,' ') +            #@group_collect.each{ |x| x.gsub!(/(.#{@@tilde}\S*\s*|<:\S+>|<!.*?!>|<!>)/,' ') } +            #@lineone.gsub!(/(.#{@@tilde}\S*\s*|<:\S+>|<!.*?!>|<!>)/,' ') +            insert=[] +            if para =~/<:code-end>/m +              insert << y + @lineone << @group_collect << ' \end{scriptsize}' << " #{@tex.paraskip_normal}" +            else insert << y + @lineone << @group_collect +            end +            @@flag_alt,@@flag_group,@@flag_code=false,false,false +            @group_collect=[] +            para.gsub!(/(<:\S+>|<!.*?!>|<!>)/,' ') +            #para.gsub!(/(.#{@@tilde}\S*\s*|<:\S+>|<!.*?!>|<!>)/,' ') +            #@tex_file << insert.flatten +            tex_f = insert.flatten +          end +        else +          if para =~ /\}(?:https?|file|ftp)/ +            para=mono.http #(@orientation) +          end +          case para +          when /^1#{@@tilde}/;       mono.level1 +          when /^2#{@@tilde}/;       mono.level2 +          when /^3#{@@tilde}/;       mono.level3 +          when /^4#{@@tilde}/;       mono.level4 +          when /^5#{@@tilde}/;       mono.level5 +          when /^6#{@@tilde}/;       mono.level6 +          when /^<:i([1-9])>/;       mono.indent($1) +          when /<:=/;                mono.symbol_graphic #watch +          when /^\s*<:image\s+/;     mono.image +          when /\}image/;            mono.png +          else +            para.strip! +            para=enclose(para) unless para =~/^$/ +          end +          para.gsub!(/(\.#{@@tilde}\S*\s*|<:\S+>|<!.*?!>|<!>)/,' ')   #% tread with care +          #para.gsub!(/(.#{@@tilde}(?:\\~\S+)?\s*|<:\S+>|<!.*?!>|<!>)/,' ')  #KEEP reference, problem escaping open curly braces \{ +          if para =~/<=curly/ #takes care of escaped curly braces, expand +            do_mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) +            para=do_mono.special_characters_curly(para) +          end +          tex_f = para +        end +        tex_f +      end        def markup(data)          @tex_file=[]          md={} @@ -360,12 +457,10 @@ module SiSU_TeX          home=@vz.txt_home.gsub(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>|\\\\/,' - ') #no line splitting in heading neither html nor latex          title=@md.title.gsub(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>|\\\\/,' - ') #no line splitting in heading neither html nor latex          subtitle=@md.subtitle.gsub(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>|\\\\/,' - ') if @md.subtitle #no line splitting in heading neither html nor latex -        orient=SiSU_TeX_Pdf::Format_text_object.new(@md,@orientation,"#{home}: - #{title} #{subtitle}") #.new -        if @orientation =~/portrait/ -          @@tex_head_portrait=orient.document_head_with_orientation -        elsif @orientation =~/landscape/ -          @@tex_head_landscape=orient.document_head_with_orientation -        end +        orient_portrait=SiSU_TeX_Pdf::Format_text_object.new(@md,'portrait',"#{home}: - #{title} #{subtitle}") +        orient_landscape=SiSU_TeX_Pdf::Format_text_object.new(@md,'landscape',"#{home}: - #{title} #{subtitle}") +        @@tex_head[:p]=orient_portrait.document_head_with_orientation +        @@tex_head[:l]=orient_landscape.document_head_with_orientation          @tex_file <<<<WOK  #{@tex.header}#{@tex.footer}  \\tolerance=500 @@ -380,39 +475,25 @@ WOK          #else                               ''          #end          @copymark='' #check and remove as now is superflous -        if @orientation =~/landscape/ # using longtable latex package -          @tex_file << SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_landscape -          if @md.dc_creator -            do_mono=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.dc_creator) -            creator=do_mono.special_characters -            @tex_file << if @md.creator_home -              <<WOK +        x={} +        x[:l]=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_landscape +        x[:p]=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_portrait +        @tex_file << x +        x=nil +        if @md.dc_creator +          do_mono=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.dc_creator) +          creator=do_mono.special_characters +          @tex_file << if @md.creator_home +            <<WOK  \\author{\\href{#{@md.creator_home}}{#@copymark \\textnormal{#{creator}}}}  WOK -            else "\n\\author{#@copymark \\textnormal{#{creator}}}" -            end -          end -          @tex_file << unless @md.fnb =~/^mail\s*$/ -            "\n\\date{\\begin{footnotesize} copy @ #{@tex.site} \\end{footnotesize} #{sisu_rc_footnote}}" -          else "\\date" -          end -        else #portrait -          @tex_file << SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_portrait -          if @md.dc_creator -            creator=@md.dc_creator -            @tex_file << if @md.creator_home -              <<WOK - -\\author{\\href{#{@md.creator_home}}{#@copymark \\textnormal{#{creator}}}} -WOK -            else "\n\\author{#@copymark \\textnormal{#{creator}}}" -            end -           end -          @tex_file << unless @md.fnb =~/^mail\s*$/; "\n\\date{\\begin{footnotesize} copy @ #{@tex.site} \\end{footnotesize} #{sisu_rc_footnote}}" -          else                                       "\\date" +          else "\n\\author{#@copymark \\textnormal{#{creator}}}"            end          end +        @tex_file << unless @md.fnb =~/^mail\s*$/; "\n\\date{\\begin{footnotesize} copy @ #{@tex.site} \\end{footnotesize} #{sisu_rc_footnote}}" +        else                                       "\\date" +        end          @tex_file <<<<WOK  \\pagenumbering{roman}\\maketitle  \\pagestyle{fancy} @@ -426,104 +507,38 @@ WOK          else                         @tex.doc_no_sc_info          end          @tex_file << @tex.manifest_info -        @tex_file << @tex.newpage -        @tex_file <<<<WOK +        x={} +        x[:l] =<<WOK +#{@tex.newpage('landscape')}  \\pagestyle{fancy}  \\tableofcontents -#{@tex.newpage} +#{@tex.newpage('landscape')}  \\pagenumbering{arabic}  #{@tex.paraskip_normal} +#{@tex.newpage('landscape')}  WOK -        @tex_file << @tex.newpage +        x[:p] =<<WOK +#{@tex.newpage('portrait')} +\\pagestyle{fancy} +\\tableofcontents +#{@tex.newpage('portrait')} +\\pagenumbering{arabic} +#{@tex.paraskip_normal} +#{@tex.newpage('portrait')} +WOK +        @tex_file << x +        x=nil          @group_collect=[]          data.each do |para|                                                      #% case follows with levels 1-6 indents & graphics -          mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) -          if para =~/<:(?:code|alt|verse|group)>/ \ -          or @@flag_alt -            if para =~/<:(?:code|alt|verse|group)>/ -              @lineone=case para -              when /<:(?:alt|verse|group)>/; para -              when /<:code>/; "#{@tex.paraskip_small} \\begin{scriptsize} " + para -              else 'error' #should never occur -              end -            end -            if para =~/<=curly/ #takes care of escaped curly braces, expand -              do_mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) -              para=do_mono.special_characters_curly(para) -            end -            regx=/<:((?:code|alt|verse|group)(?:-end)?)>/m -            x=regx.match(para)[1] if para =~regx -            x=$1 -            para.gsub!(/\n<:(?:code|alt|verse|group)>\n/m,'') -            para=enclose(para,'code') unless para =~/^$/ -            if x =~/(?:alt|verse|group)/; @@flag_alt=true -              if x =~/group/; @@flag_group=true -              end -            elsif x =~/code/; @@flag_alt,@@flag_code=true,true -            elsif @@flag_alt; -              if para =~ /\}(?:https?|file|ftp)/m -                para=mono.http(@orientation) -              end -              @group_collect << para #<< "\n\n" -            end -            if x =~/(?:code|alt|verse|group)-end/m -              regx=/(\\+marginpar\{\\+begin\{tiny\}\d+\\+end\{tiny\}\})/ -              y=if para =~regx -                regx.match(para)[1] -              else '' -              end -              para.gsub!(regx,'') -              #@group_collect.each{ |x| x.gsub!(/(<:\S+>|<!.*?!>|<!>)/,' ') } -              group_collect=[] -              group_collect << '\begin{footnotesize} ' unless @@flag_code -              @group_collect.each do |x| -                x.gsub!(/(<:\S+>|<!.*?!>|<!>)/,' ') -                x=x.split(/ \\\\ /) -                group_collect << x -              end -              group_collect << ' \end{footnotesize} ' unless @@flag_code -              @group_collect=group_collect.flatten -              @lineone.gsub!(/(<:\S+>|<!.*?!>|<!>)/,' ') -              #@group_collect.each{ |x| x.gsub!(/(.#{@@tilde}\S*\s*|<:\S+>|<!.*?!>|<!>)/,' ') } -              #@lineone.gsub!(/(.#{@@tilde}\S*\s*|<:\S+>|<!.*?!>|<!>)/,' ') -              insert=[] -              if para =~/<:code-end>/m -                insert << y + @lineone << @group_collect << ' \end{scriptsize}' << " #{@tex.paraskip_normal}" -              else insert << y + @lineone << @group_collect -              end -              @@flag_alt,@@flag_group,@@flag_code=false,false,false -              @group_collect=[] -              para.gsub!(/(<:\S+>|<!.*?!>|<!>)/,' ') -              #para.gsub!(/(.#{@@tilde}\S*\s*|<:\S+>|<!.*?!>|<!>)/,' ') -              @tex_file << insert.flatten -            end -          else -            if para =~ /\}(?:https?|file|ftp)/ -              para=mono.http(@orientation) -            end -            case para -            when /^1#{@@tilde}/;       mono.level1 -            when /^2#{@@tilde}/;       mono.level2 -            when /^3#{@@tilde}/;       mono.level3 -            when /^4#{@@tilde}/;       mono.level4 -            when /^5#{@@tilde}/;       mono.level5 -            when /^6#{@@tilde}/;       mono.level6 -            when /^<:i([1-9])>/;       mono.indent($1) -            when /<:=/;                mono.symbol_graphic #watch -            when /^\s*<:image\s+/;     mono.image -            when /\}image/;            mono.png -            else -              para.strip! -              para=enclose(para) unless para =~/^$/ -            end -            para.gsub!(/(\.#{@@tilde}\S*\s*|<:\S+>|<!.*?!>|<!>)/,' ')   #% tread with care -            #para.gsub!(/(.#{@@tilde}(?:\\~\S+)?\s*|<:\S+>|<!.*?!>|<!>)/,' ')  #KEEP reference, problem escaping open curly braces \{ -            if para =~/<=curly/ #takes care of escaped curly braces, expand -              do_mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) -              para=do_mono.special_characters_curly(para) -            end -            @tex_file << para +          if para.class == String +            para=markup_common(para) +          elsif para.class == Hash +            para={  +              :p => markup_common(para[:p]), +              :l => markup_common(para[:l]) +            }            end +          @tex_file << para          end          @tex_file << "\n\\newpage\n" # was \\pagebreak\n          @md.subtitle_tex=@md.subtitle.dup if @md.subtitle @@ -573,62 +588,79 @@ WOK          end          @tex_file << "\n\\end{document}"        end +      def number_paras_numbering(para,ocn) +        if para =~/<\\~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ \ +        and para !~/\\end\{longtable\}|<EOF>/ #catch <!TZ!> +          m=/(.+?)<\\~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m +          parablock=para[m,1] +          paranum=if ocn; para[m,2] +          else '' +          end +          do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,parablock,paranum) +          para=do_duo.para_num if parablock +        elsif para =~/^<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #2005 this is added for tables, rationalise +          m=/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m +          paranum=para[m,1] +          para.gsub!(/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>/,'') +          para="\\marginpar{\\begin{tiny}#{paranum}\\end{tiny}}" + para +        elsif para =~/^<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+>/ #extra 2005 this is added for tables, rationalise +          m=/<~(\d+);[oh]\d+;\w\d+>/m +          paranum=para[m,1] +          para.gsub!(/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+>/,'') +          para="\\marginpar{\\begin{tiny}#{paranum}\\end{tiny}}" + para +        elsif para =~/\\end\{longtable\}/ #catch <!TZ!> +          para.gsub!(/<\\~\d+>|<\\~(\d+);(?:[ohm]|[0-6]:)\d+;\w\d+><#@dp:#@dp>/,'') +          para.gsub!(/<\\~\d+>|<\\~(\d+);(?:[ohm]|[0-6]:)\d+;\w\d+>/,'') #extra +        end +        para +      end        def number_paras(data,ocn) -        @tex_file=[] +        tex_file=[]          data.each do |para| -          if para =~/<\\~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ \ -          and para !~/\\end\{longtable\}|<EOF>/ #catch <!TZ!> -            m=/(.+?)<\\~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m -            parablock=para[m,1] -            paranum=if ocn; para[m,2] -            else '' -            end -            do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,parablock,paranum) -            para=do_duo.para_num if parablock -          elsif para =~/^<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #2005 this is added for tables, rationalise -            m=/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m -            paranum=para[m,1] -            para.gsub!(/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>/,'') -            para="\\marginpar{\\begin{tiny}#{paranum}\\end{tiny}}" + para -            #para="\\marginpar{\\begin{tiny}#{paranum}\\end{tiny}}" -          #elsif para =~/<!T.+?!~\d+?>/ -          elsif para =~/^<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+>/ #extra 2005 this is added for tables, rationalise -            m=/<~(\d+);[oh]\d+;\w\d+>/m -            paranum=para[m,1] -            para.gsub!(/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+>/,'') -            para="\\marginpar{\\begin{tiny}#{paranum}\\end{tiny}}" + para -          elsif para =~/\\end\{longtable\}/ #catch <!TZ!> -            para.gsub!(/<\\~\d+>|<\\~(\d+);(?:[ohm]|[0-6]:)\d+;\w\d+><#@dp:#@dp>/,'') -            para.gsub!(/<\\~\d+>|<\\~(\d+);(?:[ohm]|[0-6]:)\d+;\w\d+>/,'') #extra +          para=if para.class == Hash \ +          and (para[:p] and para[:l]) +            para = { +              :p => number_paras_numbering(para[:p],ocn), +              :l => number_paras_numbering(para[:l],ocn) +            } +          else #elsif para.class == String +            number_paras_numbering(para,ocn)            end -          @tex_file << para +          tex_file << para          end -        @tex_file +        tex_file        end -      def output(data) -        data.flatten! -        data.compact! +      def output(array) +        array.flatten! +        array.compact!          fns_l=@md.fns.gsub(/~/,'-') #this is a sorry fix, but necessary as it appears latex programs like not ~ -        if @orientation =~/landscape/ -          filename_tex_landscape=File.new("#{@env.path.tex}/#{fns_l}.landscape.tex",'w+') -          filename_tex_landscape << @@tex_head_landscape -          data.each do |para| -            para.gsub!(/^\s+/,'') -            filename_tex_landscape.puts para,"\n" if para !~/\A\s*\Z/ -          end -          filename_tex_landscape.close -          @@tex_head_landscape=[] -        elsif @orientation =~/portrait/ -          filename_tex_portrait=File.new("#{@env.path.tex}/#{fns_l}.tex",'w+') -          filename_tex_portrait << @@tex_head_portrait -          data.each do |para| +        filename_tex_landscape=File.new("#{@env.path.tex}/#{fns_l}.landscape.tex",'w+') +        filename_tex_portrait=File.new("#{@env.path.tex}/#{fns_l}.tex",'w+') +        filename_tex_portrait << @@tex_head[:p] +        filename_tex_landscape << @@tex_head[:l] +        array.each do |para| +          case para +          when String              para.gsub!(/^\s+/,'') -            filename_tex_portrait.puts para,"\n" if para !~/\A\s*\Z/ +            if para !~/\A\s*\Z/ +              filename_tex_portrait.puts para,"\n" +              filename_tex_landscape.puts para,"\n" +            end +          when Hash +            para[:p].gsub!(/^\s+/,'') +            para[:l].gsub!(/^\s+/,'') +            if para[:p] !~/\A\s*\Z/ +              filename_tex_portrait.puts para[:p],"\n" +            end +            if para[:l] !~/\A\s*\Z/ +              filename_tex_landscape.puts para[:l],"\n" +            end            end -          filename_tex_portrait.close -          @@tex_head_portrait=[]          end -        data=[] +        filename_tex_portrait.close +        filename_tex_landscape.close +        @@tex_head={} #@@tex_head={ :p => nil, :l => nil } +        array=[]        end      end    end diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index f7d2177a..9506e17b 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -64,8 +64,8 @@ module SiSU_TeX_Pdf    include SiSU_Viz    class Use_TeX      attr_accessor :url,:txt,:date -    def initialize(md,orientation='') -      @md,@orientation=md,orientation +    def initialize(md) +      @md=md        @vz=SiSU_Env::Get_init.instance.skin        @date=SiSU_Env::Info_date.new # #{@date.year}        @copymark='{\\begin{footnotesize}\\raisebox{1ex}{\\copyright}\\end{footnotesize}}' @@ -122,8 +122,8 @@ module SiSU_TeX_Pdf        "Contact Details for Original Promulgating Authority"      end      #BOOK standard dimensions - 229x156 -    def newpage -      case @orientation +    def newpage(orientation) +      case orientation        when /landscape/ # using longtable latex package  <<WOK  \\clearpage @@ -268,7 +268,7 @@ WOK      @@tex_backslash="\\\\"      @@tilde='\\\\\\~' #?? debug crazy      @@tex_pattern_margin_number="\\\\begin\\\{tiny\\\}~\\\\end\\\{tiny\\\}\\\{\\\\marginpar.+?\s+" -    @@tableheader=0 +    @@tableheader={ :p => 0, :l => 0 }      @@sys=SiSU_Env::System_call.new      @@flag_code=false      @@dp=nil @@ -298,12 +298,12 @@ WOK          else             @tx.a4.landscape.w     #default currently A4          end          textwidth=(tw.to_i/2) - 24 -        @@tableheader=1 if @string =~/<!Th/ -        @w=cols_width.split(/;\s*/) +        @@tableheader[:l]=1 if @string =~/<!Th/ +        w=cols_width.split(/;\s*/)          @@number_of_cols=no_of_cols          @colW=[]          @colW << '{' -        @w.each  do |x| +        w.each  do |x|            x.strip!            x=(x.to_i * textwidth)/100            col_w=x.to_s # x.gsub(/.+/,'l\|') #unless x.nil? @@ -319,14 +319,14 @@ WOK          @string.gsub!(/<!TZ!>/," #@end_table\n\\end{tiny}")        end        @string.gsub!(/<!¡/,'') -      if @@tableheader == 1 +      if @@tableheader[:l] == 1          if @string =~/¡\d+?¡(.+?)(?:¡|!)/            tablefoot=@string[/\<!f(.+?)!\>/,1]            @string.gsub!(/\<!f(.+?)!\>/,'')            @string.gsub!(/¡\d+?¡(.+?)(?:¡|!)/,'\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 -          @@tableheader,@@number_of_cols=0,0 +          @@tableheader[:l],@@number_of_cols=0,0          end        else          if @string =~/¡\d+?¡(.+?)(?:¡|!)/ @@ -334,7 +334,9 @@ WOK            @string.gsub!(/&>\s*$/," #@row_break")          end        end -      @string="<~#{ocn}>" + @string +      @string=if ocn; "<~#{ocn}>" + @string +      else @string +      end      end      def longtable_portrait        @end_table='\end{longtable}' @@ -350,12 +352,12 @@ WOK          else             @tx.a4.portrait.w     #default currently A4          end          textwidth=tw.to_i - 20 -        @@tableheader=1 if @string =~/<!Th/ -        @w=cols_width.split(/;\s*/) +        @@tableheader[:p]=1 if @string =~/<!Th/ +        w=cols_width.split(/;\s*/)          @@number_of_cols=no_of_cols          @colW=[]          @colW << '{' -        @w.each  do |x| +        w.each  do |x|            x.strip!            x=(x.to_i * textwidth)/100            #x=(x.to_i/100.0 * 160) @@ -372,14 +374,14 @@ WOK          @string.gsub!(/<!TZ!>/," #@end_table\n\\end{tiny}")        end        @string.gsub!(/<!¡/,'') -      if @@tableheader == 1 +      if @@tableheader[:p] == 1          if @string =~/¡\d+?¡(.+?)(?:¡|!)/            tablefoot=@string[/\<!f(.+?)!\>/,1]            @string.gsub!(/\<!f(.+?)!\>/,'')            @string.gsub!(/¡\d+?¡(.+?)(?:¡|!)/,'\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 -          @@tableheader,@@number_of_cols=0,0 +          @@tableheader[:p],@@number_of_cols=0,0          end        else          if @string =~/¡\d+?¡(.+?)(?:¡|!)/ @@ -387,7 +389,9 @@ WOK            @string.gsub!(/&>\s*$/," #@row_break")          end        end -      @string="<~#{ocn}>" + @string +      @string=if ocn; "<~#{ocn}>" + @string +      else @string +      end      end      def scopedtable        # some features related to headers have been incorporated in longtable that are not included yet here, @@ -799,7 +803,7 @@ WOK          @string.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,'') # fragile match operator\\ fragile !        end      end -    def http_word_mode(orientation='') +    def http_word_mode #(orientation='')        # clean up ! - work area, testing        dir=SiSU_Env::Info_env.new(@md.fns)        @words=[] @@ -831,16 +835,9 @@ WOK              when /a5/;     @tx.a5              else           @tx.a4              end -            width=if orientation =~/portrait/ #value is not currently passed -              width=if width.to_i > dm.portrait.img_px -                dm.portrait.img_px -              else width -              end -            else -              width=if width.to_i > dm.landscape.img_px -                dm.landscape.img_px -              else width -              end +            width=if width.to_i > dm.landscape.img_px +              dm.landscape.img_px +            else width              end              c=z[/``(.+?)''/m,1]              hsp="\n{\\color{mywhite} .}&~\n" # ~ character for hardspace @@ -887,9 +884,9 @@ WOK        @words=@words.join        @words      end -    def http(orientation) +    def http        wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) -      @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm).http_word_mode(orientation) +      @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm).http_word_mode #(orientation)      end      def language        @lang=if @md.dc_language[:code] @@ -1000,6 +997,18 @@ WOK  \\setlength{\\marginparwidth}{#{d[:marginparwidth]}}  WOK      end +    def tex_head_paper_portrait_dvi(d) +      <<WOK +#{tex_head_info} +\\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]}} +\\setlength{\\headsep}{#{d[:headsep]}} +\\setlength{\\marginparsep}{#{d[:marginparsep]}} +\\setlength{\\marginparwidth}{#{d[:marginparwidth]}} +WOK +    end      def tex_head_paper_dimensions        d={}        case @string @@ -1067,7 +1076,7 @@ WOK          tex_head_paper_landscape(tex_head_paper_dimensions)        end      end -    def tex_head_pdftex +    def tex_head_pdftex_dvi        color=case @string        when /portrait/        <<WOK @@ -1084,6 +1093,7 @@ WOK    linkcolor=myred,    % \\href{...} and \\pageref{...}  WOK        end +      if @string =~/portrait|landscape/        <<WOK  \\usepackage{url}  \\usepackage{alltt} @@ -1121,6 +1131,27 @@ WOK  \\definecolor{myblue}{rgb}{0,0,0.5}  \\definecolor{mywhite}{rgb}{1,1,1}  WOK +      elsif @string =~/dvi/ +      <<WOK +\\usepackage{url} +\\usepackage{alltt} +  #{color.strip} +  pageanchor=true, +  plainpages=true, +  pagebackref, +  bookmarks=true, +  bookmarksopen=true, +  plainpages=false, +] +{hyperref} +\\usepackage[usenames]{color} +\\definecolor{myblack}{rgb}{0,0,0} +\\definecolor{myred}{rgb}{0.75,0,0} +\\definecolor{mygreen}{rgb}{0,0.5,0} +\\definecolor{myblue}{rgb}{0,0,0.5} +\\definecolor{mywhite}{rgb}{1,1,1} +WOK +      end      end      def tex_head_misc        <<WOK @@ -1143,7 +1174,7 @@ WOK        <<WOK  #{tex_head_paper}  #{tex_head_encode} -#{tex_head_pdftex} +#{tex_head_pdftex_dvi}  #{tex_head_misc}  \\setcounter{secnumdepth}{2}  \\setcounter{tocdepth}{4} | 
