aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2011-12-08 21:17:27 -0500
committerRalph Amissah <ralph@amissah.com>2011-12-08 21:17:36 -0500
commit595970ff23c8474ce7832473a98c1e4d55543c78 (patch)
tree5c5b49efe687585f83d073606c39ca247c2a0bb4 /lib
parentv3: epub, css, codeblock, grey box (diff)
v3: texpdf, codeblocks, use listings package (for grey box)
* (internally retain possibility to use boites package)
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v3/texpdf.rb196
-rw-r--r--lib/sisu/v3/texpdf_format.rb125
2 files changed, 244 insertions, 77 deletions
diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb
index d36344cd..2b9e1087 100644
--- a/lib/sisu/v3/texpdf.rb
+++ b/lib/sisu/v3/texpdf.rb
@@ -294,6 +294,7 @@ module SiSU_TeX
true
else false
end
+ @codeblock_box='listings' #alternative 'boites'
end
def songsheet
begin
@@ -352,7 +353,11 @@ module SiSU_TeX
dob.tmp=SiSU_TeX_Pdf::Format_text_object.new(@md,dob.tmp).url_str_internal(dob.tmp)
end
elsif dob.is =='code'
- dob.tmp=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp).special_characters_code
+ dob.tmp=if @codeblock_box=='listings'
+ dob.tmp
+ else
+ SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp).special_characters_code
+ end
elsif dob.is =='break'
if dob.obj==Mx[:br_page]; dob.tmp='\newpage'
elsif dob.obj==Mx[:br_page_new]; dob.tmp='\clearpage'
@@ -408,6 +413,53 @@ module SiSU_TeX
def enclose(dob)
dob
end
+ def box_boites(dob,ocn)
+ sp_char=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp,dob.is)
+ dob.tmp=sp_char.special_characters_safe
+ dob.tmp.gsub!(/(#{Mx[:nbsp]})/m,'{\color{mywhite}\1}')
+ #dob.tmp.gsub!(/#{Mx[:nbsp]}/m,'{~}') # dob.tmp.gsub!(/#{Mx[:nbsp]}\s*/m,'{~}')
+ dob.tmp.gsub!(/#{Mx[:vline]}/m,'\vline')
+ dob.tmp.gsub!(/ \\( |#{Mx[:br_nl]})/,' {\textbackslash}\1')
+ dob.tmp.gsub!(/#{Mx[:br_nl]}\s*\Z/m,'')
+ dob.tmp.gsub!(/#{Mx[:br_nl]}{2}/,'\newline \\\\\\ ')
+ dob.tmp.gsub!(/#{Mx[:br_nl]}/,' \\\\\\ ')
+ dob.tmp.gsub!(/\n\n\n/m," \\newline\n\n")
+ ocn=SiSU_TeX_Pdf::Format_text_object.new(@md).ocn_display(dob)
+ dob.tmp = ocn \
+ + @tex_ml.paraskip_small \
+ + '\begin{Codeblock}' \
+ + '\begin{codeblockboitebox} \hardspace \newline ' \
+ + dob.tmp \
+ + '\end{codeblockboitebox}' \
+ + '\end{Codeblock}' \
+ + "\n" \
+ + @tex_ml.paraskip_normal
+ dob
+ end
+ def box_listings(dob,ocn)
+ sp_char=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp,dob.is)
+ dob.tmp=sp_char.characters_code_listings
+ dob.tmp.gsub!(/^\s+/m,'') #bug, fix earlier, should be made unecessary
+ dob.tmp.gsub!(/#{Mx[:nbsp]}/m,' ')
+ dob.tmp.gsub!(/#{Mx[:vline]}/m,'|')
+ dob.tmp.gsub!(/#{Mx[:br_nl]}(?:\s?\n)?/m,"\n")
+ dob.tmp.gsub!(/\n\n\n/m," \n\n")
+ ocn=SiSU_TeX_Pdf::Format_text_object.new(@md).ocn_display(dob)
+ dob.tmp = ocn \
+ + @tex_ml.paraskip_small \
+ + '\begin{Codeblock}' \
+ + "\n" \
+ + '\begin{lstlisting} ' \
+ + "\n" \
+ + dob.tmp \
+ + "\n" \
+ + '\end{lstlisting} ' \
+ + "\n" \
+ + '\end{Codeblock}' \
+ + "\n" \
+ + @tex_ml.paraskip_normal
+ dob
+ end
def markup_common(dob)
tex_f=nil
txt_obj={ dal: dob }
@@ -430,7 +482,7 @@ module SiSU_TeX
+ '\\end{footnotesize}' \
+ "\n" \
+ @tex_ml.paraskip_normal
- elsif dob.is=~/verse/
+ elsif dob.is=~/verse/
ocn \
+ @tex_ml.paraskip_tiny \
+ "\n" \
@@ -444,26 +496,13 @@ module SiSU_TeX
end
dob
when /code/
- sp_char=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp,dob.is)
- dob.tmp=sp_char.special_characters_safe
- dob.tmp.gsub!(/(#{Mx[:nbsp]})/m,'{\color{mywhite}\1}')
- #dob.tmp.gsub!(/#{Mx[:nbsp]}/m,'{~}') # dob.tmp.gsub!(/#{Mx[:nbsp]}\s*/m,'{~}')
- dob.tmp.gsub!(/#{Mx[:vline]}/m,'\vline')
- dob.tmp.gsub!(/ \\( |#{Mx[:br_nl]})/,' {\textbackslash}\1')
- dob.tmp.gsub!(/#{Mx[:br_nl]}\s*\Z/m,'')
- dob.tmp.gsub!(/#{Mx[:br_nl]}{2}/,'\newline \\\\\\ ')
- dob.tmp.gsub!(/#{Mx[:br_nl]}/,' \\\\\\ ')
- dob.tmp.gsub!(/\n\n\n/m," \\newline\n\n")
- ocn=SiSU_TeX_Pdf::Format_text_object.new(@md).ocn_display(dob)
- dob.tmp = ocn \
- + @tex_ml.paraskip_small \
- + '\begin{Codeblock}' \
- + '\begin{codeblockboitebox} \hardspace \newline ' \
- + dob.tmp \
- + '\end{codeblockboitebox}' \
- + '\end{Codeblock}' \
- + "\n" \
- + @tex_ml.paraskip_normal
+ dob=if @codeblock_box == 'listings'
+ box_listings(dob,ocn)
+ elsif @codeblock_box == 'boites'
+ box_boites(dob,ocn)
+ else
+ box_boites(dob,ocn)
+ end
dob
else 'error' #should never occur
end
@@ -533,7 +572,7 @@ module SiSU_TeX
dob=enclose(dob) unless dob.tmp =~/^$/
end
else
- dob.tmp.strip!
+ dob.tmp.strip! unless dob.is=='code'
dob=enclose(dob) unless dob.tmp =~/^$/
end
if dob.class==String
@@ -543,22 +582,83 @@ module SiSU_TeX
dob
end
if dob.tmp =~/(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image\b)/m \
- and dob.is !='code'
+ && dob.is !='code'
dob=SiSU_TeX_Pdf::Bare_urls.new(@md,dob).bare_urls
tst=SiSU_TeX_Pdf::Format_text_object.new(@md,dob)
dob=tst.urls_txt_and_images
dob
elsif dob.tmp =~/https?:\/\/\S+\b/m \
- and dob.is =='code'
+ && dob.is =='code' \
+ && @codeblock_box !='listings'
dob=SiSU_TeX_Pdf::Bare_urls.new(@md,dob).bare_urls_in_code
dob
end
- if dob.class !=Hash and dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\b/ \
- and dob.is !='code'
+ if dob.class !=Hash \
+ && dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\b/ \
+ && dob.is !='code'
tst=SiSU_TeX_Pdf::Format_text_object.new(@md,dob)
end
dob
end
+ def tex_box_listings
+ <<WOK
+\\definecolor{listinggray}{gray}{0.9}
+\\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
+\\lstset{
+ backgroundcolor=\\color{lbcolor},
+ tabsize=4,
+ rulecolor=,
+ language=,
+ basicstyle=\\scriptsize,
+ upquote=true,
+ aboveskip={1.5\\baselineskip},
+ columns=fixed,
+ showstringspaces=false,
+ extendedchars=true,
+ breaklines=true,
+ prebreak = \\raisebox{0ex}[0ex][0ex]{\\ensuremath{\\hookleftarrow}},
+ frame=single,
+ showtabs=false,
+ showspaces=false,
+ showstringspaces=false,
+ identifierstyle=\\ttfamily,
+ keywordstyle=\\color[rgb]{0,0,1},
+ commentstyle=\\color[rgb]{0.133,0.545,0.133},
+ stringstyle=\\color[rgb]{0.627,0.126,0.941},
+}
+WOK
+ end
+ def tex_box_boites
+ <<WOK
+\\def\\codeblockboitebox{%
+ \\def\\bkvz@before@breakbox{\\ifhmode\\par\\fi\\vskip\\breakboxskip\\relax}%
+ \\def\\bkvz@set@linewidth{\\advance\\linewidth -2\\fboxrule
+ \\advance\\linewidth -2\\fboxsep} %
+ \\def\\bk@line{\\hbox to \\linewidth{%
+ \\ifbkcount\\smash{\\llap{\\the\\bk@lcnt\\ }}\\fi
+ \\psframebox*[framesep=0pt,linewidth=0pt]{%
+ \\vrule\\@width\\fboxrule \\hskip\\fboxsep
+ \\box\\bk@bxa
+ \\hskip\\fboxsep \\vrule\\@width\\fboxrule
+ }%
+ }}%
+ %\\def\\bkvz@top{\\hrule\\@height\\fboxrule}
+ \\def\\bkvz@top{\\hrule height .6pt}%
+ \\def\\bkvz@bottom{\\hrule\\@height\\fboxrule}%
+ \\breakbox}
+\\def\\endcodeblockboitebox{\\endbreakbox}
+WOK
+ end
+ def tex_codeblock
+ codeblock_box=if @codeblock_box=='listings'
+ tex_box_listings
+ elsif @codeblock_box=='boites'
+ tex_box_boites
+ else
+ tex_box_boites
+ end
+ codeblock_box
+ end
def markup(data)
@tex_file=[]
md={}
@@ -569,8 +669,8 @@ module SiSU_TeX
orient_portrait=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj)
txt_obj={ txt: "#{home}: - #{title}", paper_size: ps, orientation: 'landscape' }
orient_landscape=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj)
- @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation
- @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation
+ @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation(@codeblock_box)
+ @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation(@codeblock_box)
end
@tex_file <<<<WOK
#{@tex_ml.header}#{@tex_ml.footer}
@@ -598,24 +698,7 @@ module SiSU_TeX
\\newcommand{\\slash}{{/}}
\\newcommand{\\underscore}{\\_}
\\newcommand{\\exclaim}{\\Verbatim{!}}
-\\def\\codeblockboitebox{%
- \\def\\bkvz@before@breakbox{\\ifhmode\\par\\fi\\vskip\\breakboxskip\\relax}%
- \\def\\bkvz@set@linewidth{\\advance\\linewidth -2\\fboxrule
- \\advance\\linewidth -2\\fboxsep} %
- \\def\\bk@line{\\hbox to \\linewidth{%
- \\ifbkcount\\smash{\\llap{\\the\\bk@lcnt\\ }}\\fi
- \\psframebox*[framesep=0pt,linewidth=0pt]{%
- \\vrule\\@width\\fboxrule \\hskip\\fboxsep
- \\box\\bk@bxa
- \\hskip\\fboxsep \\vrule\\@width\\fboxrule
- }%
- }}%
- %\\def\\bkvz@top{\\hrule\\@height\\fboxrule}
- \\def\\bkvz@top{\\hrule height .6pt}%
- \\def\\bkvz@bottom{\\hrule\\@height\\fboxrule}%
- \\breakbox}
-\\def\\endcodeblockboitebox{\\endbreakbox}
-
+#{tex_codeblock}
% (tilde hash amp affected by http)
% \\sloppy
\\begin{document}
@@ -789,8 +872,10 @@ WOK
ps,h,fn=o[:ps],o[:h],o[:filename]
if h[ps] \
and (h[ps][:p] and h[ps][:l])
- h[ps][:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:p]
- h[ps][:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:l]
+ h[ps][:p].gsub!(/[ ]+$/m,'') if h[ps][:p]
+ h[ps][:l].gsub!(/[ ]+$/m,'') if h[ps][:l]
+ #h[ps][:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:p]
+ #h[ps][:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[ps][:l]
h[ps][:p].gsub!(/\n\n\n+/m,"\n\n") if h[ps][:p]
h[ps][:l].gsub!(/\n\n\n+/m,"\n\n") if h[ps][:l]
if h[ps][:p] !~/\A\s*\Z/
@@ -800,8 +885,10 @@ WOK
fn[:landscape].puts h[ps][:l],"\n"
end
elsif (h[:p] and h[:l])
- h[:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:p]
- h[:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:l]
+ h[:p].gsub!(/[ ]+$/m,'') if h[:p]
+ h[:l].gsub!(/[ ]+$/m,'') if h[:l]
+ #h[:p].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:p]
+ #h[:l].gsub!(/(?:^[ ]+|[ ]+$)/m,'') if h[:l]
h[:p].gsub!(/\n\n\n+/m,"\n\n") if h[:p]
h[:l].gsub!(/\n\n\n+/m,"\n\n") if h[:l]
if h[:p] !~/\A\s*\Z/
@@ -827,7 +914,7 @@ WOK
file[:landscape] << @@tex_head[ps][:l]
array.each do |morph|
if morph.class==String
- morph.gsub!(/^\s+/,'')
+ #morph.gsub!(/^\s+/,'')
if morph !~/\A\s*\Z/
file[:portrait].puts morph,"\n"
file[:landscape].puts morph,"\n"
@@ -835,9 +922,10 @@ WOK
elsif morph.class.inspect =~ /SiSU_document_structure/ \
and morph.tmp \
and morph.tmp.class==String
- unless morph.of=='block'
+ if morph.is !='code' \
+ && morph.of !='block'
morph.tmp.gsub!(/^\s+/,'')
- else morph.tmp.gsub!(/^ +/,'')
+ else morph.tmp
end
if morph.tmp !~/\A\s*\Z/ \
or morph.is=='code'
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}