aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-02-06 23:10:58 -0500
committerRalph Amissah <ralph@amissah.com>2013-02-06 23:10:58 -0500
commitbf57f03babb2375adc9a225f4d95799c37d81d55 (patch)
treeb75758b3acd905abea582cc47513704d50484809 /lib
parentv4: pdf (texpdf, options, hub, urls) orientation discrete, individually callable (diff)
v4: options, param, pdf papersize, command-line options to override sisurc
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v4/options.rb57
-rw-r--r--lib/sisu/v4/param.rb26
2 files changed, 67 insertions, 16 deletions
diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb
index fca60a3d..8f07e0c4 100644
--- a/lib/sisu/v4/options.rb
+++ b/lib/sisu/v4/options.rb
@@ -476,8 +476,14 @@ module SiSU_Commandline
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'
+ mod << m
when /^--pdf-(?:p|l|portrait|landscape)$/; c=c+'L'
mod << m
+ when /^--pdf-(?:p(?:ortrait)?|l(?:andscape)?)-(?:a4|letter|a5|b5|legal)$/; c=c+'L'
+ mod << m
+ when /^--pdf-(?:a4|letter|a5|b5|legal)-(?:p(?:ortrait)?|l(?:andscape)?)$/; c=c+'L'
+ mod << m
when /^--(?:concordance|wordmap)$/; c=c+'w'
when /^--(?:manpage|man)$/; c=c+'i'
when /^--(?:texinfo)$/; c=c+'I'
@@ -783,7 +789,7 @@ module SiSU_Commandline
? { bool: true, set: :on }
: { bool: false, set: :na }
act[:pdf]=if (cmd =~/p/ \
- || mod.inspect =~/"--pdf"/)
+ || mod.inspect =~/"--pdf"|"--pdf-(?:a4|a5|b5|letter|legal)"/)
if mod.inspect =~/"--portrait"/
act[:pdf_p]={ bool: true, set: :on }
act[:pdf_l]={ bool: false, set: :na }
@@ -799,13 +805,62 @@ module SiSU_Commandline
end
else
act[:pdf_p]=(mod.inspect =~/"--pdf-(?:p|portrait)"/) \
+ || (mod.inspect =~/"--pdf(?:-p(?:ortrait)?-(?:a4|a5|b5|letter|legal))"/) \
+ || (mod.inspect =~/"--pdf-(?:a4|a5|b5|letter|legal)(?:-p(?:ortrait)?)"/) \
? { bool: true, set: :on }
: { bool: false, set: :na }
act[:pdf_l]=(mod.inspect =~/"--pdf-(?:l|landscape)"/) \
+ || (mod.inspect =~/"--pdf(?:-l(?:andscape)?-(?:a4|a5|b5|letter|legal))"/) \
+ || (mod.inspect =~/"--pdf-(?:a4|a5|b5|letter|legal)(?:-l(?:andscape)?)"/) \
? { bool: true, set: :on }
: { bool: false, set: :na }
{ bool: false, set: :na }
end
+ if act[:pdf][:set]==:on \
+ or act[:pdf_p][:set]==:on \
+ or act[:pdf_l][:set]==:on
+ #mod.inspect =~/"--pdf-([pl]-|portrait-|landscape-)?(?:a4|a5|b5|letter|legal)"/
+ act[:pdf_a4]=if mod.inspect =~/"--pdf(?:-[pl]|-portrait|-landscape)?-a4"/ \
+ or mod.inspect =~/"--pdf-a4(?:-[pl]|-portrait|-landscape)?"/ \
+ or 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 =~/"--pdf(?:-[pl]|-portrait|-landscape)?-a5"/ \
+ or mod.inspect =~/"--pdf-a5(?:-[pl]|-portrait|-landscape)?"/ \
+ or 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 =~/"--pdf(-[pl]|-portrait|-landscape)?-b5"/ \
+ or mod.inspect =~/"--pdf-b5(?:-[pl]|-portrait|-landscape)?"/ \
+ or 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 =~/"--pdf(-[pl]|-portrait|-landscape)?-letter"/ \
+ or mod.inspect =~/"--pdf-letter(?:-[pl]|-portrait|-landscape)?"/ \
+ or 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 =~/"--pdf(-[pl]|-portrait|-landscape)?-legal"/ \
+ or mod.inspect =~/"--pdf-legal(?:-[pl]|-portrait|-landscape)?"/ \
+ or 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