From a9d166c65f9d56b1d4de20fbdfae6e940681c535 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 17 Dec 2007 00:07:08 +0000 Subject: texpdf, generate sisu latex output in a single pass implications if additional modules added e.g. provide dvi file without latex pdf headers or generate an A6 document by default for e-readers capable of reading pdf (this would otherwise require a separate pass/loop of content for each type to be generated) current shortcoming, images are sized for smaller landscape output by default, image dimension adjustments not yet made (for different orientation) --- lib/sisu/v0/texpdf_format.rb | 95 +++++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 32 deletions(-) (limited to 'lib/sisu/v0/texpdf_format.rb') 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 < 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 =~//," #@end_table\n\\end{tiny}") end @string.gsub!(//,1] @string.gsub!(/\/,'') @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 =~//," #@end_table\n\\end{tiny}") end @string.gsub!(//,1] @string.gsub!(/\/,'') @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] @@ -998,6 +995,18 @@ WOK \\setlength{\\columnsep}{#{d[:columnsep]}} \\setlength{\\marginparsep}{#{d[:marginparsep]}} \\setlength{\\marginparwidth}{#{d[:marginparwidth]}} +WOK + end + def tex_head_paper_portrait_dvi(d) + <