diff options
Diffstat (limited to 'lib/sisu/v0/texpdf_format.rb')
-rw-r--r-- | lib/sisu/v0/texpdf_format.rb | 86 |
1 files changed, 47 insertions, 39 deletions
diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 4f31311a..7d0f3967 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -31,9 +31,12 @@ If you have Internet connection, the latest version of the GPL should be available at these locations: - <http://www.fsf.org/licenses/gpl.html> + <http://www.fsf.org/licensing/licenses/gpl.html> <http://www.gnu.org/copyleft/gpl.html> - <http://www.jus.uio.no/sisu/gpl.fsf> + + <http://www.jus.uio.no/sisu/gpl.fsf/toc.html> + <http://www.jus.uio.no/sisu/gpl.fsf/doc.html> + <http://www.jus.uio.no/sisu/gpl.fsf/plain.txt> * SiSU uses: * Standard SiSU markup syntax, @@ -800,23 +803,26 @@ WOK # 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=~/\\\{.+?\\\}(?:https?|file|ftp):\S+/ - if word =~/\\\{(.+?)\\\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/ - r=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ - d=/\\\{.+?\\?\}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.to_s + @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 else - r=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+)/ - d='' + regx_url=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+)/ + punctuate='' end - z,url=r.match(word).captures if word =~r + 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+/ image,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') - width=200 - width=z[/(\d+)x\d*/,1] ||='200' #watch + width=if z =~/(\d+)x\d*/ + z[/(\d+)x\d*/,1] + else 200 + end dm=case @md.papersize when /a4/; @tx.a4 when /letter/; @tx.letter @@ -826,58 +832,60 @@ WOK 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 + 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 + width=if width.to_i > dm.landscape.img_px + dm.landscape.img_px + else width end end c=z[/``(.+?)''/m,1] hsp="\n{\\color{mywhite} .}&~\n" # ~ character for hardspace - caption="{\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}" if c + caption=if c + "{\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}" + else '' + end elsif word =~/\{\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 - ins=if image #most images fc etc. #% clean up ! - out=if @md.fns =~/\.(?:ssm\.)?sst$/ \ + 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}") - @center_begin + - "\\\n\\href{#{url}}" + #not satisfactory: \\ added to ^line to mimic reference file output - "{\\includegraphics*[width=#{width}pt]" + - "{#{dir.path.image_source_local_tex}/#{image}}}" + - "#{caption}" + - @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ + word=if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?: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}") - @center_begin + - "\\\n\\href{#{url}}" + #not satisfactory: \\ added to ^line to mimic reference file output - "{\\includegraphics*[width=#{width}pt]" + - "{#{dir.path.image_source_remote_tex}/#{image}}}" + - "#{caption}" + - @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ + word=if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?: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}") - @center_begin + - "\\\n\\href{#{url}}\n" + #not satisfactory: \\ added to ^line to mimic reference file output, mirror above ... not tested - "{\\includegraphics*[width=#{width}pt]" + - "{#{dir.path.image_source_tex}/#{image}}}" + - "#{caption}" + - @center_end if word =~/(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ + word=if word =~/(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?: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/ - '' if word =~ /\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/ + word='' if word =~ /\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/ + word end else link=z.strip #[/(.+?)\\/m,1] - word="\\href{#{url}}{#{link}}#{d}" if word =~/\\\{.+?\\\}(?:https?|file|ftp):\/\/\S+/ + word="\\href{#{url}}{#{link}}#{punctuate}" if word =~/\\\{.+?\\\}(?:https?|file|ftp):\/\/\S+/ + word end else word end end - @words.join + @words=@words.join + @words end def http(orientation) wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) |