diff options
Diffstat (limited to 'lib/sisu/v4')
-rw-r--r-- | lib/sisu/v4/constants.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v4/html.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v4/hub.rb | 10 | ||||
-rw-r--r-- | lib/sisu/v4/options.rb | 199 | ||||
-rw-r--r-- | lib/sisu/v4/param.rb | 26 | ||||
-rw-r--r-- | lib/sisu/v4/sysenv.rb | 11 | ||||
-rw-r--r-- | lib/sisu/v4/texpdf.rb | 324 | ||||
-rw-r--r-- | lib/sisu/v4/texpdf_format.rb | 94 | ||||
-rw-r--r-- | lib/sisu/v4/urls.rb | 12 | ||||
-rw-r--r-- | lib/sisu/v4/utils.rb (renamed from lib/sisu/v4/debug.rb) | 27 |
10 files changed, 449 insertions, 265 deletions
diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v4/constants.rb index 65b17796..d774be25 100644 --- a/lib/sisu/v4/constants.rb +++ b/lib/sisu/v4/constants.rb @@ -289,8 +289,8 @@ DEVELOPER={ maintenance: :false, } __END__ -puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:red).set -puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:green) +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:red).set +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:green) puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__ puts "#{ANSI_C[:red]} #{__LINE__.to_s} #{ANSI_C[:off]} #{__FILE__}" puts ANSI_C[:fuchsia] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:fuchsia]}\\1#{ANSI_C[:off]}") diff --git a/lib/sisu/v4/html.rb b/lib/sisu/v4/html.rb index 9e6ec0fa..530b5faf 100644 --- a/lib/sisu/v4/html.rb +++ b/lib/sisu/v4/html.rb @@ -89,14 +89,17 @@ module SiSU_HTML @fnb=@md.fnb @env=@particulars.env loc=@env.url.output_tell + primary_output_file=(@opt.act[:html_seg][:set]==:on) \ + ? (@md.file.output_path.html_seg.dir + '/' + @md.file.base_filename.html_segtoc) + : (@md.file.output_path.html_scroll.dir + '/' + @md.file.base_filename.html_scroll) unless @opt.cmd =~/q/ tool=(@opt.cmd =~/[MVvz]/) \ - ? ("#{@env.program.web_browser} file://#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}") + ? ("#{@env.program.web_browser} file://#{primary_output_file}") : ("[#{@opt.f_pth[:lng_is]}] #{@opt.fno}") @opt.cmd=~/[MVvz]/ \ ? SiSU_Screen::Ansi.new(@opt.cmd,'HTML',tool).green_hi_blue : SiSU_Screen::Ansi.new(@opt.cmd,'HTML',tool).green_title_hi - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}").flow if @opt.cmd =~/[MV]/ + SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{primary_output_file}").flow if @opt.cmd =~/[MV]/ end data=nil tuned_file_array=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v4/hub.rb index 2cfcee57..ccae2b9f 100644 --- a/lib/sisu/v4/hub.rb +++ b/lib/sisu/v4/hub.rb @@ -68,7 +68,7 @@ module SiSU include SiSU_Viz require_relative 'help' # help.rb include SiSU_Help - require_relative 'debug' # debug.rb + require_relative 'utils' # utils.rb require 'uri' class HubMaster def initialize(argv) @@ -337,7 +337,11 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on require_relative 'xml_dom' # -X xml_dom.rb SiSU_XML_DOM::Source.new(@opt).read end - if @opt.act[:pdf][:set]==:on #% --pdf, -p latex/ texpdf + if @opt.act[:pdf][:set]==:on \ + or @opt.act[:pdf_p][:set]==:on \ + or @opt.act[:pdf_l][:set]==:on + #% --pdf-l + #% --pdf, -p latex/ texpdf require_relative 'texpdf' # -p texpdf.rb SiSU_TeX::Source.new(@opt).read end @@ -651,6 +655,8 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on or @opt.act[:xml_sax][:set]==:on \ or @opt.act[:xml_dom][:set]==:on \ or @opt.act[:pdf][:set]==:on \ + or @opt.act[:pdf_p][:set]==:on \ + or @opt.act[:pdf_l][:set]==:on \ or @opt.act[:psql][:set]==:on \ or @opt.act[:sqlite][:set]==:on \ or @opt.act[:sqlite_discreet][:set]==:on \ diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb index fbdfc8f3..3dca5253 100644 --- a/lib/sisu/v4/options.rb +++ b/lib/sisu/v4/options.rb @@ -462,50 +462,85 @@ module SiSU_Commandline end def opt_cmd_and_mod_adjust(c,m) cmd,mod,files=@cmd,@mod,@files + if not m.empty? \ + and m.inspect =~/"--pdf-/ + ps,psa='',[] + mod << '--pdf' + m.each do |m| + if m =~ /^--pdf-(?:(?:l|landscape)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:l|landscape))$/ + mod << '--landscape' + end + if m =~ /^--pdf-(?:(?:p|portrait)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:p|portrait))$/ + mod << '--portrait' + end + if m =~ /^--pdf(?:-(?:a4|letter|a5|b5|legal)(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))(?:-(?:a4|letter|a5|b5|legal)))$/ + if m =~ /^--pdf(?:-a4(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a4)$/ + mod << '--papersize-a4' + end + if m =~ /^--pdf(?:-a5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a5)$/ + mod << '--papersize-a5' + end + if m =~ /^--pdf(?:-b5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-b5)$/ + mod << '--papersize-b5' + end + if m =~ /^--pdf(?:-letter(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-letter)$/ + mod << '--papersize-letter' + end + if m =~ /^--pdf(?:-legal(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-legal)$/ + mod << '--papersize-legal' + end + end + end + mod=mod.uniq + end unless m.empty? m.each do |m| case m - when /^--(?:color-toggle)$/; c=c+'c' - when /^--(?:color-off)$/; c=c+'k' - when /^--(?:configure|init-site)$/; c=c+'CC' - when /^--(?:dal?|machine|abstraction|abs)$/; c=c+'m' - when /^--(?:txt|text|plaintext)$/; c=c+'t' - when /^--(?:html)$/; c=c+'h' - when /^--(?:html-scroll|html-seg)$/; c=c+'H' + when /^--(?:color-toggle)$/; c=c+'c' + when /^--(?:color-off)$/; c=c+'k' + when /^--(?:configure|init-site)$/; c=c+'CC' + when /^--(?:dal?|machine|abstraction|abs)$/; c=c+'m' + when /^--(?:txt|text|plaintext)$/; c=c+'t' + when /^--(?:html)$/; c=c+'h' + when /^--(?:html-scroll|html-seg)$/; c=c+'H' mod << m - when /^--(?:epub)$/; c=c+'e' - when /^--(?:od[ft])$/; c=c+'o' - when /^--(?:pdf)$/; c=c+'p' - when /^--(?:concordance|wordmap)$/; c=c+'w' - when /^--(?:manpage|man)$/; c=c+'i' - when /^--(?:texinfo)$/; c=c+'I' - when /^--(?:xhtml)$/; c=c+'b' - when /^--(?:xml-sax)$/; c=c+'x' - when /^--(?:xml-dom)$/; c=c+'X' - when /^--(?:images)$/; c=c+'j' - when /^--(?:hash-digests)$/; c=c+'N' - when /^--(?:po4a|pot?)$/; c=c+'P' - when /^--(?:termsheet)$/; c=c+'T' - when /^--(?:manifest)$/; c=c+'y' - when /^--(?:qrcode)$/; c=c+'Q' - when /^--(?:sqlite)$/; c=c+'d' - when /^--(?:pg|pg?sql|postgresql)$/; c=c+'D' - when /^--(?:remote|rsync)$/; c=c+'R' - when /^--(?:scp)$/; c=c+'r' - when /^--(?:source)$/; c=c+'s' - when /^--(?:sisupod|pod)$/; c=c+'S' - when /^--(?:git)$/; c=c+'g' - when /^--(?:urls)$/; c=c+'U' - when /^--(?:zap|delete)$/; c=c+'Z' - when /^--(?:sample-search-form)$/; c=c+'F' - when /^--(?:webserv|webrick)$/; c=c+'W' - when /^--(?:profile)$/; c=c+'E' - when /^--(?:maintenance|keep-processing-files)$/; c=c+'M' - when /^--(?:verbose[=-]3)$/; c=c+'VM' - when /^--(?:verbose[=-]2|Verbose|VERBOSE)$/; c=c+'V' - when /^--(?:verbose(?:[=-]1)?)$/; c=c+'v' - when /^--(?:version)$/; c=c+'v' - when /^--(?:verbose[=-]0|quiet|silent)$/; c=c+'q' + when /^--(?:epub)$/; c=c+'e' + when /^--(?:od[ft])$/; c=c+'o' + when /^--(?:pdf)$/; c=c+'p' + when /^--pdf-(?:a4|a5|b5|legal|letter)$/; c=c+'p' + when /^--pdf-(?:p|l|portrait|landscape)$/; c=c+'L' + when /^--pdf-(?:p(?:ortrait)?|l(?:andscape)?)-(?:a4|letter|a5|b5|legal)$/; c=c+'L' + when /^--pdf-(?:a4|letter|a5|b5|legal)-(?:p(?:ortrait)?|l(?:andscape)?)$/; c=c+'L' + when /^--(?:concordance|wordmap)$/; c=c+'w' + when /^--(?:manpage|man)$/; c=c+'i' + when /^--(?:texinfo)$/; c=c+'I' + when /^--(?:xhtml)$/; c=c+'b' + when /^--(?:xml-sax)$/; c=c+'x' + when /^--(?:xml-dom)$/; c=c+'X' + when /^--(?:images)$/; c=c+'j' + when /^--(?:hash-digests)$/; c=c+'N' + when /^--(?:po4a|pot?)$/; c=c+'P' + when /^--(?:termsheet)$/; c=c+'T' + when /^--(?:manifest)$/; c=c+'y' + when /^--(?:qrcode)$/; c=c+'Q' + when /^--(?:sqlite)$/; c=c+'d' + when /^--(?:pg|pg?sql|postgresql)$/; c=c+'D' + when /^--(?:remote|rsync)$/; c=c+'R' + when /^--(?:scp)$/; c=c+'r' + when /^--(?:source)$/; c=c+'s' + when /^--(?:sisupod|pod)$/; c=c+'S' + when /^--(?:git)$/; c=c+'g' + when /^--(?:urls)$/; c=c+'U' + when /^--(?:zap|delete)$/; c=c+'Z' + when /^--(?:sample-search-form)$/; c=c+'F' + when /^--(?:webserv|webrick)$/; c=c+'W' + when /^--(?:profile)$/; c=c+'E' + when /^--(?:maintenance|keep-processing-files)$/; c=c+'M' + when /^--(?:verbose[=-]3)$/; c=c+'VM' + when /^--(?:verbose[=-]2|Verbose|VERBOSE)$/; c=c+'V' + when /^--(?:verbose(?:[=-]1)?)$/; c=c+'v' + when /^--(?:version)$/; c=c+'v' + when /^--(?:verbose[=-]0|quiet|silent)$/; c=c+'q' else mod << m #mod only contains command modifiers; commands converted to character end end @@ -518,7 +553,7 @@ module SiSU_Commandline end extra='' if cmd !~/[mn]/ - extra+=if cmd =~/[abegHhIiNOoPpQTtwXxyz]/ \ + extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ and cmd !~/[mn]/ 'm' #% add dal elsif ((cmd =~/[Dd]/ \ @@ -561,8 +596,7 @@ module SiSU_Commandline @act=@@act else act={} - act[:license]=(cmd =~/L/ \ - || mod.inspect =~/"--license/) \ + act[:license]=(mod.inspect =~/"--license/) \ ? { bool: true, set: :on } : { bool: false, set: :na } act[:site_init]=(cmd =~/C/ \ @@ -765,16 +799,12 @@ module SiSU_Commandline act[:html_seg]={ bool: true, set: :on } { bool: true, set: :on } else - act[:html_scroll]=if mod.inspect =~/"--html-scroll"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:html_seg]=if mod.inspect =~/"--html-seg"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end + act[:html_scroll]=(mod.inspect =~/"--html-scroll"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:html_seg]=(mod.inspect =~/"--html-seg"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } { bool: false, set: :na } end act[:concordance]=(cmd =~/w/ \ @@ -785,10 +815,65 @@ module SiSU_Commandline || mod.inspect =~/"--images"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } - act[:pdf]=(cmd =~/p/ \ - || mod.inspect =~/"--pdf"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } + if (cmd =~/p/ \ + || mod.inspect =~/"--pdf"/) + if mod.inspect =~/"--portrait"/ + act[:pdf]= { bool: false, set: :na } + act[:pdf_l]={ bool: false, set: :na } + act[:pdf_p]={ bool: true, set: :on } + elsif mod.inspect =~/"--landscape"/ + act[:pdf]= { bool: false, set: :na } + act[:pdf_l]={ bool: true, set: :on } + act[:pdf_p]={ bool: false, set: :na } + else + act[:pdf]= { bool: true, set: :on } + act[:pdf_l]={ bool: true, set: :on } + act[:pdf_p]={ bool: true, set: :on } + end + else + act[:pdf]= { bool: false, set: :na } + act[:pdf_p]= { bool: false, set: :na } + act[:pdf_l]= { bool: false, set: :na } + act[:pdf_a4]= { bool: false, set: :na } + act[:pdf_a5]= { bool: false, set: :na } + act[:pdf_b5]= { bool: false, set: :na } + act[:pdf_letter]={ bool: false, set: :na } + act[:pdf_legal]= { bool: false, set: :na } + end + if act[:pdf][:set]==:on \ + or act[:pdf_p][:set]==:on \ + or act[:pdf_l][:set]==:on + act[:pdf_a4]=if mod.inspect =~/"--a4"|--papersize-a4"/ \ + or mod.inspect =~/"--papersize=\S*a4\b\S*"/ #--papersize=a4,a5 + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_a5]=if mod.inspect =~/"--a5"|"--papersize-a5"/ \ + or mod.inspect =~/"--papersize=\S*a5\b\S*"/ #--papersize=a4,a5 + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_b5]=if mod.inspect =~/"--b5"|"--papersize-b5"/ \ + or mod.inspect =~/"--papersize=\S*b5\b\S*"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_letter]=if mod.inspect =~/"--letter"|"--papersize-letter"/ \ + or mod.inspect =~/"--papersize=\S*letter\b\S*"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_legal]=if mod.inspect =~/"--legal"|"--papersize-legal"/ \ + or mod.inspect =~/"--papersize=\S*legal\b\S*"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end act[:epub]=(cmd =~/e/ \ || mod.inspect =~/"--epub"/) \ ? { bool: true, set: :on } diff --git a/lib/sisu/v4/param.rb b/lib/sisu/v4/param.rb index bcbf9ce3..8d0cf482 100644 --- a/lib/sisu/v4/param.rb +++ b/lib/sisu/v4/param.rb @@ -894,16 +894,6 @@ module SiSU_Param end end #protected - def determine_papersize(l) - l=case l - when /eu|europe|uk/i; 'A4' #European default, SiSU default - when /(?:us-)?legal|legal/i; 'US_legal' #U.S. alternative - when /(?:us-)?letter|u.s.|us/i; 'US_letter' #U.S. default - when /book_a5|a5/i; 'book_a5' - when /book_b5|b5|book/i; 'book_b5' #book default - larger - else 'A4' - end - end def extract @user,@home,@hostname,@pwd=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'] @programs,@wc,@language,@language_original={},{},{},{} @@ -1303,11 +1293,17 @@ module SiSU_Param gsub(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}"). gsub(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") end - if @opt.mod.inspect =~/--papersize[=-]\S+|--pdf[=-]\S+/ \ - or @opt.mod.inspect =~/--(?:a4|letter|legal|book|a5|b5)\b/i #command line config/header override - @papersize=determine_papersize(@opt.mod.inspect) - end - @papersize_array=@papersize.scan(/(?:a4|letter|legal|book|a5|b5)/i) + papersize_array_rc=@papersize.downcase.scan(/(?:a4|letter|legal|book|a5|b5)/) + papersize_array_opt=[ + ((@opt.act[:pdf_a4][:set]==:on) ? 'a4' : ''), + ((@opt.act[:pdf_a5][:set]==:on) ? 'a5' : ''), + ((@opt.act[:pdf_b5][:set]==:on) ? 'b5' : ''), + ((@opt.act[:pdf_letter][:set]==:on) ? 'letter' : ''), + ((@opt.act[:pdf_legal][:set]==:on) ? 'legal' : ''), + ] - [""] + @papersize_array=(papersize_array_opt.length > 0) \ + ? papersize_array_opt + : papersize_array_rc fn=@opt.fno #decide what to do a filesize on .ssm tells very little about actual document size @filesize=(File.size(fn)).to_s if @sys.openssl !=false diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v4/sysenv.rb index d8b6f4fd..728f4fc4 100644 --- a/lib/sisu/v4/sysenv.rb +++ b/lib/sisu/v4/sysenv.rb @@ -60,6 +60,7 @@ @@lang_info=nil module SiSU_Env require_relative 'constants' # constants.rb + require_relative 'utils' # utils.rb require 'fileutils' include FileUtils::Verbose require 'singleton' @@ -213,7 +214,7 @@ module SiSU_Env } @@default_dir=DEFAULT_DIR m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m - @@pwd=@pwd=(/(\S+?)(?:\/(?:#{Px[:lng_lst_rgx]}))?$/).match(Dir.pwd)[1] + @@pwd=@pwd=SiSU_Utils::Path.new.base_markup stub_pwd=@pwd[m,1] attr_accessor :user,:home,:hostname,:pwd,:host,:arch,:rbver,:dir_arch,:dir_sitearch,:dir_bin,:locale,:webserv_path,:webserv_host_cgi,:webserv_port_cgi,:default_dir,:rc_path,:ad_path def initialize @@ -1067,7 +1068,7 @@ module SiSU_Env elsif output_dir_structure.by_filename? '' else - puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:fuschia) + puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuschia) puts 'set output type, by: language, filetype or filename' end @stub_set_manifest=stub + '/manifest' @@ -1940,7 +1941,11 @@ WOK man_path=if @@man_path.nil? man_path=if defined? @rc['webserv']['path'] \ and @rc['webserv']['path'] =~/\S\S+/ + pwd=Dir.pwd + Dir.chdir(SiSU_Utils::Path.new.base_markup) man_path=@@man_path=File.expand_path(@rc['webserv']['path']) + Dir.chdir(pwd) + man_path else defaults[:webserv_path] end else @@man_path @@ -3926,7 +3931,7 @@ WOK class InfoDb < InfoEnv @@rc=nil def initialize - @@pwd=@pwd=(/(\S+?)(?:\/(?:#{Px[:lng_lst_rgx]}))?$/).match(Dir.pwd)[1] + @@pwd=@pwd=SiSU_Utils::Path.new.base_markup @env=SiSU_Env::InfoEnv.new pt=Pathname.new(@pwd) r=Px[:lng_lst_rgx] diff --git a/lib/sisu/v4/texpdf.rb b/lib/sisu/v4/texpdf.rb index aa1f9444..34d4f69c 100644 --- a/lib/sisu/v4/texpdf.rb +++ b/lib/sisu/v4/texpdf.rb @@ -109,8 +109,12 @@ module SiSU_TeX SiSU_Screen::Ansi.new(@opt.cmd,'LaTeX/PDF',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_title_hi unless @opt.cmd =~/q/ if @opt.cmd =~/[MVv]/ path=@env.url.output_tell - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}pdf").flow - SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@opt.fns} #{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}pdf").flow + if @md.opt.act[:pdf_l][:set]==:on + SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_l}pdf").flow + end + if @md.opt.act[:pdf_p][:set]==:on + SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@opt.fns} #{@env.program.pdf_viewer} #{@md.file.output_path.pdf.dir}/#{@md.file.base_filename.pdf_p}pdf").flow + end end @md=@particulars.md $flag=@md.opt.cmd #introduced to pass 0 for no object citation numbers... to texpdf_format @@ -157,27 +161,35 @@ module SiSU_TeX def latex_do(texfilename,papersize) @texfilename=texfilename @@n_lpdf=@@n_lpdf+1 - SiSU_Screen::Ansi.new(@md.opt.cmd,"#{papersize} portrait ->").dark_grey_title_hi if @md.opt.cmd =~/[MVv]/ tex_fn_base=@texfilename.gsub(/\.tex$/,'') - cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.tex",'',@md.opt.cmd) tell=SiSU_Screen::Ansi.new(@md.opt.cmd) - tell.grey_open if @md.opt.cmd =~/[MVv]/ - if "#{tex_fn_base}" =~/\w+/ \ - and "#{papersize}" =~/\w+/ - 2.times { |i| cmd.latex2pdf(@md,papersize) } #comment out to skip processing of latex portrait - end - tell.p_off if @md.opt.cmd =~/[MVv]/ - SiSU_Screen::Ansi.new(@md.opt.cmd,"#{papersize} landscape ->").dark_grey_title_hi if @md.opt.cmd =~/[MVv]/ - cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.landscape.tex",'',@md.opt.cmd) - tell.grey_open if @md.opt.cmd =~/[MVv]/ - if "#{tex_fn_base}" =~/\w+/ \ - and "#{papersize}" =~/\w+/ - 2.times { |i| cmd.latex2pdf(@md,papersize) } #comment out to skip processing of latex landscape - end - tell.p_off if @md.opt.cmd =~/[MVv]/ + if @md.opt.act[:pdf_p][:set]==:on + SiSU_Screen::Ansi.new(@md.opt.cmd,"#{papersize} portrait ->").dark_grey_title_hi if @md.opt.cmd =~/[MVv]/ + cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.tex",'',@md.opt.cmd) + tell.grey_open if @md.opt.cmd =~/[MVv]/ + if "#{tex_fn_base}" =~/\w+/ \ + and "#{papersize}" =~/\w+/ + 2.times { |i| cmd.latex2pdf(@md,papersize) } #comment out to skip processing of latex portrait + end + tell.p_off if @md.opt.cmd =~/[MVv]/ + end + if @md.opt.act[:pdf_l][:set]==:on + SiSU_Screen::Ansi.new(@md.opt.cmd,"#{papersize} landscape ->").dark_grey_title_hi if @md.opt.cmd =~/[MVv]/ + cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.landscape.tex",'',@md.opt.cmd) + tell.grey_open if @md.opt.cmd =~/[MVv]/ + if "#{tex_fn_base}" =~/\w+/ \ + and "#{papersize}" =~/\w+/ + 2.times { |i| cmd.latex2pdf(@md,papersize) } #comment out to skip processing of latex landscape + end + tell.p_off if @md.opt.cmd =~/[MVv]/ + end pwd=Dir.pwd - portrait_pdf="#{pwd}/#{tex_fn_base}.pdf" - landscape_pdf="#{pwd}/#{tex_fn_base}.landscape.pdf" + if @md.opt.act[:pdf_p][:set]==:on + portrait_pdf="#{pwd}/#{tex_fn_base}.pdf" + end + if @md.opt.act[:pdf_l][:set]==:on + landscape_pdf="#{pwd}/#{tex_fn_base}.landscape.pdf" + end case papersize when /a4/; pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 when /a5/; pdf_p=@f.pdf_p_a5; pdf_l=@f.pdf_l_a5 @@ -187,15 +199,19 @@ module SiSU_TeX else pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 end FileUtils::mkdir_p(@md.file.output_path.pdf.dir) unless FileTest.directory?(@md.file.output_path.pdf.dir) - if FileTest.file?(portrait_pdf) - FileUtils::cp(portrait_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_p}") - FileUtils::rm(portrait_pdf) - else p "#{__FILE__}:#{__LINE__} NOT FOUND: #{portrait_pdf}" if @md.opt.cmd.inspect =~/M/ + if @md.opt.act[:pdf_p][:set]==:on + if FileTest.file?(portrait_pdf) + FileUtils::cp(portrait_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_p}") + FileUtils::rm(portrait_pdf) + else p "#{__FILE__}:#{__LINE__} NOT FOUND: #{portrait_pdf}" if @md.opt.cmd.inspect =~/M/ + end end - if FileTest.file?(landscape_pdf) - FileUtils::cp(landscape_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_l}") - FileUtils::rm(landscape_pdf) - else p "#{__FILE__}:#{__LINE__} NOT FOUND: #{landscape_pdf}" if @md.opt.cmd.inspect =~/M/ + if @md.opt.act[:pdf_l][:set]==:on + if FileTest.file?(landscape_pdf) + FileUtils::cp(landscape_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_l}") + FileUtils::rm(landscape_pdf) + else p "#{__FILE__}:#{__LINE__} NOT FOUND: #{landscape_pdf}" if @md.opt.cmd.inspect =~/M/ + end end SiSU_Screen::Ansi.new(@md.opt.cmd,@@n_lpdf,'processed (SiSU LaTeX to pdf - using pdfetex aka. pdftex or pdflatex)').generic_number if @md.opt.cmd =~/[MVv]/ end @@ -214,13 +230,18 @@ module SiSU_TeX Dir.chdir(@env.processing_path.tex) texfile=@md.fns.gsub(/$/,".#{ps}.tex"). gsub(/~/,'-') - if File.exist?(texfile) \ - and File.size(texfile) > 0 - @tex_f_no+=1 - #p "#{__FILE__}:#{__LINE__} texpdf generation disabled" if @md.opt.cmd.inspect =~/M/ #%% disable temporarily, re-enable + if @md.opt.act[:pdf_p][:set]==:on \ + or @md.opt.act[:pdf_l][:set]==:on latex_do(texfile,ps) - else - puts "\tzero file size #{@env.processing_path.tex}/#{texfile}" + if @md.opt.act[:pdf_p][:set]==:on + if File.exist?(texfile) \ + and File.size(texfile) > 0 + #@tex_f_no+=1 + else + puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) + puts "\tzero file size #{@env.processing_path.tex}/#{texfile}" + end + end end end end @@ -234,31 +255,33 @@ module SiSU_TeX when /legal/; pdf_p=@f.pdf_p_legal; pdf_l=@f.pdf_l_legal else pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4 end - if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{pdf_p}") - mklnk=if @md.file.output_dir_structure.by_language_code? \ - or @md.file.output_dir_structure.by_filetype? - "#{@md.fnb}.portrait.pdf" - else 'portrait.pdf' + if @md.opt.act[:pdf_p][:set]==:on + if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{pdf_p}") + mklnk=((@md.file.output_dir_structure.by_language_code?) \ + || (@md.file.output_dir_structure.by_filetype?)) \ + ? "#{@md.fnb}.portrait.pdf" + : 'portrait.pdf' + if FileTest.directory?(@md.file.output_path.pdf.dir) + pwd=Dir.pwd + Dir.chdir(@md.file.output_path.pdf.dir) + FileUtils::rm_f(mklnk) + FileUtils::ln_s(pdf_p, mklnk) + Dir.chdir(pwd) + end end - if FileTest.directory?(@md.file.output_path.pdf.dir) - pwd=Dir.pwd + end + if @md.opt.act[:pdf_l][:set]==:on + if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{pdf_l}") + mklnk=((@md.file.output_dir_structure.by_language_code?) \ + || (@md.file.output_dir_structure.by_filetype?)) \ + ? "#{@md.fnb}.landscape.pdf" + : 'landscape.pdf' + pwd_set=Dir.pwd Dir.chdir(@md.file.output_path.pdf.dir) FileUtils::rm_f(mklnk) - FileUtils::ln_s(pdf_p, mklnk) - Dir.chdir(pwd) - end - end - if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{pdf_l}") - mklnk=if @md.file.output_dir_structure.by_language_code? \ - or @md.file.output_dir_structure.by_filetype? - "#{@md.fnb}.landscape.pdf" - else 'landscape.pdf' + FileUtils::ln_s(pdf_l, mklnk) + Dir.chdir(pwd_set) end - pwd_set=Dir.pwd - Dir.chdir(@md.file.output_path.pdf.dir) - FileUtils::rm_f(mklnk) - FileUtils::ln_s(pdf_l, mklnk) - Dir.chdir(pwd_set) end else SiSU_Screen::Ansi.new(@md.opt.cmd,"*WARN* FILE NOT FOUND: << #{@md.fns} >> - requested latex system processing skipped").warn @@ -303,7 +326,18 @@ module SiSU_TeX data=@data @@tex_footnote_array=[] @@rights=nil - SiSU_Screen::Ansi.new(@md.opt.cmd,"pdfTex portrait & landscape").txt_grey if @md.opt.cmd=~/[MVvz]/ + txt_gen=if @md.opt.act[:pdf_l][:set]==:on \ + and @md.opt.act[:pdf_p][:set]==:on + 'pdfTex portrait & landscape' + elsif @md.opt.act[:pdf_l][:set]==:on + 'pdfTex landscape' + elsif @md.opt.act[:pdf_p][:set]==:on + 'pdfTex portrait' + else + puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) + 'error: neither landscape nor portrait' + end + SiSU_Screen::Ansi.new(@md.opt.cmd,txt_gen).txt_grey if @md.opt.cmd=~/[MVvz]/ if defined? @md.rights.all \ and not @md.rights.all.empty? rght=@md.rights #.author.dup #dup is necessary, else contents of :rights changed @@ -607,7 +641,7 @@ module SiSU_TeX dob end def tex_box_listings - <<WOK + <<-WOK \\definecolor{listinggray}{gray}{0.9} \\definecolor{lbcolor}{rgb}{0.9,0.9,0.9} \\lstset{ @@ -632,10 +666,10 @@ module SiSU_TeX commentstyle=\\color[rgb]{0.133,0.545,0.133}, stringstyle=\\color[rgb]{0.627,0.126,0.941}, } -WOK + WOK end def tex_box_boites - <<WOK + <<-WOK \\def\\codeblockboitebox{% \\def\\bkvz@before@breakbox{\\ifhmode\\par\\fi\\vskip\\breakboxskip\\relax}% \\def\\bkvz@set@linewidth{\\advance\\linewidth -2\\fboxrule @@ -653,7 +687,7 @@ WOK \\def\\bkvz@bottom{\\hrule\\@height\\fboxrule}% \\breakbox} \\def\\endcodeblockboitebox{\\endbreakbox} -WOK + WOK end def tex_codeblock codeblock_box=if @codeblock_box=='listings' @@ -671,14 +705,18 @@ WOK home=@vz.txt_home.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') #no line splitting in heading neither html nor latex title=@md.title.full.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') #no line splitting in heading neither html nor latex @md.papersize_array.each do |ps| - txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: 'portrait' } - orient_portrait=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj) - txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: 'landscape' } - orient_landscape=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj) - @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation(@codeblock_box) - @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation(@codeblock_box) - end - @tex_file <<<<WOK + if @md.opt.act[:pdf_p][:set]==:on + txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: 'portrait' } + orient_portrait=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj) + @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation(@codeblock_box) + end + if @md.opt.act[:pdf_l][:set]==:on + txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: 'landscape' } + orient_landscape=SiSU_TeX_Pdf::FormatHead.new(@md,txt_obj) + @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation(@codeblock_box) + end + end + @tex_file <<<<-WOK #{@tex_ml.header}#{@tex_ml.footer} \\tolerance=300 \\clubpenalty=300 @@ -708,15 +746,19 @@ WOK % (tilde hash amp affected by http) % \\sloppy \\begin{document} -WOK + WOK sisu_rc_footnote=if @md.sc_info then @tex_ml.doc_sc_info_footnote_full else @tex_ml.doc_sc_info_footnote_brief end @copymark='' #check and remove as now is superflous x={} txt_obj={ title: @md.title.full } - x[:l]=SiSU_TeX_Pdf::FormatTextObject.new(@md,txt_obj).title_landscape - x[:p]=SiSU_TeX_Pdf::FormatTextObject.new(@md,txt_obj).title_portrait + if @md.opt.act[:pdf_l][:set]==:on + x[:l]=SiSU_TeX_Pdf::FormatTextObject.new(@md,txt_obj).title_landscape + end + if @md.opt.act[:pdf_p][:set]==:on + x[:p]=SiSU_TeX_Pdf::FormatTextObject.new(@md,txt_obj).title_portrait + end @tex_file << x x=nil if defined? @md.creator.author \ @@ -724,10 +766,10 @@ WOK sp_char=SiSU_TeX_Pdf::SpecialCharacters.new(@md,@md.creator.author) author=sp_char.special_characters @tex_file << if @md.author_home - <<WOK + <<-WOK \\author{\\href{#{@md.author_home}}{#{@copymark} \\textnormal{#{author}}}} -WOK + WOK else "\n\\author{#{@copymark} \\textnormal{#{author}}}" end end @@ -736,22 +778,22 @@ WOK and @md.make.cover_image[:cover] =~/\S+/ x={} dir=SiSU_Env::InfoEnv.new(@md.fns) - x[:l] =<<WOK + x[:l] =<<-WOK \\titlepic{\\includegraphics[width=0.3\\textwidth]{#{dir.path.image_source_include}/#{@md.make.cover_image[:cover]}}} -WOK - x[:p] =<<WOK + WOK + x[:p] =<<-WOK \\titlepic{\\includegraphics[width=0.6\\textwidth]{#{dir.path.image_source_include}/#{@md.make.cover_image[:cover]}}} -WOK + WOK @tex_file << x x=nil end @tex_file << unless @md.fnb =~/^mail\s*$/ then @tex_ml.site else '\date' end - @tex_file <<<<WOK + @tex_file <<<<-WOK \\pagenumbering{roman}\\maketitle \\pagestyle{fancy} -WOK + WOK if defined? @md.rights.all \ and @md.rights.all @tex_file << "\\newpage\n" @@ -760,24 +802,27 @@ WOK end x={} if (@make.build.toc?) - toc=<<WOK + toc=<<-WOK \\renewcommand{\\contentsname}{#{@translate.contents}} \\tableofcontents -WOK + WOK toc_pb={ l: @tex_ml.newpage('landscape'), p: @tex_ml.newpage('portrait') } else toc='' toc_pb={ l: '', p: '' } end - x[:l] =<<WOK + if @md.opt.act[:pdf_l][:set]==:on + x[:l] =<<-WOK #{@tex_ml.newpage('landscape')} \\pagestyle{fancy} #{toc}#{toc_pb[:l]} \\pagenumbering{arabic} #{@tex_ml.paraskip_normal} #{@tex_ml.newpage('landscape')} -WOK - x[:p] =<<WOK + WOK + end + if @md.opt.act[:pdf_p][:set]==:on + x[:p] =<<-WOK #{@tex_ml.newpage('portrait')} \\pagestyle{fancy} #{toc}#{toc_pb[:p]} @@ -785,7 +830,8 @@ WOK \\pagenumbering{arabic} #{@tex_ml.paraskip_normal} #{@tex_ml.newpage('portrait')} -WOK + WOK + end @tex_file << x x=nil data.each do |dob| #% case follows with levels 1-6 indents & graphics @@ -897,59 +943,77 @@ WOK def output_morph_hash(o) ps,h,fn=o[:ps],o[:h],o[:filename] if h[ps] \ - and (h[ps][:p] and h[ps][:l]) - if h[ps][:p] - h[ps][:p]=h[ps][:p].gsub(/[ ]+$/m,''). - gsub(/\n\n\n+/m,"\n\n") - end - if h[ps][:l] - h[ps][:l]=h[ps][:l].gsub(/[ ]+$/m,''). - gsub(/\n\n\n+/m,"\n\n") - end - #h[ps][:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:p] - #h[ps][:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:l] - if h[ps][:p] !~/\A\s*\Z/ - fn[:portrait].puts h[ps][:p],"\n" - end - if h[ps][:l] !~/\A\s*\Z/ - fn[:landscape].puts h[ps][:l],"\n" - end - elsif (h[:p] and h[:l]) - if h[:p] - h[:p]=h[:p].gsub(/[ ]+$/m,''). - gsub(/\n\n\n+/m,"\n\n") + and (h[ps][:p] or h[ps][:l]) + if @md.opt.act[:pdf_p][:set]==:on + if h[ps][:p] + h[ps][:p]=h[ps][:p].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + if h[ps][:p] !~/\A\s*\Z/ + fn[:portrait].puts h[ps][:p],"\n" + end end - if h[:l] - h[:l]=h[:l].gsub(/[ ]+$/m,''). - gsub(/\n\n\n+/m,"\n\n") + if @md.opt.act[:pdf_l][:set]==:on + if h[ps][:l] + h[ps][:l]=h[ps][:l].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + if h[ps][:l] !~/\A\s*\Z/ + fn[:landscape].puts h[ps][:l],"\n" + end end - #h[:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:p] - #h[:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:l] - if h[:p] !~/\A\s*\Z/ - fn[:portrait].puts h[:p],"\n" + elsif (h[:p] or h[:l]) + if @md.opt.act[:pdf_p][:set]==:on + if h[:p] + h[:p]=h[:p].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + if h[:p] !~/\A\s*\Z/ + fn[:portrait].puts h[:p],"\n" + end end - if h[:l] !~/\A\s*\Z/ - fn[:landscape].puts h[:l],"\n" + if @md.opt.act[:pdf_l][:set]==:on + if h[:l] + h[:l]=h[:l].gsub(/[ ]+$/m,''). + gsub(/\n\n\n+/m,"\n\n") + end + if h[:l] !~/\A\s*\Z/ + fn[:landscape].puts h[:l],"\n" + end end else p "#{__FILE__}:#{__LINE__}" if @md.opt.cmd.inspect =~/M/ end end def output(array) @array=array=array.flatten.compact - fns_l=@md.fns.gsub(/~/,'-') #this is a sorry fix, but necessary as it appears latex programs like not ~ + fns=@md.fns.gsub(/~/,'-') #this is a sorry fix, but necessary as it appears latex programs like not ~ @md.papersize_array.each do |ps| + texfile_landscape=(@md.opt.act[:pdf_l][:set]==:on) \ + ? (File.new("#{@env.processing_path.tex}/#{fns}.#{ps}.landscape.tex",'w+')) + : nil + texfile_portrait=(@md.opt.act[:pdf_p][:set]==:on) \ + ? (File.new("#{@env.processing_path.tex}/#{fns}.#{ps}.tex",'w+')) + : nil file={ - landscape: File.new("#{@env.processing_path.tex}/#{fns_l}.#{ps}.landscape.tex",'w+'), - portrait: File.new("#{@env.processing_path.tex}/#{fns_l}.#{ps}.tex",'w+') + landscape: texfile_landscape, + portrait: texfile_portrait } - file[:portrait] << @@tex_head[ps][:p] - file[:landscape] << @@tex_head[ps][:l] + if @md.opt.act[:pdf_p][:set]==:on + file[:portrait] << @@tex_head[ps][:p] + end + if @md.opt.act[:pdf_l][:set]==:on + file[:landscape] << @@tex_head[ps][:l] + end array.each do |morph| if morph.is_a?(String) #morph.gsub!(/^\s+/,'') if morph !~/\A\s*\Z/ - file[:portrait].puts morph,"\n" - file[:landscape].puts morph,"\n" + if @md.opt.act[:pdf_p][:set]==:on + file[:portrait].puts morph,"\n" + end + if @md.opt.act[:pdf_l][:set]==:on + file[:landscape].puts morph,"\n" + end end elsif morph.class.inspect =~ /SiSU_DAL_DocumentStructure/ \ and morph.tmp \ @@ -961,8 +1025,12 @@ WOK end if (morph.tmp !~/\A\s*\Z/) \ || morph.is==:code - file[:portrait].puts morph.tmp,"\n" - file[:landscape].puts morph.tmp,"\n" + if @md.opt.act[:pdf_p][:set]==:on + file[:portrait].puts morph.tmp,"\n" + end + if @md.opt.act[:pdf_l][:set]==:on + file[:landscape].puts morph.tmp,"\n" + end end elsif morph.is_a?(Hash) #inserted headers and the like, only h={ ps: ps, h: morph, filename: file } @@ -973,8 +1041,12 @@ WOK end end array=@array - file[:portrait].close - file[:landscape].close + if @md.opt.act[:pdf_p][:set]==:on + file[:portrait].close + end + if @md.opt.act[:pdf_l][:set]==:on + file[:landscape].close + end end @@tex_head={ 'a4'=> { p: nil, l: nil }, diff --git a/lib/sisu/v4/texpdf_format.rb b/lib/sisu/v4/texpdf_format.rb index e1dbcb18..abb4c5e0 100644 --- a/lib/sisu/v4/texpdf_format.rb +++ b/lib/sisu/v4/texpdf_format.rb @@ -798,7 +798,7 @@ module SiSU_TeX_Pdf # fc-list :outline -f "%{family}\n" case @tex2pdf when /xe/ - <<WOK + <<-WOK \\usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode} \\setmainlanguage{#{tex_head_lang[:mainlang]}} \\setotherlanguage{#{tex_head_lang[:otherlang]}} @@ -806,19 +806,19 @@ module SiSU_TeX_Pdf \\setmonofont[Scale=0.85]{#{texpdf_font_mono}} % \\setsansfont{#{texpdf_font_sans}} % \\setromanfont{#{texpdf_font_serif}} -WOK + WOK when /pdf/ if @md.file_encoding =~ /iso-?8859/i #% iso8859 - <<WOK + <<-WOK % \\usepackage[latin1]{inputenc} \\usepackage{fontspec} -WOK + WOK else #% utf-8 assumed - <<WOK + <<-WOK \\usepackage{babel} \\usepackage{ucs} \\usepackage[utf8x]{inputenc} -WOK + WOK end end end @@ -826,18 +826,18 @@ WOK generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version] lastdone="Last Generated on: #{Time.now}" rubyv="Ruby version: #{@md.ruby_version}" - <<WOK + <<-WOK %% SiSU (Linux & Ruby - \"better ways\") LaTeX output %% #{generator} %% #{rubyv} %% LaTeX output %% #{lastdone} %% SiSU http://www.jus.uio.no/sisu -WOK + WOK end def tex_head_paper_portrait(d) multicol=(@md.book_idx ? '\usepackage{multicol}' : '') - <<WOK + <<-WOK #{tex_head_info} \\documentclass[#{d[:fontsize]},#{d[:papertype]},titlepage]{scrartcl} %with titlepage \\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm} @@ -847,10 +847,10 @@ WOK \\setlength{\\marginparsep}{#{d[:marginparsep]}} \\setlength{\\marginparwidth}{#{d[:marginparwidth]}} #{multicol} -WOK + WOK end def tex_head_paper_landscape(d) - <<WOK + <<-WOK #{tex_head_info} \\documentclass[#{d[:fontsize]},#{d[:papertype]},landscape,titlepage,twocolumn]{scrartcl} %with titlepage \\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm} @@ -860,10 +860,10 @@ WOK \\setlength{\\columnsep}{#{d[:columnsep]}} \\setlength{\\marginparsep}{#{d[:marginparsep]}} \\setlength{\\marginparwidth}{#{d[:marginparwidth]}} -WOK + WOK end def tex_head_paper_portrait_dvi(d) - <<WOK + <<-WOK #{tex_head_info} \\documentclass[#{d[:fontsize]},#{d[:papertype]},titlepage]{scrartcl} %with titlepage \\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm} @@ -872,7 +872,7 @@ WOK \\setlength{\\headsep}{#{d[:headsep]}} \\setlength{\\marginparsep}{#{d[:marginparsep]}} \\setlength{\\marginparwidth}{#{d[:marginparwidth]}} -WOK + WOK end def tex_head_paper_dimensions d={} @@ -946,22 +946,22 @@ WOK def tex_head_pdftex_dvi color=case @layout when /portrait/ - <<WOK + <<-WOK colorlinks=true, urlcolor=myblack, filecolor=myblack, linkcolor=myblack, -WOK + WOK when /landscape/ - <<WOK + <<-WOK colorlinks=true, urlcolor=myblue, % \\href{...}{...} external url filecolor=mygreen, % \\href{...} local file linkcolor=myred, % \\href{...} and \\pageref{...} -WOK + WOK end if @layout =~/portrait|landscape/ - <<WOK + <<-WOK \\usepackage{alltt} \\usepackage{thumbpdf} \\usepackage[#{@tex2pdf}, @@ -1000,9 +1000,9 @@ WOK \\definecolor{mywhite}{rgb}{1,1,1} \\usepackage{url} %\\usepackage{breakurl} -WOK + WOK elsif @txt =~/dvi/ - <<WOK + <<-WOK \\usepackage{alltt} #{color.strip} pageanchor=true, @@ -1021,16 +1021,16 @@ WOK \\definecolor{mywhite}{rgb}{1,1,1} \\usepackage{url} %\\usepackage{breakurl} -WOK + WOK end end def tex_head_codeblock(codeblock_box_type) codeblock_box=if codeblock_box_type=='listings' - <<WOK + <<-WOK \\usepackage{listings} \\usepackage{color} \\usepackage{textcomp} -WOK + WOK elsif codeblock_box_type=='boites' "\\usepackage{boites}" else @@ -1039,7 +1039,7 @@ WOK codeblock_box end def tex_head_misc - <<WOK + <<-WOK \\usepackage{textcomp} \\usepackage[parfill]{parskip} \\usepackage[normalem]{ulem} @@ -1052,12 +1052,12 @@ WOK %\\usepackage{mathptmx} \\usepackage{amssymb} % amssymb used for backslash -WOK + WOK end def document_head_with_orientation(codeblock_box_type) - endnotes=("\\usepackage{endnotes}" if @txt =~/endnotes?/)||'' #not implemented see also def endnotes + endnotes=("\\usepackage{endnotes}" if @txt =~/endnotes?/) || '' #not implemented see also def endnotes @lang.list[@md.i18n[0]][:xlp] - <<WOK + <<-WOK #{tex_head_paper} #{tex_head_encode} #{tex_head_pdftex_dvi} @@ -1134,7 +1134,7 @@ WOK {\\normalfont\\normalsize\\itshape\\raggedright}} % \\makeatother \\selectlanguage{#{@lang.list[@md.i18n[0]][:xlp]}} -WOK + WOK end def a4generic end @@ -1443,13 +1443,13 @@ WOK def newpage(orientation) case orientation when /landscape/ # using longtable latex package -<<WOK + <<-WOK \\clearpage -WOK + WOK when /portrait/ -<<WOK + <<-WOK \\newpage -WOK + WOK end end def sisu_rights @@ -1461,7 +1461,7 @@ WOK end else '' end -<<WOK + <<-WOK \\\\ ~ {\\begin{footnotesize}#{base_prog_txt} \\\\ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\begin{tiny}[ #{v[:project]} #{v[:version]} of #{v[:date_stamp]} ]\\end{tiny} \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu} @@ -1470,19 +1470,19 @@ WOK \\\\ SiSU is released under \\href{http://www.fsf.org/licenses/gpl.html}{GPL 3 } or later, #{@brace_url.tex_open}\\href{http://www.fsf.org/licenses/gpl.html}{http://www.fsf.org/licenses/gpl.html}#{@brace_url.tex_close}. {\\end{footnotesize} \\\\ -WOK + WOK end def doc_sc_info_footnote_full -<<WOK + <<-WOK \\footnote{%\nGenerated by \\href{http://www.jus.uio.no/sisu}{SiSU \\ www.jus.uio.no/sisu }\\ \\newline \\scriptsize{Document version information: \\emph{sourcefile} \\uline{#{@md.fnstex}}; \\emph{version} \\uline{#{@md.sc_number}}; \\emph{date} \\uline{#{@md.sc_date}}; \\emph{time} \\uline{#{@md.sc_time}}}} -WOK + WOK end def doc_sc_info_footnote_brief " \\footnote{%\nGenerated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\ \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu} \\newline \\href{http://www.sisudoc.org}{www.sisudoc.org} \\\n}" end def doc_sc_info v=SiSU_Env::InfoVersion.instance.get_version -<<WOK + <<-WOK \\\\ {\\begin{footnotesize} Document version information: \\\\ @@ -1490,11 +1490,11 @@ Document version information: \\\\ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu }\\- version information: \\\\ \\uline{ #{v[:project]} #{v[:version]} of #{v[:date_stamp]}} \\end{footnotesize}}& -WOK + WOK end def doc_no_sc_info v=SiSU_Env::InfoVersion.instance.get_version -<<WOK + <<-WOK \\\\ {\\begin{small} Document information: \\\\ @@ -1503,15 +1503,15 @@ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu } \\\\ \\uline{ #{v[:project]} #{v[:version]} of #{v[:date_stamp]}} \\end{small}}& -WOK + WOK end def endnotes #not used should be inserted before MetaData section which preceeds doc_tail, but is "part of document" -<<WOK + <<-WOK \\subsection*{Endnotes} \\addcontentsline{toc}{section}{Endnotes} \\ \\listofendnotes -WOK + WOK end def doc_tail dir=SiSU_Env::InfoEnv.new(@md.fns) @@ -1524,7 +1524,7 @@ WOK " SiSU " end url=@md.fnb.gsub(/(?:\\)*([$&~%_#}{^])/,'\\\\\1') -<<WOK + <<-WOK \\begin{english}[variant=british] \\subsection*{Information on this document copy and an unofficial List of Some web related information and sources} \\addcontentsline{toc}{section}{Information on this document copy and an unofficial List of Some web related information and sources} @@ -1551,11 +1551,11 @@ WOK #{sitename} found at: \\begin{scriptsize}#{site}\\end{scriptsize}\\subsubsection*{Links that may be of interest at #{@vz.txt_home} and elsewhere:} \\addcontentsline{toc}{subsection}{Links that may be of interest} \\end{english} -WOK + WOK end def mail_tail #not retested, the old mail_tail is commented out and appended to this program dir=SiSU_Env::InfoEnv.new(@md.fns) -<<WOK + <<-WOK \\subsection*{Mail sender details} \\addcontentsline{toc}{subsection}{Mail sender details} \\\\ @@ -1566,7 +1566,7 @@ Mail from: ralph@amissah.com\\\\ \"Support Open Standards and Open Sources for the Information Technology Infrastructure\" RA \\subsubsection*{Information on this document copy #{site}\\copyright} Presentations' look and feel generated by \\href{http://www.jus.uio.no/sisu/}{SiSU Scribe} \\href{http://www.jus.uio.no/sisu/}{http://www.jus.uio.no/sisu/} programmed in Ruby on Debian/Gnu/Linux by Copyright \\copyright Ralph Amissah, W3 since October 3 1993 \\href{http://www.jus.uio.no/sisu/}{\\includegraphics*[width=35pt]{#{dir.path.image_source_include}/sisu.png}}for #{sitename}. SiSU Scribe (sisu information structuring unit) produces Electronic Documents, i.e. it generates structured output for use in a number of file formats, including the pdf file produced here. -WOK + WOK end end end diff --git a/lib/sisu/v4/urls.rb b/lib/sisu/v4/urls.rb index 5e6bcc8a..e3671dcd 100644 --- a/lib/sisu/v4/urls.rb +++ b/lib/sisu/v4/urls.rb @@ -355,11 +355,17 @@ module SiSU_Urls end end if x=~/--pdf\b/ \ - and @opt.act[:pdf][:set]==:on + and (@opt.act[:pdf][:set]==:on \ + or @opt.act[:pdf_p][:set]==:on \ + or @opt.act[:pdf_l][:set]==:on) if x =~/portrait/ - show.pdf.portrait(x) + if @opt.act[:pdf_p][:set]==:on + show.pdf.portrait(x) + end else - show.pdf.landscape(x) + if @opt.act[:pdf_l][:set]==:on + show.pdf.landscape(x) + end end end if x=~/--sisupod\b/ \ diff --git a/lib/sisu/v4/debug.rb b/lib/sisu/v4/utils.rb index a49cecb7..040e06b6 100644 --- a/lib/sisu/v4/debug.rb +++ b/lib/sisu/v4/utils.rb @@ -55,8 +55,8 @@ ** Description: system environment, debug related =end -module SiSU_Debug - class Mark +module SiSU_Utils + class CodeMarker def initialize(line,file,color=:red) @line,@file,@color=line.to_s,file,color end @@ -99,11 +99,22 @@ module SiSU_Debug @file.gsub(/([^\/]+$)/,"#{c[:on]}\\1#{c[:off]}") end end + class Path + def initialize(dir=Dir.pwd) + @dir=dir + end + def base_markup + (/(\S+?)(?:\/(?:#{Px[:lng_lst_rgx]}))?$/).match(Dir.pwd)[1] + end + def bmd + base_markup + end + end end __END__ -puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:red) -puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:green) -puts SiSU_Debug::Mark.new(__LINE__,__FILE__).set(:inv_red) -puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:red).set -puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:green).set -puts SiSU_Debug::Mark.new(__LINE__,__FILE__,:inv_red).set +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:red) +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:green) +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:inv_red) +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:red).set +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).set +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:inv_red).set |