From 9d76329a6203dbb2b48b926d764b3429ac04ea5c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 22:43:02 -0400 Subject: 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 --- data/doc/sisu/CHANGELOG_v6 | 8 ++++++ lib/sisu/v6/options.rb | 6 ++++ lib/sisu/v6/sysenv.rb | 42 ++++++++++++++++++++++++++++ lib/sisu/v6/texpdf_format.rb | 66 +++++++++++++++++++++----------------------- sisu.org | 29 ++++++++++++++++++- 5 files changed, 116 insertions(+), 35 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 969ceb7e..c75ad615 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -55,6 +55,14 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.5.orig.tar.xz * use symbols to identify page orientation * renaming related to fontface +* texpdf, pdf colored hyperlinks configurable (cli & sisurc.yml) + --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 │ + * texpdf, headings and table of contents * texpdf, pdf default font size configurable (cli & sisurc.yml) (no fractions) 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} diff --git a/sisu.org b/sisu.org index 4db30823..426ad58a 100644 --- a/sisu.org +++ b/sisu.org @@ -1594,7 +1594,7 @@ if you have the following sisu syntax: then anything (including and) after ':B~ bar' is ignored entirely. -**** TODO [#C] #744391 [w|u] sisu output: no color on a4 portrait +**** DONE (6.0.5) [#C] #744391 [w|u] sisu output: no color on a4 portrait :output:pdf:contemplate: From: Daniel Baumann @@ -1627,6 +1627,33 @@ pdf does indeed have colors (red for toc, blue for links). Regards, Daniel +***** NOTES/COMMENTS + +background: +portrait was provided for print/paper copy and is great for that in monochrome +(without grays for colored links), +landscape better matching a screen for visual presentations, color affecting the landscape only + +solution: +make configurable by cli & rc file +make both (portrait & landscape colors) configurable +either as hyperlinks monochrome or colored +overriding existing default which remains as described + +document +cli: +--pdf-hyperlinks-no-color or --pdf-hyperlinks-mono +--pdf-hyperlinks-color + +rc: + +default: + pdf_hyperlinks: *[possible values] + pdf_hyperlinks_portrait: *[possible values] + pdf_hyperlinks_landscape: *[possible values] + + * 'color' or ('mono' or 'no-color' or 'color-off') + **** TODO [#D] #744395 [w|u] sisu output: half-page title page in landscape output -- cgit v1.2.3