aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-05-12 22:43:02 -0400
committerRalph Amissah <ralph@amissah.com>2014-05-12 22:43:02 -0400
commit9d76329a6203dbb2b48b926d764b3429ac04ea5c (patch)
tree0d0cfaf0af56bdc688a38bd43e06110e0d90dcb8 /lib
parentv6: texpdf, pdf default font size configurable (cli & sisurc.yml) (no fractions) (diff)
v6: texpdf, pdf colored hyperlinks configurable
* --pdf-hyperlinks-color --pdf-hyperlinks-no-color or --pdf-hyperlinks-monochrome * ['default']['pdf_hyperlinks']='color' (other options switch hyperlink color off 'no-color' 'color-off' 'monochrome') * (Closes: #744391) no color on a4 portrait see discussion in sisu.org
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v6/options.rb6
-rw-r--r--lib/sisu/v6/sysenv.rb42
-rw-r--r--lib/sisu/v6/texpdf_format.rb66
3 files changed, 80 insertions, 34 deletions
diff --git a/lib/sisu/v6/options.rb b/lib/sisu/v6/options.rb
index 462d9166..d7719ea4 100644
--- a/lib/sisu/v6/options.rb
+++ b/lib/sisu/v6/options.rb
@@ -972,6 +972,12 @@ module SiSU_Commandline
$1
else :na
end
+ act[:pdf_hyperlink_colors]=if mod.inspect =~/"--pdf-hyperlinks-(?:mono(?:chrome)?|no-color)"/
+ :mono
+ elsif mod.inspect =~/"--pdf-hyperlinks-color"/
+ :color
+ else :na
+ end
act[:hash_digest_algo]=if mod.inspect =~/"--hash-(?:sha)?512"/
:sha512
elsif mod.inspect =~/"--hash-(?:sha)?256"/
diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb
index 6136d248..8c819d9b 100644
--- a/lib/sisu/v6/sysenv.rb
+++ b/lib/sisu/v6/sysenv.rb
@@ -1874,6 +1874,48 @@ WOK
file=@fns.gsub(/\.ssm(?:\.sst)?/,'.ssm.sst')
"#{source_file_path}/#{file}"
end
+ def texpdf_hyperlinks(cli)
+ @cli=cli
+ @hyplnks=if cli != :na
+ cli
+ elsif (defined? @rc['default']['pdf_hyperlinks']) \
+ && (@rc['default']['pdf_hyperlinks']=~/color/)
+ :color
+ elsif (defined? @rc['default']['pdf_hyperlinks']) \
+ && (@rc['default']['pdf_hyperlinks']=~/(?:no-color|color-off|mono(?:chrome)?)/)
+ :mono
+ else :na
+ end
+ def landscape
+ if @cli != :na
+ @cli
+ elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \
+ && (@rc['default']['pdf_hyperlinks_landscape']=~/color/)
+ :color
+ elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \
+ && (@rc['default']['pdf_hyperlinks_landscape']=~/(?:no-color|color-off|mono(?:chrome)?)/)
+ :mono
+ elsif @hyplnks != :na
+ @hyplnks
+ else :na
+ end
+ end
+ def portrait
+ if @cli != :na
+ @cli
+ elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \
+ && (@rc['default']['pdf_hyperlinks_portrait']=~/color/)
+ :color
+ elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \
+ && (@rc['default']['pdf_hyperlinks_portrait']=~/(?:no-color|color-off|mono(?:chrome)?)/)
+ :mono
+ elsif @hyplnks != :na
+ @hyprlnks
+ else :na
+ end
+ end
+ self
+ end
def font
def size(pt=nil)
if pt && pt != :na
diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb
index 56bb1c0b..47829581 100644
--- a/lib/sisu/v6/texpdf_format.rb
+++ b/lib/sisu/v6/texpdf_format.rb
@@ -1009,30 +1009,50 @@ module SiSU_TeX_Pdf
tex_head_paper_landscape(tex_head_paper_dimensions)
end
end
- def tex_head_pdftex_dvi
- color=case @layout
- when :portrait
+ def hyperlinks_monochrome
<<-WOK
colorlinks=true,
urlcolor=myblack,
filecolor=myblack,
linkcolor=myblack,
- WOK
- when :landscape
+ WOK
+ end
+ def hyperlinks_colored
<<-WOK
colorlinks=true,
urlcolor=myblue, % \\href{...}{...} external url
- filecolor=mygreen, % \\href{...} local file
+ filecolor=mygreen, % \\href{...} local file
linkcolor=myred, % \\href{...} and \\pageref{...}
- WOK
+ WOK
+ end
+ def hyperlinks_color?
+ case @layout
+ when :portrait then hyperlinks_monochrome
+ if @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).portrait != :na
+ case @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).portrait
+ when :color then hyperlinks_colored
+ when :mono then hyperlinks_monochrome
+ else p __LINE__.to_s + ':error'
+ end
+ else hyperlinks_monochrome
+ end
+ when :landscape
+ if @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).landscape != :na
+ case @env.texpdf_hyperlinks(@md.opt.act[:pdf_hyperlink_colors]).landscape
+ when :color then hyperlinks_colored
+ when :mono then hyperlinks_monochrome
+ else p __LINE__.to_s + ':error'
+ end
+ else hyperlinks_colored
+ end
end
- if @layout == :portrait \
- or @layout == :landscape
- <<-WOK
+ end
+ def tex_head_pdftex
+ <<-WOK
\\usepackage{alltt}
\\usepackage{thumbpdf}
\\usepackage[#{@tex2pdf},
- #{color.strip}
+ #{hyperlinks_color?.strip}
pdftitle={#{@txt}},
pdfauthor={#{@author}},
pdfsubject={#{@subject}},
@@ -1068,28 +1088,6 @@ module SiSU_TeX_Pdf
\\usepackage{url}
%\\usepackage{breakurl}
WOK
- elsif @txt =~/dvi/
- <<-WOK
-\\usepackage{alltt}
- #{color.strip}
- pageanchor=true,
- plainpages=true,
- pagebackref,
- bookmarks=true,
- bookmarksopen=true,
- plainpages=false,
-]
-{hyperref}
-\\usepackage[usenames]{color}
-\\definecolor{myblack}{rgb}{0,0,0}
-\\definecolor{myred}{rgb}{0.75,0,0}
-\\definecolor{mygreen}{rgb}{0,0.5,0}
-\\definecolor{myblue}{rgb}{0,0,0.5}
-\\definecolor{mywhite}{rgb}{1,1,1}
-\\usepackage{url}
-%\\usepackage{breakurl}
- WOK
- end
end
def tex_head_codeblock(codeblock_box_type)
codeblock_box=if codeblock_box_type=='listings'
@@ -1127,7 +1125,7 @@ module SiSU_TeX_Pdf
<<-WOK
#{tex_head_paper}
#{tex_head_encode}
-#{tex_head_pdftex_dvi}
+#{tex_head_pdftex}
#{tex_head_misc}
#{tex_head_codeblock(codeblock_box_type)}
\\setcounter{secnumdepth}{2}