aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/texpdf_format.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/texpdf_format.rb')
-rw-r--r--lib/sisu/v3/texpdf_format.rb125
1 files changed, 102 insertions, 23 deletions
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}"
<<WOK
@@ -858,9 +873,9 @@ WOK
<<WOK
#{tex_head_info}
\\documentclass[#{d[:fontsize]},#{d[:papertype]},titlepage]{scrartcl} %with titlepage
-\\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm}
-\\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}} \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}
-\\setlength{\\topmargin}{#{d[:topmargin]}} \\setlength{\\headheight}{#{d[:headheight]}}
+\\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm}
+\\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}} \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}
+\\setlength{\\topmargin}{#{d[:topmargin]}} \\setlength{\\headheight}{#{d[:headheight]}}
\\setlength{\\headsep}{#{d[:headsep]}}
\\setlength{\\marginparsep}{#{d[:marginparsep]}}
\\setlength{\\marginparwidth}{#{d[:marginparwidth]}}
@@ -871,9 +886,9 @@ WOK
<<WOK
#{tex_head_info}
\\documentclass[#{d[:fontsize]},#{d[:papertype]},landscape,titlepage,twocolumn]{scrartcl} %with titlepage
-\\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm}
-\\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}} \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}
-\\setlength{\\topmargin}{#{d[:topmargin]}} \\setlength{\\headheight}{#{d[:headheight]}}
+\\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm}
+\\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}} \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}
+\\setlength{\\topmargin}{#{d[:topmargin]}} \\setlength{\\headheight}{#{d[:headheight]}}
\\setlength{\\headsep}{#{d[:headsep]}}
\\setlength{\\columnsep}{#{d[:columnsep]}}
\\setlength{\\marginparsep}{#{d[:marginparsep]}}
@@ -884,9 +899,9 @@ WOK
<<WOK
#{tex_head_info}
\\documentclass[#{d[:fontsize]},#{d[:papertype]},titlepage]{scrartcl} %with titlepage
-\\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm}
-\\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}} \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}
-\\setlength{\\topmargin}{#{d[:topmargin]}} \\setlength{\\headheight}{#{d[:headheight]}}
+\\setlength{\\textheight}{#{d[:textheight]}mm} \\setlength{\\textwidth}{#{d[:textwidth]}mm}
+\\setlength{\\oddsidemargin}{#{d[:oddsidemargin]}} \\setlength{\\evensidemargin}{#{d[:evensidemargin]}}
+\\setlength{\\topmargin}{#{d[:topmargin]}} \\setlength{\\headheight}{#{d[:headheight]}}
\\setlength{\\headsep}{#{d[:headsep]}}
\\setlength{\\marginparsep}{#{d[:marginparsep]}}
\\setlength{\\marginparwidth}{#{d[:marginparwidth]}}
@@ -985,10 +1000,9 @@ WOK
\\usepackage[#{@tex2pdf},
#{color.strip}
pdftitle={#{@txt}},
-% pdftitle={Untitled},
- pdfauthor={LM-sisu-scribe},
- pdfsubject={law},
- pdfkeywords={law},
+ pdfauthor={#{@author}},
+ pdfsubject={#{@subject}},
+ pdfkeywords={#{@keywords}},
pageanchor=true,
plainpages=true,
pdfpagelabels=true,
@@ -1043,12 +1057,25 @@ WOK
WOK
end
end
+ def tex_head_codeblock(codeblock_box_type)
+ codeblock_box=if codeblock_box_type=='listings'
+ <<WOK
+\\usepackage{listings}
+\\usepackage{color}
+\\usepackage{textcomp}
+WOK
+ elsif codeblock_box_type=='boites'
+ "\\usepackage{boites}"
+ else
+ "\\usepackage{boites}"
+ end
+ codeblock_box
+ end
def tex_head_misc
<<WOK
\\usepackage{textcomp}
\\usepackage[parfill]{parskip}
\\usepackage[normalem]{ulem}
-\\usepackage{boites}
\\usepackage{soul}
\\usepackage{longtable}
\\usepackage{graphicx}
@@ -1059,7 +1086,7 @@ WOK
% amssymb used for backslash
WOK
end
- def document_head_with_orientation
+ def document_head_with_orientation(codeblock_box_type)
endnotes=("\\usepackage{endnotes}" if @txt =~/endnotes?/)||'' #not implemented see also def endnotes
@lang.list[@md.i18n[0]][:xlp]
<<WOK
@@ -1067,6 +1094,7 @@ WOK
#{tex_head_encode}
#{tex_head_pdftex_dvi}
#{tex_head_misc}
+#{tex_head_codeblock(codeblock_box_type)}
\\setcounter{secnumdepth}{2}
\\setcounter{tocdepth}{4}
\\makeatletter
@@ -1149,6 +1177,52 @@ WOK
@brace_url=SiSU_Viz::Skin.new.url_decoration
@tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine
end
+ def xetex_code_listings(str,is='') # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list
+ word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/
+ para_array=[]
+ str=if word
+ word.each do |w| # _ - / # | : ! ^ ~
+ w.gsub!(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<'); w.gsub!(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>')
+ 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!(/<sup><font face=symbol>&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}