From 26e5e47cb281d7ee98abcc619332b87b321aaed0 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 3 Jun 2012 14:39:42 -0400 Subject: v3: images, regular & sisupod --- lib/sisu/v3/texpdf_format.rb | 100 ++++++++++++------------------------------- 1 file changed, 28 insertions(+), 72 deletions(-) (limited to 'lib/sisu/v3/texpdf_format.rb') diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index 626020c3..75eadedc 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -478,67 +478,6 @@ module SiSU_TeX_Pdf @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'') # fragile match operator\\ fragile ! end end - def image - dir=SiSU_Env::InfoEnv.new(@md.fns) - 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$/ \ - and FileTest.file?("#{dir.path.image_source_include_local}/#{image}") - dir.path.image_source_include_local - elsif @md.fns =~/\.-ss[tm]$/ \ - and FileTest.file?("#{dir.path.image_source_include_remote}/#{image}") - dir.path.image_source_include_remote - elsif FileTest.file?("#{dir.path.image_source_include}/#{image}") - dir.path.image_source_include - else - SiSU_Screen::Ansi.new(@md.opt.cmd,"ERROR - image:",%{"#{image}" missing},"search locations: #{dir.path.image_source_include_local},#{dir.path.image_source_include_remote} and #{dir.path.image_source_include}").error2 unless @md.opt.cmd =~/q/ - nil - end - if image_source #CHECK - @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/, - @center_begin + "\\includegraphics*[width=#{width}pt]{#{image_source}/\\1}" + @center_end ) - else @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,'\1}') - end - end - def png(ps='') #fc missing image check - dir=SiSU_Env::InfoEnv.new(@md.fns) - # messy clean up - 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!(/\\/,'') - width=if z =~ /\d+x\d*/ - w=(z[/\s(\d+)x\d*/,1]).to_i - w*0.8 - else '100' #revisit, is bug for small images/icons - end - width='380' if width.to_i > 380 - c=z[/``(.+?)''/m] - end - hsp="\n{\\color{mywhite} .}&~\n" # ~ character for hardspace - caption="{\\\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}" if c - image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ \ - and FileTest.file?("#{dir.path.image_source_include_local}/#{image}") - dir.path.image_source_include_local - elsif @md.fns =~/\.-ss[tm]$/ \ - and FileTest.file?("#{dir.path.image_source_include_remote}/#{image}") - dir.path.image_source_include_remote - elsif FileTest.file?("#{dir.path.image_source_include}/#{image}") - dir.path.image_source_include - else - unless image.nil? \ - or image.length < 2 - SiSU_Screen::Ansi.new(@md.opt.cmd,"ERROR - image:",%{"#{image}" missing},"search locations: #{dir.path.image_source_include_local},#{dir.path.image_source_include_remote} and #{dir.path.image_source_include}").error2 unless @md.opt.cmd =~/q/ - end - nil - end - if image_source - @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 @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/,'') - end - end def url_str_internal(str,idx=nil) map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/m @@ -684,36 +623,53 @@ module SiSU_TeX_Pdf images_hash[ps].gsub!(/#{Mx[:lnk_o]}\s*(\S+\.?\.(?:png|jpg|gif))/,'[image]') end if image #most images fc etc. #% clean up ! - if @md.fns =~/\.(?:ssm\.)?sst$/ \ - and FileTest.file?("#{dir.path.image_source_include_local}/#{image}") + if FileTest.file?("#{dir.path.image_source_include}/#{image}") case images_hash[ps] when url_image_rgx images_hash[ps].sub!(url_image_rgx, - "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_local}/#{image}}}#{caption} #{@center_end}") + "#{@center_begin}\\\n\\href{#{url}}\n{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include}/#{image}}}#{caption}#{@center_end}") when image_rgx images_hash[ps].sub!(image_rgx, - "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_local}/#{image}}#{caption} #{@center_end}") + "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include}/#{image}}#{caption}#{@center_end}") end images_hash[ps] - elsif @md.fns =~/\.-ss[tm]$/ \ - and FileTest.file?("#{dir.path.image_source_include_remote}/#{image}") + elsif @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/ + pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1] + img_src=pt + '/image' + if FileTest.file?("#{img_src}/#{image}") + img_src + + case images_hash[ps] + when url_image_rgx + images_hash[ps].sub!(url_image_rgx, + "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{img_src}/#{image}}}#{caption} #{@center_end}") + when image_rgx + images_hash[ps].sub!(image_rgx, + "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{img_src}/#{image}}#{caption} #{@center_end}") + end + images_hash[ps] + end + + elsif @md.fns =~/\.(?:ssm\.)?sst$/ \ + and FileTest.file?("#{dir.path.image_source_include_local}/#{image}") case images_hash[ps] when url_image_rgx images_hash[ps].sub!(url_image_rgx, - "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_remote}/#{image}}}#{caption}#{@center_end}") + "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_local}/#{image}}}#{caption} #{@center_end}") when image_rgx images_hash[ps].sub!(image_rgx, - "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_remote}/#{image}}#{caption}#{@center_end}") + "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_local}/#{image}}#{caption} #{@center_end}") end images_hash[ps] - elsif FileTest.file?("#{dir.path.image_source_include}/#{image}") + elsif @md.fns =~/\.-ss[tm]$/ \ + and FileTest.file?("#{dir.path.image_source_include_remote}/#{image}") case images_hash[ps] when url_image_rgx images_hash[ps].sub!(url_image_rgx, - "#{@center_begin}\\\n\\href{#{url}}\n{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include}/#{image}}}#{caption}#{@center_end}") + "#{@center_begin}\\\n\\href{#{url}}{\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_remote}/#{image}}}#{caption}#{@center_end}") when image_rgx images_hash[ps].sub!(image_rgx, - "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include}/#{image}}#{caption}#{@center_end}") + "#{@center_begin}\\\n\\includegraphics*[width=#{width[ps]}pt]{#{dir.path.image_source_include_remote}/#{image}}#{caption}#{@center_end}") end images_hash[ps] else -- cgit v1.2.3