From 595970ff23c8474ce7832473a98c1e4d55543c78 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 8 Dec 2011 21:17:27 -0500 Subject: v3: texpdf, codeblocks, use listings package (for grey box) * (internally retain possibility to use boites package) --- lib/sisu/v3/texpdf_format.rb | 125 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 23 deletions(-) (limited to 'lib/sisu/v3/texpdf_format.rb') diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index e65f9729..2e69e3e3 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -179,7 +179,7 @@ module SiSU_TeX_Pdf textwidth=tw.to_i - 20 colW=[] colW << '{' - @dob.widths.each do |x| + @dob.widths.each do |x| x=(x.to_i * textwidth)/100 #x=(x.to_i/100.0 * 160) col_w=x.to_s # x.gsub(/.+/,'l\|') #unless x.nil? colW << "p{#{col_w}mm}" if col_w @@ -555,7 +555,7 @@ module SiSU_TeX_Pdf map_nametags[url][:ocn] else nil end - ocn_lnk=(url=~/^\d+$/ ? url : ocn_lnk) + ocn_lnk=(url=~/^\d+$/ ? url : ocn_lnk) if ocn_lnk and not ocn_lnk.empty? idx \ ? (str.sub!(rgx_url_internal,"\\hyperlink{#{ocn_lnk}}{#{link}}")) @@ -767,6 +767,21 @@ module SiSU_TeX_Pdf @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine @ps=@txt if @txt=~/(?:a4|letter|legal|book|a5|b5)/i @lang ||=SiSU_i18n::Languages.new #.list[@md.opt.lng][:xlp] + @author=if defined? @md.creator.author \ + and @md.creator.author=~/\S+/ + SiSU_TeX_Pdf::Special_characters.new(@md,@md.creator.author).special_characters_safe + else '' + end + @subject=if defined? @md.classify.subject \ + and @md.classify.subject=~/\S+/ + SiSU_TeX_Pdf::Special_characters.new(@md,@md.classify.subject).special_characters_safe + else '' + end + @keywords=if defined? @md.classify.keywords \ + and @md.classify.keywords=~/\S+/ + SiSU_TeX_Pdf::Special_characters.new(@md,@md.classify.keywords).special_characters_safe + else '' + end end def tex_head_lang #babel 18n lang_char_arr=@md.i18n @@ -841,7 +856,7 @@ WOK end end def tex_head_info - generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version] + generator="Generated by: #{@md.sisu_version[:project]} #{@md.sisu_version[:version]} of #{@md.sisu_version[:date_stamp]} (#{@md.sisu_version[:date]})" if @md.sisu_version[:version] lastdone="Last Generated on: #{Time.now}" rubyv="Ruby version: #{@md.ruby_version}" <') + w.gsub!(/[\\]?~/,'~') + w.gsub!(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,"\n") #watch + w.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~') #126 usual + w.gsub!(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + para_array << w + end + str=para_array.join(' ') + str=str.strip unless is=='code' + str + else '' + end + str.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' ') + str.gsub!(/.+?<-#>/,'') + str.gsub!(/#{Mx[:br_eof]}/,'') + str.gsub!(/#{Mx[:br_endnotes]}/,'') + #problem sequence -> + str.gsub!(/&(?:lt|#060);/,'<') # < SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'>') # > SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{') # { SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') # } SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'~') # ~ SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') # # SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') # ! SiSU not really special sisu character but done, also LaTeX + #str.gsub!(/(^|\s)\*\s/,'\1\asterisk ') # * should you wish to escape astrisk e.g. describing \*{bold}* + str.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') # * should you wish to escape astrisk e.g. describing \*{bold}* + str.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') # - SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+') # + SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',') # + SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'&') #unless @txt=~/<:code>/ # / SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') # / SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') # \ SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') # _ SiSU special character also LaTeX + str.gsub!(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') # | SiSU not really special sisu character but done, also LaTeX + str.gsub!(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':') # : SiSU not really special sisu character but done, also LaTeX + str.gsub!(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'^') # ^ SiSU not really special sisu character but done, also LaTeX + ##watch placement, problem sequence ^ + str.gsub!(/&atild;<\/font><\/sup>/,' ') + str.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript + str + end def xetex_special_characters_1(str,is='') # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list #str=Iconv.conv('ISO-8859-1', 'UTF-8', @txt) # `require': iconv will be deprecated in the future, use String#encode instead. word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/ @@ -1326,6 +1400,11 @@ WOK str=xetex_special_characters_2(str,is) unless str.nil? # remove this to start with, causes issues @txt=str end + def characters_code_listings #special characters - some substitutions are sequence sensitive, rearrange with care. + str,is=@txt,@is + str=xetex_code_listings(str,is) unless str.nil? + @txt=str + end def special_characters_code str=@txt str.gsub!(/ \\\\([ #{Mx[:br_nl]}]+|$)/,' \textbackslash\textbackslash\hardspace\1') @@ -1369,7 +1448,7 @@ WOK end def header "\\lhead[ ]{ }\n" + - "\\chead[ \\fancyplain{} \\bfseries \\footnotesize \\leftmark ]{ \\fancyplain{} \\bfseries \\footnotesize \\rightmark }\n" + + "\\chead[ \\fancyplain{} \\bfseries \\footnotesize \\leftmark ]{ \\fancyplain{} \\bfseries \\footnotesize \\rightmark }\n" + "\\rhead[ ]{ }\n" end def footer @@ -1500,13 +1579,13 @@ WOK \"Support Open Standards and Software Libré for the Information Technology Infrastructure\" RA\\subsubsection*{Information on this document copy #{site}} \\addcontentsline{toc}{subsection}{Information on this document copy} {\\begin{footnotesize} -\\\\ Generated by \\href{http://www.jus.uio.no/sisu/}{SiSU} found at \\href{http://www.jus.uio.no/sisu/}{www.jus.uio.no/sisu} \\begin{tiny}[ #{v[:project]} #{v[:version]} #{v[:date_stamp]} ]\\end{tiny} \\href{http://www.sisudoc.org}{www.sisudoc.org}. SiSU is software for document structuring, publishing and search (using SiSU: object citation numbering, markup, meta-markup, and system) Copyright #{@copymark} 1997, current #{@date.year_static} Ralph Amissah, All Rights Reserved. +\\\\ Generated by \\href{http://www.jus.uio.no/sisu/}{SiSU} found at \\href{http://www.jus.uio.no/sisu/}{www.jus.uio.no/sisu} \\begin{tiny}[ #{v[:project]} #{v[:version]} #{v[:date_stamp]} ]\\end{tiny} \\href{http://www.sisudoc.org}{www.sisudoc.org}. SiSU is software for document structuring, publishing and search (using SiSU: object citation numbering, markup, meta-markup, and system) Copyright #{@copymark} 1997, current #{@date.year_static} Ralph Amissah, All Rights Reserved. \\\\ SiSU is released under \\href{http://www.fsf.org/licenses/gpl.html}{GPL 3 } or later (\\href{http://www.fsf.org/licenses/gpl.html}{www.fsf.org/licenses/gpl.html}). {\\end{footnotesize} {\\begin{small} -\\\\ W3 since October 3 1993 \\href{http://www.jus.uio.no/sisu/}{#{sisu_ico}}SiSU 1997, current #{@date.year_static}. \\\\ #{sitename} presentations at \\begin{scriptsize}#{site}\\end{scriptsize} \\\\ \\\\ #{@md.title.full} \\textbf{pdf} versions can be found at: \\\\ +\\\\ W3 since October 3 1993 \\href{http://www.jus.uio.no/sisu/}{#{sisu_ico}}SiSU 1997, current #{@date.year_static}. \\\\ #{sitename} presentations at \\begin{scriptsize}#{site}\\end{scriptsize} \\\\ \\\\ #{@md.title.full} \\textbf{pdf} versions can be found at: \\\\ {\\end{small} -\\\\ #{@brace_url.tex_open}\\begin{scriptsize}\\url{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_p]}}\\end{scriptsize}#{@brace_url.tex_close} \\\\ -#{@brace_url.tex_open}\\begin{scriptsize}\\url{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_l]}}\\end{scriptsize}#{@brace_url.tex_close} \\\\ +\\\\ #{@brace_url.tex_open}\\begin{scriptsize}\\url{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_p]}}\\end{scriptsize}#{@brace_url.tex_close} \\\\ +#{@brace_url.tex_open}\\begin{scriptsize}\\url{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_l]}}\\end{scriptsize}#{@brace_url.tex_close} \\\\ \\\\\n#{@md.title.full} \\textbf{html} versions may be found at: \\\\ #{@brace_url.tex_open}\\begin{scriptsize}\\url{#{@vz.url_root_http}/#{url}/#{@md.fn[:toc]}}\\end{scriptsize}#{@brace_url.tex_close} or \\\\ #{@brace_url.tex_open}\\begin{scriptsize}\\url{#{@vz.url_root_http}/#{url}/#{@md.fn[:doc]}}\\end{scriptsize}#{@brace_url.tex_close} -- cgit v1.2.3