From 3d16556052d17ef636f576f93bb4e525c6c58e22 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 6 Feb 2013 22:28:34 -0500 Subject: v4: pdf (texpdf, options, hub, urls) orientation discrete, individually callable --- data/doc/sisu/CHANGELOG_v4 | 9 +- lib/sisu/v4/hub.rb | 8 +- lib/sisu/v4/options.rb | 115 +++++++++++-------- lib/sisu/v4/texpdf.rb | 278 ++++++++++++++++++++++++++++----------------- lib/sisu/v4/urls.rb | 12 +- 5 files changed, 264 insertions(+), 158 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4 index 8244ed40..494a51e8 100644 --- a/data/doc/sisu/CHANGELOG_v4 +++ b/data/doc/sisu/CHANGELOG_v4 @@ -26,6 +26,13 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.0.6.orig.tar.xz * v4: html, screen reporting for --html-scroll, correctly identify output file +* v4: pdf + * pdf (options, hub, urls), orientation, portrait & landscape optionally + discrete, individually callable + * --pdf-l (--pdf-landscape), --pdf-p (--pdf-portrait) + * sisu latex output & xetex generation + * texpdf, cosmetic code + * v4: utils (debug renamed) * SiSU_Utils::CodeMarker (from Debug::Mark) * SiSU_Utils::Path.new.base_markup provides base markup directory that @@ -33,8 +40,6 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.0.6.orig.tar.xz files) and sisu resource configuration sub-directory, if any (./_sisu) (identifies when needed in runtime) -* v4: texpdf, cosmetic code - * v4: sysenv, webserv dir (output dir), ensure it is determined from base markup dir where relative path provided (remove possibility of it being done from a language sub-directory), fix diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v4/hub.rb index 0cfa0d6e..ccae2b9f 100644 --- a/lib/sisu/v4/hub.rb +++ b/lib/sisu/v4/hub.rb @@ -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 6aac2b1a..fca60a3d 100644 --- a/lib/sisu/v4/options.rb +++ b/lib/sisu/v4/options.rb @@ -465,47 +465,49 @@ module SiSU_Commandline 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-(?:p|l|portrait|landscape)$/; c=c+'L' + mod << m + 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 +520,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 +563,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/ \ @@ -781,10 +782,30 @@ 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 } + act[:pdf]=if (cmd =~/p/ \ + || mod.inspect =~/"--pdf"/) + if mod.inspect =~/"--portrait"/ + act[:pdf_p]={ bool: true, set: :on } + act[:pdf_l]={ bool: false, set: :na } + { bool: false, set: :na } + elsif mod.inspect =~/"--landscape"/ + act[:pdf_l]={ bool: true, set: :on } + act[:pdf_p]={ bool: false, set: :na } + { bool: false, set: :na } + else + act[:pdf_p]={ bool: true, set: :on } + act[:pdf_l]={ bool: true, set: :on } + { bool: true, set: :on } + end + else + act[:pdf_p]=(mod.inspect =~/"--pdf-(?:p|portrait)"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:pdf_l]=(mod.inspect =~/"--pdf-(?:l|landscape)"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + { bool: false, set: :na } + end act[:epub]=(cmd =~/e/ \ || mod.inspect =~/"--epub"/) \ ? { bool: true, set: :on } diff --git a/lib/sisu/v4/texpdf.rb b/lib/sisu/v4/texpdf.rb index 20998e6c..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,32 +255,34 @@ 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) + FileUtils::ln_s(pdf_l, mklnk) + Dir.chdir(pwd_set) 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' - 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 end @@ -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 @@ -671,12 +705,16 @@ module SiSU_TeX 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) + 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} @@ -715,8 +753,12 @@ module SiSU_TeX @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 \ @@ -901,59 +943,77 @@ module SiSU_TeX 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 \ @@ -965,8 +1025,12 @@ module SiSU_TeX 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 } @@ -977,8 +1041,12 @@ module SiSU_TeX 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/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/ \ -- cgit v1.2.3