diff options
Diffstat (limited to 'lib/sisu/v0/texpdf_format.rb')
-rw-r--r-- | lib/sisu/v0/texpdf_format.rb | 1432 |
1 files changed, 737 insertions, 695 deletions
diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index ee457ca3..0fa439f0 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -61,215 +61,22 @@ module SiSU_TeX_Pdf @@table_pg_break_counter=1 include SiSU_Viz - class Use_TeX - attr_accessor :url,:txt,:date - def initialize(md) - @md=md - @vz=SiSU_Env::Get_init.instance.skin - @date=SiSU_Env::Info_date.new # #{@date.year} - @copymark='{\\begin{footnotesize}\\raisebox{1ex}{\\copyright}\\end{footnotesize}}' - @url_brace=SiSU_Viz::Skin.new.url_decoration - end - def skip - "\n\\vspace*{\\smallskipamount} \n" - end - def paraskip_normal - '\setlength{\parskip}{1ex plus0.5ex minus0.2ex}' - end - def paraskip_small - '\setlength{\parskip}{0.5ex plus0.2ex minus0.1ex}' - end - def skip_small - #"\\smallskip{}" - end - def skip_small_vspace - "\n\\vspace*{\\smallskipamount} \n" - end - def skip_small_footnote - #"\n\\smallskip{}\n" - end - def skip_medium - "\n\\medskip{}\n\n" - end - def skip_dummy - "\n" - end - def header - "\\lhead[ ]{ }\n" + - "\\chead[ \\fancyplain{} \\bfseries \\footnotesize \\leftmark ]{ \\fancyplain{} \\bfseries \\footnotesize \\rightmark }\n" + - "\\rhead[ ]{ }\n" - end - def footer - base_prog_txt=if @md.base_program - case @md.base_program - when /kdissert/i; " \\\\ \\href{http://freehackers.org/~tnagy/kdissert/}{Kdissert}" - else '' - end - else '' - end - "\\lfoot[\\textrm{\\thepage}]{\\tiny \\href{#{@vz.url_sisu}}{#{@vz.txt_signature}}#{base_prog_txt}}\n" + - "\\cfoot[\\href{#{@vz.url_home}}{#{@vz.url_txt}}]{\\href{#{@vz.url_home}}{#{@vz.url_txt}}}\n" + - "\\rfoot[\\tiny \\href{#{@vz.url_sisu}}{#{@vz.txt_signature}}]{\\textrm{\\thepage}}\n" - end - def site - "\\href{#{@vz.url_home}}{#{@vz.url_txt}}" - end - def sitename #owners site, eg freeculture, free.for.all, gutenberg etc. - "\\href{#{@vz.url_home}}{#{@vz.txt_home}}" - end - def owner_chapter - "Contact Details for Original Promulgating Authority" - end - #BOOK standard dimensions - 229x156 - def newpage(orientation) - case orientation - when /landscape/ # using longtable latex package -<<WOK -\\clearpage -WOK - when /portrait/ -<<WOK -\\newpage -WOK - end - end - def sisu_rights - v=SiSU_Env::Info_version.new.get_version - base_prog_txt=if @md.base_program - case @md.base_program - when /kdissert/i; "\n\\\\ This document prepared using \\href{http://freehackers.org/~tnagy/kdissert/}{Kdissert \\ http://freehackers.org/~tnagy/kdissert/ } \\\\ Kdissert is Document Mapping software by Thomas Nagy" - else '' - end - else '' - end -<<WOK -\\\\ ~ -{\\begin{footnotesize}#{base_prog_txt} -\\\\ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\begin{tiny}[ #{v[:project]} #{v[:version]} of #{v[:date_stamp]} ]\\end{tiny} \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu} -\\\\ Copyright #@copymark 1997, current #{@date.year_static} Ralph Amissah, All Rights Reserved. -\\\\ SiSU is software for document structuring, publishing and search (with object citation numbering), \\href{http://www.sisudoc.org}{www.sisudoc.org} -\\\\ SiSU is released under \\href{http://www.fsf.org/licenses/gpl.html}{GPL 3 } or later, #{@url_brace.tex_open}\\href{http://www.fsf.org/licenses/gpl.html}{http://www.fsf.org/licenses/gpl.html}#{@url_brace.tex_close}. -{\\end{footnotesize} -\\\\ -WOK - end - def doc_sc_info_footnote_full -<<WOK -\\footnote{%\nGenerated by \\href{http://www.jus.uio.no/sisu}{SiSU \\ www.jus.uio.no/sisu }\\ \\newline \\scriptsize{Document version information: \\emph{sourcefile} \\uline{#{@md.fnstex}}; \\emph{version} \\uline{#{@md.sc_number}}; \\emph{date} \\uline{#{@md.sc_date}}; \\emph{time} \\uline{#{@md.sc_time}}}} -WOK - end - def doc_sc_info_footnote_brief - " \\footnote{%\nGenerated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\ \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu} \\newline \\href{http://www.sisudoc.org}{www.sisudoc.org} \\\n}" - end - def doc_sc_info - v=SiSU_Env::Info_version.new.get_version -<<WOK -\\\\ -{\\begin{footnotesize} -Document version information: \\\\ -\\emph{sourcefile} \\uline{#{@md.fnstex}}; \\emph{version} \\uline{#{@md.sc_number}}; \\emph{date} \\uline{#{@md.sc_date}}; \\emph{time} \\uline{#{@md.sc_time}} \\\\ -Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu }\\- version information: \\\\ -\\uline{ #{v[:project]} #{v[:version]} of #{v[:date_stamp]}} -\\end{footnotesize}}& -WOK - end - def doc_no_sc_info - v=SiSU_Env::Info_version.new.get_version -<<WOK -\\\\ -{\\begin{small} -Document information: \\\\ -\\emph{sourcefile} \\uline{#{@md.fnstex}} \\\\ -Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu } \\\\ version information: \\ -\\uline{ #{v[:project]} #{v[:version]} of #{v[:date_stamp]}} - -\\end{small}}& -WOK - end - def manifest_info - url=@md.fnb.gsub(/(?:\\)*([$&~%_#}{^])/,'\\\\\1') - fn=@md.fn[:manifest].gsub(/(?:\\)*([$&~%_#}{^])/,'\\\\\1') -<<WOK -{\\begin{footnotesize} -\\\\ For alternative output formats of this document check: -\\\\ #{@url_brace.tex_open}\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{fn}}{#{@vz.url_root_http}/#{url}/#{fn}}\\end{scriptsize}#{@url_brace.tex_close} -\\end{footnotesize}}& -WOK - end - def endnotes #not used should be inserted before MetaData section which preceeds doc_tail, but is "part of document" -<<WOK -\\subsection*{Endnotes} -\\addcontentsline{toc}{section}{Endnotes} -\\ -\\listofendnotes -WOK - end - def doc_tail - dir=SiSU_Env::Info_env.new(@md.fns) - base_html="#{dir.url.root}/#{@md.fnb}" - v=SiSU_Env::Info_version.new.get_version - sisu_ico=if FileTest.file?("#{dir.path.image_source_tex}/sisu.png") - "\\includegraphics*[width=60pt]{#{dir.path.image_source_tex}/sisu.png}" - else - tell=SiSU_Screen::Ansi.new(@md.cmd,'WARNING - image directory or image(s) missing:', %{"#{dir.path.image_source_tex}"} ) - tell.warn unless @md.cmd =~/q/ - " SiSU " - end - url=@md.fnb.gsub(/(?:\\)*([$&~%_#}{^])/,'\\\\\1') -<<WOK -\\subsection*{Information on this document copy and an unofficial List of Some web related information and sources} -\\addcontentsline{toc}{section}{Information on this document copy and an unofficial List of Some web related information and sources} -\\\\ -\"Support Open Standards and Software Libre 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. -\\\\ 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{bfseries}#{site}\\end{bfseries} \\\\ \\\\ #{@md.title} \\textbf{pdf} versions can be found at: \\\\ -{\\end{small} -\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_p]}}{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_p]}}\\end{scriptsize} \\\\ -\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_l]}}{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_l]}}\\end{scriptsize} \\\\ -\\\\\n#{@md.title} \\textbf{html} versions may be found at: \\\\ -\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:toc]}}{#{@vz.url_root_http}/#{url}/#{@md.fn[:toc]}}\\end{scriptsize} or \\\\ -\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:doc]}}{#{@vz.url_root_http}/#{url}/#{@md.fn[:doc]}}\\end{scriptsize} -\\\\ -\\\\ -\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:manifest]}}{SiSU Manifest} of document output and metadata may be found at: \\\\ -\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:manifest]}}{#{@vz.url_root_http}/#{url}/#{@md.fnl[:pre]}sisu\\_manifest#{@md.fnl[:mid]}.html#{@md.fnl[:post]}}\\end{scriptsize} -\\\\ -\\\\ - #{sitename} found at: \\begin{bfseries}#{site}\\end{bfseries}\\subsubsection*{Links that may be of interest at #{@vz.txt_home} and elsewhere:} -\\addcontentsline{toc}{subsection}{Links that may be of interest} -WOK - end - def mail_tail #not retested, the old mail_tail is commented out and appended to this program - dir=SiSU_Env::Info_env.new(@md.fns) -<<WOK -\\subsection*{Mail sender details} -\\addcontentsline{toc}{subsection}{Mail sender details} -\\\\ -Mail from: ralph@amissah.com\\\\ -44 20 8789 3452\\\\ -44 77 9669 4448 -\\\\ - \"Support Open Standards and Open Sources for the Information Technology Infrastructure\" RA -\\subsubsection*{Information on this document copy #{site}\\copyright} -Presentations' look and feel generated by \\href{http://www.jus.uio.no/sisu/}{SiSU Scribe} \\href{http://www.jus.uio.no/sisu/}{http://www.jus.uio.no/sisu/} programmed in Ruby on Debian/Gnu/Linux by Copyright \\copyright Ralph Amissah, W3 since October 3 1993 \\href{http://www.jus.uio.no/sisu/}{\\includegraphics*[width=35pt]{#{dir.path.image_source_tex}/sisu.png}}for #{sitename}. SiSU Scribe (sisu information structuring unit) produces Electronic Documents, i.e. it generates structured output for use in a number of file formats, including the pdf file produced here. -WOK - end - end class Format_text_object require 'iconv' require "#{SiSU_lib}/defaults" - attr_accessor :string,:string1,:string,:orientation,:url,:dir,:tex + attr_accessor :string,:string1,:orientation,:url,:dir,:tex @@sys=SiSU_Env::System_call.new @@tex_backslash="\\\\" @@tilde='\\\\\\~' #?? debug crazy - @@tex_pattern_margin_number="\\\\begin\\\{tiny\\\}~\\\\end\\\{tiny\\\}\\\{\\\\marginpar.+?\s+" - @@tableheader={ :p => 0, :l => 0 } + @@tex_pattern_margin_number=/\\begin\{tiny\}~\\end\{tiny\}\{\\marginpar.+?\}\}\}/ + @@tableheader={ + 'a4' => { :p => 0, :l => 0 }, + 'a5' => { :p => 0, :l => 0 }, + 'b5' => { :p => 0, :l => 0 }, + 'letter' => { :p => 0, :l => 0 }, + 'legal' => { :p => 0, :l => 0 } + } @@sys=SiSU_Env::System_call.new - @@flag_code=false @@dp=nil def initialize(md,string,string1=nil) @md,@string,@string1=md,string,string1 @@ -283,13 +90,14 @@ WOK @tx=SiSU_Env::Get_init.instance.tex @url_brace=SiSU_Viz::Skin.new.url_decoration @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine + @ps=string1 if string1=~/(?:a4|letter|legal|book|a5|b5)/i end def longtable_landscape @end_table='\end{longtable}' @row_break='\\\\\\' - if @string[/<!Th?¡\s+c(\d+);(.+?)!\\~(\d+;\w\d+;\w\d+)>/u] + if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] no_of_cols,cols_width,ocn=$1,$2,$3 - tw=case @md.papersize + tw=case @ps when /a4/i; @tx.a4.landscape.w #European default, SiSU default when /letter/i; @tx.letter.landscape.w #U.S. default when /legal/i; @tx.legal.landscape.w #U.S. alternative @@ -298,9 +106,10 @@ WOK else @tx.a4.landscape.w #default currently A4 end textwidth=(tw.to_i/2) - 24 - @@tableheader[:l]=1 if @string =~/<!Th/ + @@tableheader[@ps][:l]=1 if @string =~/#{Mx[:gr_o]}Th/ w=cols_width.split(/;\s*/) - @@number_of_cols=no_of_cols + @@number_of_cols=no_of_cols ||=@@number_of_cols + #@@number_of_cols=0 unless @@number_of_cols.to_i > 0 @colW=[] @colW << '{' w.each do |x| @@ -311,39 +120,40 @@ WOK end @colW << '}' @colW=@colW.join - @start_table="<~#{ocn}>\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + + @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#@colW\n" - @string.gsub!(/<!Th?¡\s+c\d+?;.+!\\~\d+;\w\d+;\w\d+>/u,@start_table) + @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table) end - if @string =~/<!TZ!>/ - @string.gsub!(/<!TZ!>/," #@end_table\n\\end{tiny}") + if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") end - @string.gsub!(/<!¡/u,'') - if @@tableheader[:l] == 1 - if @string =~/¡\d+?¡(.+?)(?:¡|!)/u + @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + if @@tableheader[@ps][:l] == 1 + if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u tablefoot=@string[/\<!f(.+?)!\>/,1] @string.gsub!(/\<!f(.+?)!\>/,'') - @string.gsub!(/¡\d+?¡(.+?)(?:¡|!)/u,'\bfseries \1&') - @string.gsub!(/&>\s*$/," #@row_break \\hline\\endhead #@row_break") + @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') + @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot - @@tableheader[:l],@@number_of_cols=0,0 + @@tableheader[@ps][:l]=0 + #@@tableheader[@ps][:l],@@number_of_cols=0,0 end else - if @string =~/¡\d+?¡(.+?)(?:¡|!)/u - @string.gsub!(/¡\d+?¡(.+?)(?:¡|!)/u,'\1&') - @string.gsub!(/&>\s*$/," #@row_break") + if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u + @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,'\1&') + @string.gsub!(/&\s*$/," #@row_break") end end - @string=if ocn; "<~#{ocn}>" + @string + @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string else @string end end def longtable_portrait @end_table='\end{longtable}' @row_break='\\\\\\' - if @string[/<!Th?¡\s+c(\d+);(.+?)!\\~(\d+;\w\d+;\w\d+)>/u] + if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] no_of_cols,cols_width,ocn=$1,$2,$3 - tw=case @md.papersize + tw=case @ps when /a4/i; @tx.a4.portrait.w #European default, SiSU default when /letter/i; @tx.letter.portrait.w #U.S. default when /legal/i; @tx.legal.portrait.w #U.S. alternative @@ -352,9 +162,9 @@ WOK else @tx.a4.portrait.w #default currently A4 end textwidth=tw.to_i - 20 - @@tableheader[:p]=1 if @string =~/<!Th/ + @@tableheader[@ps][:p]=1 if @string =~/#{Mx[:gr_o]}Th/ w=cols_width.split(/;\s*/) - @@number_of_cols=no_of_cols + @@number_of_cols=no_of_cols ||=@@number_of_cols @colW=[] @colW << '{' w.each do |x| @@ -366,30 +176,31 @@ WOK end @colW << '}' @colW=@colW.join - @start_table="<~#{ocn}>\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + + @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#@colW\n" - @string.gsub!(/<!Th?¡\s+c\d+?;.+!\\~\d+;\w\d+;\w\d+>/u,"#@start_table") + @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table") end - if @string =~/<!TZ!>/ - @string.gsub!(/<!TZ!>/," #@end_table\n\\end{tiny}") + if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") end - @string.gsub!(/<!¡/u,'') - if @@tableheader[:p] == 1 - if @string =~/¡\d+?¡(.+?)(?:¡|!)/u + @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + if @@tableheader[@ps][:p] == 1 + if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u tablefoot=@string[/\<!f(.+?)!\>/,1] @string.gsub!(/\<!f(.+?)!\>/,'') - @string.gsub!(/¡\d+?¡(.+?)(?:¡|!)/u,'\bfseries \1&') - @string.gsub!(/&>\s*$/," #@row_break \\hline\\endhead #@row_break") + @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') + @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot - @@tableheader[:p],@@number_of_cols=0,0 + @@tableheader[@ps][:p]=0 + #@@tableheader[@ps][:p],@@number_of_cols=0,0 end else - if @string =~/¡\d+?¡(.+?)(?:¡|!)/u - @string.gsub!(/¡\d+?¡(.+?)(?:¡|!)/u,'\1&') - @string.gsub!(/&>\s*$/," #@row_break") + if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u + @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') + @string.gsub!(/&\s*$/," #@row_break") end end - @string=if ocn; "<~#{ocn}>" + @string + @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string else @string end end @@ -399,7 +210,7 @@ WOK @end_table="\\end{tabular}" @row_break='\\\\\\\\' @break_page="#@row_break\n#@row_break \n" - if @string[/<!Th?¡\s+c(\d+);(.+?)!>/u] + if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/u] no_of_cols,cols_width=$1,$2 @w=cols_width.split(/;\s*/) @colW=[] @@ -408,391 +219,49 @@ WOK @colW << "p{#{col_w}cm}" if col_w end @start_table="\\begin{tabular}{#@colW}\n" - @string.gsub!(/<!Th?¡\s+c\d+?;.+!>/u,"#@start_table}") + @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#@start_table}") end - if @string =~/<!TZ!>/ - @string.gsub!(/<!TZ!>/,"#@end_table") + if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") @@table_pg_break_counter=1 end - if @string =~/<!¡/u + if @string =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u if @@table_pg_break_counter == 28 # taken from 34 ideal for portrait to 28 which suits landscape @string="\n\n#@end_table \n#@break_page#@start_table\n" @@table_pg_break_counter=1 else - @string.gsub!(/<!¡/u,'') + @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') @@table_pg_break_counter+=1 tablefoot=@string[/\<!f(.+?)!\>/,1] @string.gsub!(/\<!f(.+?)!\>/,'') end end - if @string =~/¡\d+?¡(.+?)(?:¡|!)/u - @string.gsub!(/¡\d+?¡(.+?)(?:¡|!)/u,"\\1&") - @string.gsub!(/&>\s*$/,"#@row_break") + if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u + @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u,"\\1&") + @string.gsub!(/&\s*$/,"#@row_break") end @string end - def pdftex_special_characters_1(string) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list - #p @@utf_8.list - #@string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) - word=string.scan(/\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/ - para_array=[] - string=if word - word.each do |w| # _ - / # | : ! ^ ~ - unless string =~/^(?:0~|%+ |<!Th?¡ )/um - w.gsub!(/[\\]?~/,'<=tilde>') unless w=~/^[1-6]~|~\{|\}~|~\[|\]~|^\^~\s|~\^|\*~\S+|~#|\{t~|<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ - w.gsub!(/&#(?:126|152);/,'<=tilde>') #126 usual - #w.gsub!(/&#(?:126|152);/,'<=tilde>') unless w=~/https?:\/\/\S+/ #126 usual - w.gsub!(/\\?\|||/,'<=pipe>') #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX - end - para_array << w - end - string=para_array.join(' ') - string=string.strip - string - else '' - end - string.gsub!(/<~\d+;(?:\w|[0-6]:)\d+;[umdv]\d+><#@dp:#@dp>/,'') - string.gsub!(/.+?<-#>/,'') - string.gsub!(/<EOF>/,'') - string.gsub!(/<ENDNOTES?>/,'') - #problem sequence -> - string.gsub!(/&(?:nbsp);/,'<=hardspace>') # < SiSU special character also LaTeX - string.gsub!(/&(?:lt|#060);/,'<=lt>') # < SiSU special character also LaTeX - string.gsub!(/&(?:gt|#062);/,'<=gt>') # > SiSU special character also LaTeX - string.gsub!(/{/,'<=curlyopen>') # { SiSU special character also LaTeX - string.gsub!(/}/,'<=curlyclose>') # } SiSU special character also LaTeX - string.gsub!(/&#(?:126|152);/,'<=tilde>') # ~ SiSU special character also LaTeX - string.gsub!(/#/,'\#') # # SiSU special character also LaTeX - string.gsub!(/!/,'!') # ! SiSU not really special sisu character but done, also LaTeX - string.gsub!(/*/,'*') # * should you wish to escape astrisk e.g. describing \*{bold}* - string.gsub!(/-/,'-') # - SiSU special character also LaTeX - string.gsub!(/+/,'+') # + SiSU special character also LaTeX - string.gsub!(/,/,',') # + SiSU special character also LaTeX - string.gsub!(/&/,'<=amp>') #unless @string=~/<:code>/ # / SiSU special character also LaTeX - string.gsub!(///,'<=slash>') # / SiSU special character also LaTeX - string.gsub!(/\/,'<=backslash>') # \ SiSU special character also LaTeX - string.gsub!(/_/,'<=underscore>') # _ SiSU special character also LaTeX - string.gsub!(/|/,'|') # | SiSU not really special sisu character but done, also LaTeX - string.gsub!(/:/,':') # : SiSU not really special sisu character but done, also LaTeX - string.gsub!(/^|\^/,'<=caret>') # ^ SiSU not really special sisu character but done, also LaTeX - string.gsub!(/\#/,'<=hash>') - ##watch placement, problem sequence ^ - string.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') - string.gsub!(/<:pb>/,'\newpage') - string.gsub!(/<:pn>/,'\clearpage') - string.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript - string - end - def pdftex_special_characters_2(string) - string.gsub!(/œ/,'\oe ') - string.gsub!(/\$/,'\$') - string.gsub!(/\#/,'\#') - string.gsub!(/\%/,'\%') - string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes - if string !~/^\s*<:image|\}:image\s/ - string.gsub!(/_/,'\_') - end - string.gsub!(/\{/,'\{') - string.gsub!(/\}/,'\}') - string.gsub!(/ /,'~') # ~ character for hardspace - # sequence important must appear after removal of { and } - string.gsub!(/&\S+?;/,'') #hmmm - # sequence imortant place before removal of & - if string=~/<:code>/; @@flag_code=true - elsif string=~/<:code-end>/; @@flag_code=false - end - if @@flag_code; string.gsub!(/&/,'{\\\&}') - else string.gsub!(/(\s+&\s+)/,' and ') - end - string.gsub!(/§/u,'\S') #latex: space between next character not preserved? #string.gsub!(/§ /,'\S ') - string.gsub!(/£/u,'\pounds') - string.gsub!(/&\S+?;/,' ') - string.gsub!(/<a href=".+?">/,' ') - string.gsub!(/<\/a>/,' ') - string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case - string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url - string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration - unless @@flag_code - string.gsub!(/(^|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start - else #code-block: angle brackets special characters, note _ already escaped - string.gsub!(/\\_</,'{\UseTextSymbol{OML}{<}}') - string.gsub!(/\\_>/,'{\UseTextSymbol{OML}{>}}') - end - string.gsub!(/<:ee>/,'') - string.gsub!(/<!>/,' ') - #proposed change, insert, but may be redundant - string.gsub!(/ \/><:i[12]>(.+?)(?:\}~|<br)/,' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder - string.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area - string.gsub!(/<b>(.+?)<\/b>/,'\begin{bfseries}\1 \end{bfseries}') - string.gsub!(/<em>(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') - string.gsub!(/<(bold|strong)>(.+?)<\/(bold|strong)>/,'\begin{bfseries}\1 \end{bfseries}') - string.gsub!(/<h\d+>(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}') - string.gsub!(/<i>(.+?)<\/i>/,'\emph{\1}') - string.gsub!(/<italic>(.+?)<\/italic>/,'\emph{\1}') - string.gsub!(/<u>(.+?)<\/u>/,'\uline{\1}') # ulem - string.gsub!(/<cite>(.+?)<\/cite>/,"``\\1''") # quote - string.gsub!(/<ins>(.+?)<\/ins>/,'\uline{\1}') # ulem - string.gsub!(/<del>(.+?)<\/del>/,'\sout{\1}') # ulem - string.gsub!(/<sub>(.+?)<\/sub>/,"\$_{\\textrm{\\1}}\$") - string.gsub!(/<sup>(.+?)<\/sup>/,"\$^{\\textrm{\\1}}\$") - unless @@flag_code - string.gsub!(/"(.+?)"/,'“\1”') # quote marks / quotations open & close " need condition exclude for code - string.gsub!(/\s+"/,' “') # open " - string.gsub!(/^([1-6-]#{@@tilde}\S*|<.+?>)?\s*"/,'\1“') # open " - string.gsub!(/"(\s|\.|,|:|;)/,'”\1') # close " - string.gsub!(/"([1-6-]#{@@tilde}\S*|<.+?>)?\s*$/,'”\1') # close " - string.gsub!(/"(\.|,)/,'”') # close " - string.gsub!(/\s+'/,' `') # open ' - string.gsub!(/^([1-6-]#{@@tilde}\S*|<.+?>)?\s*'/,'\1`') # open ' - end - string.gsub!(/^(<:i[1-9]>)?\s*\\_\*\s*/,'\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_ - string.gsub!(/(<font.*?>|<\/font>)/,'') - string.gsub!(/\s*<sup>(\S+?)<\/sup>/,'^\1') - string.gsub!(/(<sup>|<\/sup>)/,'') - string - end - def pdftex_special_characters_3(string) - string.gsub!(/<br(\s*[^\/][^>])/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder - string.gsub!(/([^<][^b][^r]\s+)\/>/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder - #problem sequence (another kludge) -> - string.gsub!(/<=lt>/,'{\UseTextSymbol{OML}{<}}') - string.gsub!(/<=gt>/,'{\UseTextSymbol{OML}{>}}') - #string.gsub!(/<=lt>/,'\<') - #string.gsub!(/<=gt>/,'\>') - string.gsub!(/<=underscore>/,'\_') - string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text - string.gsub!(/<=tilde>/,'{\~~}') - string.gsub!(/<=pipe>/,'{\textbar}') - string.gsub!(/<=caret>/,'{\^{~}}') - #string.gsub!(/<=caret>/,'\^{}') - string.gsub!(/<=exclaim>/,'\Verbatim{!}') - string.gsub!(/<=hash>/,'{\#}') - #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}') - #string.gsub!(/<=slash>/,'{\slash}') - string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 - string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 - #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}') - string.gsub!(/<=slash>/,'{/}') - string.gsub!(/<=backslash>/,'{\textbackslash}') - #string.gsub!(/<=asterisk>/,'*') - #string.gsub!(/<=exclaim>/,'!') - #string.gsub!(/<=asterisk>/,'{\ast}') - #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic - #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' - string.gsub!(/<=copymark>\s*(.+)?\s+(<\\~\d+;\w(?:[0-6]:)?\d+;\w\d+><#@dp:#@dp>)/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic - string - end - def xetex_special_characters_1(string) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list - #p @@utf_8.list - #string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) - word=string.scan(/\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/ - para_array=[] - string=if word - word.each do |w| # _ - / # | : ! ^ ~ - unless string =~/^(?:0~|%+ |<!Th?¡ )/um - w.gsub!(/[\\]?~/,'<=tilde>') unless w=~/^[1-6]~|~\{|\}~|~\[|\]~|^\^~\s|~\^|\*~\S+|~#|\{t~|<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ - w.gsub!(/&#(?:126|152);/,'<=tilde>') #126 usual - #w.gsub!(/&#(?:126|152);/,'<=tilde>') unless w=~/https?:\/\/\S+/ #126 usual - w.gsub!(/\\?\|||/,'<=pipe>') #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX - end - para_array << w - end - string=para_array.join(' ') - string=string.strip - string - else '' - end - string.gsub!(/<~\d+;(?:\w|[0-6]:)\d+;[umdv]\d+><#@dp:#@dp>/,'') - string.gsub!(/.+?<-#>/,'') - string.gsub!(/<EOF>/,'') - string.gsub!(/<ENDNOTES?>/,'') - #problem sequence -> - string.gsub!(/&(?:nbsp);/,'<=hardspace>') # < SiSU special character also LaTeX - string.gsub!(/&(?:lt|#060);/,'<=lt>') # < SiSU special character also LaTeX - string.gsub!(/&(?:gt|#062);/,'<=gt>') # > SiSU special character also LaTeX - string.gsub!(/{/,'<=curlyopen>') # { SiSU special character also LaTeX - string.gsub!(/}/,'<=curlyclose>') # } SiSU special character also LaTeX - string.gsub!(/&#(?:126|152);/,'<=tilde>') # ~ SiSU special character also LaTeX - string.gsub!(/#/,'\#') # # SiSU special character also LaTeX - string.gsub!(/!/,'!') # ! SiSU not really special sisu character but done, also LaTeX - string.gsub!(/*/,'*') # * should you wish to escape astrisk e.g. describing \*{bold}* - string.gsub!(/-/,'-') # - SiSU special character also LaTeX - string.gsub!(/+/,'+') # + SiSU special character also LaTeX - string.gsub!(/,/,',') # + SiSU special character also LaTeX - string.gsub!(/&/,'<=amp>') #unless @string=~/<:code>/ # / SiSU special character also LaTeX - string.gsub!(///,'<=slash>') # / SiSU special character also LaTeX - string.gsub!(/\/,'<=backslash>') # \ SiSU special character also LaTeX - string.gsub!(/_/,'<=underscore>') # _ SiSU special character also LaTeX - string.gsub!(/|/,'|') # | SiSU not really special sisu character but done, also LaTeX - string.gsub!(/:/,':') # : SiSU not really special sisu character but done, also LaTeX - string.gsub!(/^|\^/,'<=caret>') # ^ SiSU not really special sisu character but done, also LaTeX - string.gsub!(/\#/,'<=hash>') - ##watch placement, problem sequence ^ - string.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') - string.gsub!(/<:pb>/,'\newpage') - string.gsub!(/<:pn>/,'\clearpage') - string.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript - string - end - def xetex_special_characters_2(string) - string.gsub!(/œ/,'\oe ') - string.gsub!(/\$/,'\$') - string.gsub!(/\#/,'\#') - string.gsub!(/\%/,'\%') - string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes - if string !~/^\s*<:image|\}:image\s/ - string.gsub!(/_/,'\_') - end - string.gsub!(/\{/,'\{') - string.gsub!(/\}/,'\}') - string.gsub!(/ /,'~') # ~ character for hardspace - # sequence important must appear after removal of { and } - string.gsub!(/&\S+?;/,'') #hmmm - # sequence imortant place before removal of & - if string=~/<:code>/; @@flag_code=true - elsif string=~/<:code-end>/; @@flag_code=false - end - if @@flag_code; string.gsub!(/&/,'{\\\&}') - else string.gsub!(/(\s+&\s+)/,' and ') - end - string.gsub!(/§/u,'\S') #latex: space between next character not preserved? #string.gsub!(/§ /,'\S ') - string.gsub!(/£/u,'\pounds') - string.gsub!(/&\S+?;/,' ') - string.gsub!(/<a href=".+?">/,' ') - string.gsub!(/<\/a>/,' ') - string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case - string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url - string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration - unless @@flag_code - string.gsub!(/(^|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start - else #code-block: angle brackets special characters, note _ already escaped - string.gsub!(/\\_</,'{\UseTextSymbol{OML}{<}}') - string.gsub!(/\\_>/,'{\UseTextSymbol{OML}{>}}') - end - string.gsub!(/<:ee>/,'') - string.gsub!(/<!>/,' ') - #proposed change, insert, but may be redundant - string.gsub!(/ \/><:i[12]>(.+?)(?:\}~|<br)/,' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder - string.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area - string.gsub!(/<b>(.+?)<\/b>/,'\begin{bfseries}\1 \end{bfseries}') - string.gsub!(/<em>(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') - string.gsub!(/<(bold|strong)>(.+?)<\/(bold|strong)>/,'\begin{bfseries}\1 \end{bfseries}') - string.gsub!(/<h\d+>(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}') - string.gsub!(/<i>(.+?)<\/i>/,'\emph{\1}') - string.gsub!(/<italic>(.+?)<\/italic>/,'\emph{\1}') - string.gsub!(/<u>(.+?)<\/u>/,'\uline{\1}') # ulem - string.gsub!(/<cite>(.+?)<\/cite>/,"``\\1''") # quote - string.gsub!(/<ins>(.+?)<\/ins>/,'\uline{\1}') # ulem - string.gsub!(/<del>(.+?)<\/del>/,'\sout{\1}') # ulem - string.gsub!(/<sub>(.+?)<\/sub>/,"\$_{\\textrm{\\1}}\$") - string.gsub!(/<sup>(.+?)<\/sup>/,"\$^{\\textrm{\\1}}\$") - unless @@flag_code - string.gsub!(/"(.+?)"/,'“\1”') # quote marks / quotations open & close " need condition exclude for code - string.gsub!(/\s+"/,' “') # open " - string.gsub!(/^([1-6-]#{@@tilde}\S*|<.+?>)?\s*"/,'\1“') # open " - string.gsub!(/"(\s|\.|,|:|;)/,'”\1') # close " - string.gsub!(/"([1-6-]#{@@tilde}\S*|<.+?>)?\s*$/,'”\1') # close " - string.gsub!(/"(\.|,)/,'”') # close " - string.gsub!(/\s+'/,' `') # open ' - string.gsub!(/^([1-6-]#{@@tilde}\S*|<.+?>)?\s*'/,'\1`') # open ' - end - #string.gsub!(/^(<:i[1-9]>)?\s*\\_\*\s*/,'\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_ - string.gsub!(/^(<:i[1-9]>)?\s*\\_\*\s*/,'\1 ● ~~') - string.gsub!(/(<font.*?>|<\/font>)/,'') - string.gsub!(/\s*<sup>(\S+?)<\/sup>/,'^\1') - string.gsub!(/(<sup>|<\/sup>)/,'') - string - end - def xetex_special_characters_3(string) - string.gsub!(/<br(\s*[^\/][^>])/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder - string.gsub!(/([^<][^b][^r]\s+)\/>/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder - #problem sequence (another kludge) -> - string.gsub!(/<=lt>/,'{\UseTextSymbol{OML}{<}}') - string.gsub!(/<=gt>/,'{\UseTextSymbol{OML}{>}}') - #string.gsub!(/<=lt>/,'\<') - #string.gsub!(/<=gt>/,'\>') - string.gsub!(/<=underscore>/,'\_') - string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text - string.gsub!(/<=tilde>/,'{\~~}') - string.gsub!(/<=pipe>/,'{\textbar}') - string.gsub!(/<=caret>/,'{\^{~}}') - #string.gsub!(/<=caret>/,'\^{}') - string.gsub!(/<=exclaim>/,'\Verbatim{!}') - string.gsub!(/<=hash>/,'{\#}') - #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}') - #string.gsub!(/<=slash>/,'{\slash}') - string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 - string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 - #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}') - string.gsub!(/<=slash>/,'{/}') - string.gsub!(/<=backslash>/,'{\textbackslash}') - #string.gsub!(/<=asterisk>/,'*') - #string.gsub!(/<=exclaim>/,'!') - #string.gsub!(/<=asterisk>/,'{\ast}') - #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic - #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' - string.gsub!(/<=copymark>\s*(.+)?\s+(<\\~\d+;\w(?:[0-6]:)?\d+;\w\d+><#@dp:#@dp>)/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic - string - end - def special_characters_curly(string) - string.gsub!(/<=curlyopen>/,'\{') - string.gsub!(/<=curlyclose>/,'\}') - string - end - - - def special_characters_unsafe_1(string) #depreciated, make obsolete - # some substitutions are sequence sensitive, rearrange with care. - string.gsub!(/\\backslash (copyright|clearpage|newpage)/,"\\\\\\1") #kludge bad solution, find out where tail is sent through specChar ! - string - end - def special_characters #special characters - some substitutions are sequence sensitive, rearrange with care. - string=@string - case @tex2pdf - when /pdf/ - string=pdftex_special_characters_1(string) unless string.nil? - string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@string) - string=pdftex_special_characters_2(string) unless string.nil? - string=pdftex_special_characters_3(string) unless string.nil? - when /xe/ - string=xetex_special_characters_1(string) unless string.nil? - string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@string) - string=xetex_special_characters_2(string) unless string.nil? #issues with xetex - string=xetex_special_characters_3(string) unless string.nil? - end - @string=string - end - def special_characters_safe #special characters - some substitutions are sequence sensitive, rearrange with care. - string=@string - case @tex2pdf - when /pdf/ - string=pdftex_special_characters_1(@string) unless string.nil? - string=pdftex_special_characters_2(@string) unless string.nil? - #special_characters_3(@string) - when /xe/ - string=xetex_special_characters_1(@string) unless string.nil? - string=xetex_special_characters_2(@string) unless string.nil? # remove this to start with, causes issues - end - @string=string - end - def heading_major(para,lev) + def heading_major(para,lev) #\emph{ title=@md.title para.strip! if para para.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') cont_ln=para.dup - cont_ln.gsub!(/#{@@tex_pattern_margin_number}/,'') - cont_ln.gsub!(/#{lev}#{@@tilde}(?:\S+)?\s+/,'') + cont_ln.gsub!(@@tex_pattern_margin_number,'') + cont_ln.gsub!(/#{Mx[:lv_o]}#{lev}:\S*?#{Mx[:lv_c]}\s*/,'') if para =~/\\[Ff]ootnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - para.gsub!(/(#{@md.lev}.*)\n?$/m,"\\part*{\\1} + para.gsub!(/(#{@md.lev}.*)\n?$/m, #apparently not used @md.lev does not exist + "\\part*{\\1} \\addcontentsline{toc}{section}{#{cont_ln}} -\\markboth{#{title}}\n") if (para !~/#{lev}#{@@tilde}/) - para.gsub!(/^#{lev}#{@@tilde}\s*(.*)\n?$/m, +\\markboth{#{title}}\n") if (para !~/#{Mx[:lv_o]}#{lev}:/) + para.gsub!(/^#{Mx[:lv_o]}#{lev}:\S*?#{Mx[:lv_c]}\s*(.*)\n?$/m, "\\part*{\\1} \\addcontentsline{toc}{section}{#{cont_ln}} \\markboth{#{title}}\n") +para end def level1 heading_major(@string,1) @@ -807,14 +276,14 @@ WOK @string.strip! if @string @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') cont_ln=@string.dup - cont_ln.gsub!(/#{@@tex_pattern_margin_number}/,'') + cont_ln.gsub!(@@tex_pattern_margin_number,'') cont_ln.gsub!(/#{@@tex_backslash*2}/,"#{@@tex_backslash*4}") # added w42 - cont_ln.gsub!(/4#{@@tilde}\S+\s+/,'') + cont_ln.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'') cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 title=@md.title @string.gsub!(/#{@md.lv4}\s+(#{@md.lv4})/m,'\1') - if @string =~/4#{@@tilde}endnotes|<:4-endnotes>/ + if @string =~/#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|<:4-endnotes>/ # watch exclusion removes endnotes marker from pdf 2003w03 @string.gsub!(/.+/m,'') end @@ -822,12 +291,12 @@ WOK cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - if @string !~/4#{@@tilde}/ + if @string !~/#{Mx[:lv_o]}4:/ @string.gsub!(/(#{@md.lv4}.*)\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsection}{#{cont_ln}} \\markright{#{title}}") else - @string.gsub!(/^\s*4#{@@tilde}\S+\s*(.*)?\n?$/m,"\\subsubsection*{\\1} + @string.gsub!(/^\s*#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.*)?\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsection}{#{cont_ln}} \\markright{#{title}}") end @@ -838,8 +307,8 @@ WOK @string.strip! if @string @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') cont_ln=@string.dup - cont_ln.gsub!(/#{@@tex_pattern_margin_number}/,'') - cont_ln.gsub!(/5#{@@tilde}\S*\s+/,'') + cont_ln.gsub!(@@tex_pattern_margin_number,'') + cont_ln.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'') cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa @@ -848,12 +317,13 @@ WOK cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - if @string !~/5#{@@tilde}/ + if @string !~/#{Mx[:lv_o]}5:/ @string.gsub!(/(#{@md.lv5}.*?)\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ }") else - @string.gsub!(/^\s*5#{@@tilde}\S*\s*(.*)?\n?$/m,"\\subsubsection*{\\1} + @string.gsub!(/^\s*#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, + "\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ }") end @@ -864,8 +334,8 @@ WOK @string.strip! if @string @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') cont_ln=@string.dup - cont_ln.gsub!(/#{@@tex_pattern_margin_number}/,'') - cont_ln.gsub!(/6#{@@tilde}\S*\s+/,'') + cont_ln.gsub!(@@tex_pattern_margin_number,'') + cont_ln.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'') cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 @string.gsub!(/#{@md.lv6}\s+(#{@md.lv6})/m,'\1') @@ -874,8 +344,8 @@ WOK cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end @string.gsub!(/(#{@md.lv6}.*)\n?$/m, - "\\subsubsection*{\\1}") if (@string !~/6#{@@tilde}/) - @string.gsub!(/^\s*6#{@@tilde}\S*\s*(.*)?\n?$/m, + "\\subsubsection*{\\1}") if (@string !~/#{Mx[:lv_o]}6:/) + @string.gsub!(/^\s*#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, '\subsubsection*{\1}') @string.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1') #end BUGWATCH @@ -892,7 +362,7 @@ WOK when /8/; '70mm' when /9/; '80mm' end - @string.gsub!(/<:i#{lev}>\s*(.*)/m, + @string.gsub!(/#{Mx[:pa_o]}:i#{lev}#{Mx[:pa_c]}\s*(.*)/m, "\\begin{ParagraphIndent}{#{indent}}\\1 \\end{ParagraphIndent}}") end @@ -951,7 +421,6 @@ WOK end hsp="\n{\\color{mywhite} .}&~\n" # ~ character for hardspace caption="{\\\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}" if c - #caption="{\\\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c[1]}\\end{scriptsize}&}" if c image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ \ and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") dir.path.image_source_local_tex @@ -999,16 +468,16 @@ WOK z[/(\d+)x\d*/,1] else 200 end - dm=case @md.papersize - when /a4/; @tx.a4 - when /letter/; @tx.letter - when /legal/; @tx.legal - when /b5/; @tx.b5 - when /a5/; @tx.a5 - else @tx.a4 + dm=case @ps # @md.papersize + when /a4/; @tx.a4.landscape.img_px + when /letter/; @tx.letter.landscape.img_px + when /legal/; @tx.legal.landscape.img_px + when /b5/; @tx.b5.landscape.img_px + when /a5/; @tx.a5.landscape.img_px + else @tx.a4.landscape.img_px end - width=if width.to_i > dm.landscape.img_px - dm.landscape.img_px + width=if width.to_i > dm + dm else width end c=z[/``(.+?)''/m,1] @@ -1058,7 +527,54 @@ WOK end def http wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) - @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm).http_word_mode #(orientation) + @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm,@ps).http_word_mode #GET PAPER SIZE AND USE IT + end + def title + @string=SiSU_TeX_Pdf::Special_characters.new(@md,@string).special_characters_safe + if @string1 + @string1=SiSU_TeX_Pdf::Special_characters.new(@md,@string1).special_characters_safe + @string1.gsub!(/\$/,"\\$") + "\n\\title{#@string#{@@tex_backslash*2} \\textbf{\\normalsize #@string1}\\normalsize}" + else "\n\\title{#@string}" + end + end + def title_landscape + title + end + def title_portrait + title + end + def para_num + paranumber_display=if @md.markup.inspect =~/no_ocn/ \ + or @md.mod.inspect =~/--no-ocn/ + '' + else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@string1\\end{tiny}}}" #ocn object citation numbering + end + if @string !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ + @string.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect + else + if (@string =~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})/) #watch - in 1-6 is suspect + @string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #watch - in 1-6 is suspect + #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\begin{bfseries}\\2 \\end{bfseries}\n") #watch - in 1-6 is suspect + #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\emph{\\2}\n") #watch - in 1-6 is suspect + @string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? + #@string.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? + else + @string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\1\n") + #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\begin{bfseries}\\1 \\end{bfseries}\n") + #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\emph{\\1}\n") + end + end + @string + end + end + class Format_head + def initialize(md,ps,layout=nil,string1=nil) + @md,@ps,@layout,@string1=md,ps,layout,string1 + @tx=SiSU_Env::Get_init.instance.tex + @url_brace=SiSU_Viz::Skin.new.url_decoration + @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine + @ps=@string if @string=~/(?:a4|letter|legal|book|a5|b5)/i end def language @lang=if @md.dc_language[:code] @@ -1095,21 +611,6 @@ WOK else 'english' end end - def title - @string=Format_text_object.new(@md,@string).special_characters_safe - if @string1 - @string1=Format_text_object.new(@md,@string1).special_characters_safe - @string1.gsub!(/\$/,"\\$") - "\n\\title{#@string#{@@tex_backslash*2} \\textbf{\\normalsize #@string1}\\normalsize}" - else "\n\\title{#@string}" - end - end - def title_landscape - title - end - def title_portrait - title - end def tex_head_lang #babel 18n language #@md.dc_language[:name] @@ -1193,14 +694,14 @@ WOK end def tex_head_paper_dimensions d={} - case @string + case @layout when /portrait/ #textheight,textwidth=@tx.a4.portrait.h,@tx.a4.portrait.w d[:papertype],d[:fontsize]='a4paper','11pt' d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='0mm','0mm','-12pt' d[:headheight],d[:headsep],d[:columnsep]='12pt','35pt','' d[:marginparsep],d[:marginparwidth]='4mm','8mm' - case @md.papersize + case @ps #@md.papersize when /a4/i #European default, SiSU default d[:papertype],d[:fontsize]='a4paper','12pt' d[:textheight],d[:textwidth]=@tx.a4.portrait.h,@tx.a4.portrait.w @@ -1212,9 +713,14 @@ WOK d[:textheight],d[:textwidth]=@tx.legal.portrait.h,@tx.legal.portrait.w when /book|b5/i #book default - larger d[:papertype],d[:fontsize]='b5paper','11pt' + d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-4mm','-4mm','-36pt' + d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','' d[:textheight],d[:textwidth]=@tx.b5.portrait.h,@tx.b5.portrait.w when /a5/i d[:papertype],d[:fontsize]='a5paper','11pt' + d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-4mm','-4mm','-36pt' + d[:headheight],d[:headsep],d[:columnsep]='8pt','12pt','' + d[:marginparsep],d[:marginparwidth]='4mm','6mm' d[:textheight],d[:textwidth]=@tx.a5.portrait.h,@tx.a5.portrait.w else #default currently A4 d[:papertype],d[:fontsize]='a4paper','12pt' @@ -1226,7 +732,7 @@ WOK d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-8mm','-8mm','-18mm' d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','40pt' d[:marginparsep],d[:marginparwidth]='4mm','8mm' - case @md.papersize + case @ps #@md.papersize when /a4/i #European default, SiSU default d[:papertype],d[:fontsize]='a4paper','12pt' d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w @@ -1240,7 +746,7 @@ WOK d[:papertype],d[:fontsize],d[:columnsep]='b5paper','11pt','35pt' d[:textheight],d[:textwidth]=@tx.b5.landscape.h,@tx.b5.landscape.w when /a5/i - d[:papertype],d[:fontsize],d[:columnsep]='a5paper','10pt','38pt' + d[:papertype],d[:fontsize],d[:columnsep]='a5paper','10pt','32pt' d[:textheight],d[:textwidth]=@tx.a5.landscape.h,@tx.a5.landscape.w else #default currently A4 d[:papertype],d[:fontsize]='a4paper','12pt' @@ -1250,8 +756,7 @@ WOK d end def tex_head_paper - d={} - case @string + case @layout when /portrait/ tex_head_paper_portrait(tex_head_paper_dimensions) when /landscape/ @@ -1259,7 +764,7 @@ WOK end end def tex_head_pdftex_dvi - color=case @string + color=case @layout when /portrait/ <<WOK colorlinks=true, @@ -1275,7 +780,7 @@ WOK linkcolor=myred, % \\href{...} and \\pageref{...} WOK end - if @string =~/portrait|landscape/ + if @layout =~/portrait|landscape/ <<WOK \\usepackage{url} \\usepackage{alltt} @@ -1383,69 +888,606 @@ WOK \\usepackage{fancyhdr} \\lhead{} \\renewcommand{\\part}{\\\@startsection -{part}% -{1}% -{-2mm}% -{-\\baselineskip}% -{0.5\\baselineskip}% -{\\bfseries\\large\\scshape}}% + {part}{1}{-2mm}% + {-\\baselineskip}{0.5\\baselineskip}% + {\\bfseries\\large\\upshape\\raggedright}} \\renewcommand{\\section}{\\\@startsection -{section}% -{2}% -{-2mm}% -{-\\baselineskip}% -{0.5\\baselineskip}% -{\\bfseries\\Large\\upshape}}% + {section}{2}{-2mm}% + {-\\baselineskip}{0.5\\baselineskip}% + {\\bfseries\\large\\upshape\\raggedright}} \\renewcommand{\\subsection}{\\\@startsection -{subsection}% -{3}% -{-2mm}% -{-\\baselineskip}% -{0.5\\baselineskip}% -{\\bfseries\\large\\upshape}}% + {subsection}{3}{-2mm}% + {-\\baselineskip}{0.5\\baselineskip}% + {\\bfseries\\large\\upshape\\raggedright}} \\renewcommand{\\subsubsection}{\\\@startsection -{subsubsection}% -{4}% -{-2mm}% -{-\\baselineskip}% -{0.5\\baselineskip}% -{\\bfseries\\normalsize\\upshape}}% + {subsubsection}{4}{-2mm}% + {-\\baselineskip}{0.5\\baselineskip}% + {\\normalfont\\normalsize\\bfseries\\raggedright}} \\renewcommand{\\paragraph}{\\\@startsection -{paragraph}% -{5}% -{-2mm}% -{-\\baselineskip}% -{0.5\\baselineskip}% -{\\normalfont\\normalsize\\itshape}}% + {paragraph}{5}{-2mm}% + {-\\baselineskip}{0.5\\baselineskip}% + {\\normalfont\\normalsize\\itshape\\raggedright}} \\renewcommand{\\subparagraph}{\\\@startsection -{subparagraph}% -{6}% -{-2mm}% -{-\\baselineskip}% -{0.5\\baselineskip}% -{\\normalfont\\normalsize\\itshape}}% + {subparagraph}%{6}%{-2mm}% + {-\\baselineskip}{0.5\\baselineskip}% + {\\normalfont\\normalsize\\itshape\\raggedright}} +% \\makeatother \\selectlanguage{#{language}} WOK end def a4generic end - def para_num - paranumber_display=if @md.markup.inspect =~/no_ocn/ \ - or @md.mod.inspect =~/--no-ocn/ - '' - else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@string1\\end{tiny}}}" #ocn object citation numbering + end + class Special_characters + @@flag_code=false + @@tex_backslash="\\\\" + def initialize(md,string) + @md,@string=md,string + @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + #@tx=SiSU_Env::Get_init.instance.tex + @url_brace=SiSU_Viz::Skin.new.url_decoration + @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine + end + def pdftex_special_characters_1(string) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list + #p @@utf_8.list + #@string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) + word=string.scan(/#{Mx[:mk_o]}\S+?#{Mx[:mk_c]}|\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/ + para_array=[] + string=if word + word.each do |w| # _ - / # | : ! ^ ~ + unless string =~/^(?:#{Rx[:meta]}|%+ |#{Mx[:gr_o]}Th?#{Mx[:tc_p]} )/um + unless w=~/^#{Mx[:lv_o]}[1-6]:|~\{|\}~|~\[|\]~|^\^~\s|~\^|\*~\S+|~#|\{t~|#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}/ + w.gsub!(/[\\]?~/,'<=tilde>') + #if w !~/^(\s*<:image|\}:image\s)|/ + # w.gsub!(/_/,'\_') + #end + end + w.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') #126 usual + #w.gsub!(/&#(?:126|152);/,'<=tilde>') unless w=~/https?:\/\/\S+/ #126 usual + w.gsub!(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'<=pipe>') #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + end + para_array << w + end + string=para_array.join(' ') + string=string.strip + string + else '' end - if @string !~/^([1-6a-z-]#{@@tilde}\S*|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ - @string.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect - else - if (@string =~/^(?:[1-6a-z-]#{@@tilde}\S*|<:.+?>)/) #watch - in 1-6 is suspect - @string.gsub!(/^([1-6a-z-]#{@@tilde}\S*)\s*(.+)/m,"\\1 #{paranumber_display} \\2\n") #watch - in 1-6 is suspect - @string.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") - else - @string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\1\n") + string.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' ') + string.gsub!(/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;[umdv]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/,'') + string.gsub!(/.+?<-#>/,'') + string.gsub!(/#{Mx[:br_eof]}|#{Mx[:br_endnotes]}/,'') + #problem sequence -> + string.gsub!(/&(?:nbsp);/,'<=hardspace>') # < SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#nbsp#{Mx[:gl_c]}/,'<=hardspace>') # < SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<=lt>') # < SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'<=gt>') # > SiSU special character also LaTeX + #string.gsub!(/#{Mx[:gl_o]}(#[a-z]+|#[0-9]+)#{Mx[:gl_c]}/,'\1') #i don't think so + string.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'<=curlyopen>') # { SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'<=curlyclose>') # } SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') # ~ SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'\#') # # SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') # ! SiSU not really special sisu character but done, also LaTeX + string.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') # * should you wish to escape astrisk e.g. describing \*{bold}* + string.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') # - SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+') # + SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',') # + SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @string=~/<:code>/ # / SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>') # / SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>') # \ SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>') # _ SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') # | SiSU not really special sisu character but done, also LaTeX + string.gsub!(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':') # : SiSU not really special sisu character but done, also LaTeX + string.gsub!(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'<=caret>') # ^ SiSU not really special sisu character but done, also LaTeX + string.gsub!(/\#/,'<=hash>') + ##watch placement, problem sequence ^ + string.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') + string.gsub!(/#{Mx[:br_page]}/,'\newpage') + string.gsub!(/#{Mx[:br_page_new]}/,'\clearpage') + string.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript + string + end + def pdftex_special_characters_2(string) + string.gsub!(/#{Mx[:gl_o]}#156#{Mx[:gl_c]}/,'\oe ') + string.gsub!(/\$/,'\$') + string.gsub!(/\#/,'\#') + string.gsub!(/\%/,'\%') + string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes + if string !~/^\s*<:image|\}:image\s/ + string.gsub!(/_/,'\_') + end + string.gsub!(/\{/,'\{') + #string.gsub!(/\}/,'\}') + string.gsub!(/ /,'~') # ~ character for hardspace + # sequence important must appear after removal of { and } + string.gsub!(/&\S+?;/,'') #hmmm + # sequence imortant place before removal of & + if string=~/#{Mx[:gr_o]}code#{Mx[:gr_c]}/; @@flag_code=true + elsif string=~/#{Mx[:gr_o]}code-end#{Mx[:gr_c]}/; @@flag_code=false + end + if @@flag_code; string.gsub!(/&/,'{\\\&}') + else string.gsub!(/(\s+&\s+)/,' and ') + end + string.gsub!(/§/u,'\S') #latex: space between next character not preserved? #string.gsub!(/§ /,'\S ') + string.gsub!(/£/u,'\pounds') + string.gsub!(/&\S+?;/,' ') + string.gsub!(/<a href=".+?">/,' ') + string.gsub!(/<\/a>/,' ') + string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case + string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url + string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration + unless @@flag_code + string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start + else #code-block: angle brackets special characters, note _ already escaped + string.gsub!(/\\_</,'{\UseTextSymbol{OML}{<}}') + string.gsub!(/\\_>/,'{\UseTextSymbol{OML}{>}}') + end + string.gsub!(/<:ee>/,'') + string.gsub!(/<!>/,' ') + #proposed change, insert, but may be redundant + string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/,' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + string.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area + string.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}') + #string.gsub!(/<em>(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') + #string.gsub!(/<(bold|strong)>(.+?)<\/(bold|strong)>/,'\begin{bfseries}\1 \end{bfseries}') + string.gsub!(/<h\d+>(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}') + string.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}') + #string.gsub!(/<italic>(.+?)<\/italic>/,'\emph{\1}') + string.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}') # ulem + string.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''") # quote #CHECK + string.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}') # ulem + string.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}') # ulem + string.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$") + string.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") + unless @@flag_code + string.gsub!(/"(.+?)"/,'“\1”') # quote marks / quotations open & close " need condition exclude for code + string.gsub!(/\s+"/,' “') # open " + string.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*"/,'\1“') # open " + string.gsub!(/"(\s|\.|,|:|;)/,'”\1') # close " + string.gsub!(/"(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*$/,'”\1') # close " + string.gsub!(/"(\.|,)/,'”') # close " + string.gsub!(/\s+'/,' `') # open ' + string.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`') # open ' + end + string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*#{Mx[:gl_bullet]}\s*/,'\1 \begin{math} \bullet \end{math}~~') #bullets - added 2004w17 watch \\_ + string.gsub!(/(<font.*?>|<\/font>)/,'') + string.gsub!(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1') + #string.gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_paragraph]}|\n)\*/,' \\\\ ') + #string.gsub!(/(<sup>|<\/sup>)/,'') + string + end + def pdftex_special_characters_3(string) + string.gsub!(/<br(\s*[^\/][^>])/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + string.gsub!(/([^<][^b][^r]\s+)\/>/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + #problem sequence (another kludge) -> + string.gsub!(/<=lt>/,'{\UseTextSymbol{OML}{<}}') + string.gsub!(/<=gt>/,'{\UseTextSymbol{OML}{>}}') + #string.gsub!(/<=lt>/,'\<') + #string.gsub!(/<=gt>/,'\>') + string.gsub!(/<=underscore>/,'\_') + string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text + string.gsub!(/<=tilde>/,'{\~~}') + string.gsub!(/<=pipe>/,'{\textbar}') + string.gsub!(/<=caret>/,'{\^{~}}') + #string.gsub!(/<=caret>/,'\^{}') + string.gsub!(/<=exclaim>/,'\Verbatim{!}') + string.gsub!(/<=hash>/,'{\#}') + #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}') + #string.gsub!(/<=slash>/,'{\slash}') + string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 + string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 + #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}') + string.gsub!(/<=slash>/,'{/}') + string.gsub!(/<=backslash>/,'{\textbackslash}') + #string.gsub!(/<=asterisk>/,'*') + #string.gsub!(/<=exclaim>/,'!') + #string.gsub!(/<=asterisk>/,'{\ast}') + #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic + #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' + string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic + string + end + def xetex_special_characters_1(string) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list + #p @@utf_8.list + #string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) + word=string.scan(/\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/ + para_array=[] + string=if word + word.each do |w| # _ - / # | : ! ^ ~ + unless string =~/^(?:#{Rx[:meta]}|%+ |#{Mx[:gr_o]}Th?#{Mx[:tc_p]} )/um + unless w=~/^#{Mx[:lv_o]}[1-6]:|~\{|\}~|~\[|\]~|^\^~\s|~\^|\*~\S+|~#|\{t~|#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}/ + w.gsub!(/[\\]?~/,'<=tilde>') + #if w !~/^(\s*<:image|\}:image\s)/ + # w.gsub!(/_/,'\_') + #end + end + w.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') #126 usual + #w.gsub!(/&#(?:126|152);/,'<=tilde>') unless w=~/https?:\/\/\S+/ #126 usual + w.gsub!(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'<=pipe>') #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + end + para_array << w end + string=para_array.join(' ') + string=string.strip + string + else '' end - @string + string.gsub(/\s*#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}\s*/,' ') + string.gsub!(/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;[umdv]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/,'') + string.gsub!(/.+?<-#>/,'') + string.gsub!(/#{Mx[:br_eof]}/,'') + string.gsub!(/#{Mx[:br_endnotes]}/,'') + #string.gsub!(/<ENDNOTES?>/,'') + #problem sequence -> + string.gsub!(/&(?:nbsp);/,'<=hardspace>') # < SiSU special character also LaTeX + string.gsub!(/&(?:lt|#060);/,'<=lt>') # < SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'<=gt>') # > SiSU special character also LaTeX + #string.gsub!(/#{Mx[:gl_o]}(&#(?:[a-z]+|[0-9]+);)#{Mx[:gl_c]}/,'\1') + string.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'<=curlyopen>') # { SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'<=curlyclose>') # } SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') # ~ SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'\#') # # SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') # ! SiSU not really special sisu character but done, also LaTeX + string.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') # * should you wish to escape astrisk e.g. describing \*{bold}* + string.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') # - SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+') # + SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',') # + SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @string=~/<:code>/ # / SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>') # / SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>') # \ SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>') # _ SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') # | SiSU not really special sisu character but done, also LaTeX + string.gsub!(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':') # : SiSU not really special sisu character but done, also LaTeX + string.gsub!(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'<=caret>') # ^ SiSU not really special sisu character but done, also LaTeX + string.gsub!(/\#/,'<=hash>') + ##watch placement, problem sequence ^ + string.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') + string.gsub!(/#{Mx[:br_page]}/,'\newpage') + string.gsub!(/#{Mx[:br_page_new]}/,'\clearpage') + string.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript + string + end + def xetex_special_characters_2(string) + string.gsub!(/#{Mx[:gl_o]}#156#{Mx[:gl_c]}/,'\oe ') + string.gsub!(/\$/,'\$') + string.gsub!(/\#/,'\#') + string.gsub!(/\%/,'\%') + string.gsub!(/\~/,'\~') #revist, should not be necessary to mark remaining tildes + if string !~/^\s*<:image|\}:image\s/ + string.gsub!(/_/,'\_') + end + string.gsub!(/\{/,'\{') + string.gsub!(/\}/,'\}') + string.gsub!(/ /,'~') # ~ character for hardspace + # sequence important must appear after removal of { and } + string.gsub!(/&\S+?;/,'') #hmmm + # sequence imortant place before removal of & + if string=~/#{Mx[:gr_o]}code#{Mx[:gr_c]}/; @@flag_code=true + elsif string=~/#{Mx[:gr_o]}code-end#{Mx[:gr_c]}/; @@flag_code=false + end + if @@flag_code; string.gsub!(/&/,'{\\\&}') + else string.gsub!(/(\s+&\s+)/,' and ') + end + string.gsub!(/§/u,'\S') #latex: space between next character not preserved? #string.gsub!(/§ /,'\S ') + string.gsub!(/£/u,'\pounds') + string.gsub!(/&\S+?;/,' ') + string.gsub!(/<a href=".+?">/,' ') + string.gsub!(/<\/a>/,' ') + string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case + string.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url + string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration + unless @@flag_code + string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,"\\1#{@url_brace.tex_open}\\begin{scriptsize}\\href{\\2}{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start + else #code-block: angle brackets special characters, note _ already escaped + string.gsub!(/\\_</,'{\UseTextSymbol{OML}{<}}') + string.gsub!(/\\_>/,'{\UseTextSymbol{OML}{>}}') + end + string.gsub!(/<:ee>/,'') + string.gsub!(/<!>/,' ') + #proposed change, insert, but may be redundant + string.gsub!(/ \/>#{Mx[:pa_o]}:i[12]#{Mx[:pa_c]}(.+?)(?:\}~|<br)/,' \begin{ParagraphIndent}{0.01\columnwidth}\1\end{ParagraphIndent} ') # footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + string.gsub!(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") # Work Area + string.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}') + #string.gsub!(/<em>(.+?)<\/em>/,'\begin{bfseries}\1 \end{bfseries}') + #string.gsub!(/<(bold|strong)>(.+?)<\/(bold|strong)>/,'\begin{bfseries}\1 \end{bfseries}') + string.gsub!(/<h\d+>(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}') + string.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}') + #string.gsub!(/<italic>(.+?)<\/italic>/,'\emph{\1}') + string.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}') # ulem + string.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''") # quote #CHECK + string.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}') # ulem + string.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}') # ulem + string.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$") + string.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") + unless @@flag_code + string.gsub!(/"(.+?)"/,'“\1”') # quote marks / quotations open & close " need condition exclude for code + string.gsub!(/\s+"/,' “') # open " + string.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*"/,'\1“') # open " + string.gsub!(/"(\s|\.|,|:|;)/,'”\1') # close " + string.gsub!(/"(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*$/,'”\1') # close " + string.gsub!(/"(\.|,)/,'”') # close " + string.gsub!(/\s+'/,' `') # open ' + string.gsub!(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*'/,'\1`') # open ' + end + string.gsub!(/^\s*#{Mx[:gl_bullet]}\s*/,'\begin{math} \bullet \end{math}~~') + string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*#{Mx[:gl_bullet]}\s*/,'\1 \begin{math} \bullet \end{math}~~') + #string.gsub!(/^\s*#{Mx[:gl_bullet]}\s*/,'● ~~') + #string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*#{Mx[:gl_bullet]}\s*/,'\1 ● ~~') + ##string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})?\s*\\_\*\s*/,'\1 ● ~~') + ##string.gsub!(/^\\_\*\s*/,'● ~~') + string.gsub!(/(<font.*?>|<\/font>)/,'') + string.gsub!(/\s*#{Mx[:fa_superscript_o]}(\S+?)#{Mx[:fa_superscript_c]}/,'^\1') + #string.gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_paragraph]}|\n)\*/,' \\\\ ') + #string.gsub!(/(<sup>|<\/sup>)/,'') + string + end + def xetex_special_characters_3(string) + string.gsub!(/<br(\s*[^\/][^>])/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + string.gsub!(/([^<][^b][^r]\s+)\/>/,'\1') # clean up, incredibly messy :-( footnote indents, problems if match exists in ordinary paragraphs? check! Work Area 200501 a bit tricky as must be able to match multiple times, and to clean remainder + #problem sequence (another kludge) -> + string.gsub!(/<=lt>/,'{\UseTextSymbol{OML}{<}}') + string.gsub!(/<=gt>/,'{\UseTextSymbol{OML}{>}}') + #string.gsub!(/<=lt>/,'\<') + #string.gsub!(/<=gt>/,'\>') + string.gsub!(/<=underscore>/,'\_') + string.gsub!(/(\href\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text + string.gsub!(/<=tilde>/,'{\~~}') + string.gsub!(/<=pipe>/,'{\textbar}') + string.gsub!(/<=caret>/,'{\^{~}}') + #string.gsub!(/<=caret>/,'\^{}') + string.gsub!(/<=exclaim>/,'\Verbatim{!}') + string.gsub!(/<=hash>/,'{\#}') + #string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}') + #string.gsub!(/<=slash>/,'{\slash}') + string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005 + string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005 + #string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}') + string.gsub!(/<=slash>/,'{/}') + string.gsub!(/<=backslash>/,'{\textbackslash}') + #string.gsub!(/<=asterisk>/,'*') + #string.gsub!(/<=exclaim>/,'!') + #string.gsub!(/<=asterisk>/,'{\ast}') + #string.gsub!(/<=copymark>/,"^{\\copyright} ") # watch has been problematic + #copymark='{\\begin{small}\\raisebox{1ex}{\\copyright}\\end{small}} ' + string.gsub!(/<=copymark>\s*(.+)?\s+(#{Mx[:id_o]}\\~\d+;\w(?:[0-6]:)?\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]})/,"^\\copyright \\textnormal{\\1} \\2") # watch likely to be problematic + string + end + def special_characters_curly(string) + string.gsub!(/<=curlyopen>/,'\{') + string.gsub!(/<=curlyclose>/,'\}') + string + end + def special_characters_unsafe_1(string) #depreciated, make obsolete + # some substitutions are sequence sensitive, rearrange with care. + string.gsub!(/\\backslash (copyright|clearpage|newpage)/,"\\\\\\1") #kludge bad solution, find out where tail is sent through specChar ! + string + end + def special_characters #special characters - some substitutions are sequence sensitive, rearrange with care. + string=@string + case @tex2pdf + when /pdf/ + string=pdftex_special_characters_1(string) unless string.nil? + string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@string) + string=pdftex_special_characters_2(string) unless string.nil? + string=pdftex_special_characters_3(string) unless string.nil? + when /xe/ + string=xetex_special_characters_1(string) unless string.nil? + string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@string) + string=xetex_special_characters_2(string) unless string.nil? #issues with xetex + string=xetex_special_characters_3(string) unless string.nil? + end + @string=string + end + def special_characters_safe #special characters - some substitutions are sequence sensitive, rearrange with care. + string=@string + case @tex2pdf + when /pdf/ + string=pdftex_special_characters_1(@string) unless string.nil? + string=pdftex_special_characters_2(@string) unless string.nil? + #special_characters_3(@string) + when /xe/ + string=xetex_special_characters_1(@string) unless string.nil? + string=xetex_special_characters_2(@string) unless string.nil? # remove this to start with, causes issues + end + @string=string + end + end + class Use_TeX + attr_accessor :url,:txt,:date + def initialize(md) + @md=md + @vz=SiSU_Env::Get_init.instance.skin + @date=SiSU_Env::Info_date.new # #{@date.year} + @copymark='{\\begin{footnotesize}\\raisebox{1ex}{\\copyright}\\end{footnotesize}}' + @url_brace=SiSU_Viz::Skin.new.url_decoration + end + def skip + "\n\\vspace*{\\smallskipamount} \n" + end + def paraskip_normal + '\setlength{\parskip}{1ex plus0.5ex minus0.2ex}' + end + def paraskip_small + '\setlength{\parskip}{0.5ex plus0.2ex minus0.1ex}' + end + def skip_small + #"\\smallskip{}" + end + def skip_small_vspace + "\n\\vspace*{\\smallskipamount} \n" + end + def skip_small_footnote + #"\n\\smallskip{}\n" + end + def skip_medium + "\n\\medskip{}\n\n" + end + def skip_dummy + "\n" + end + def header + "\\lhead[ ]{ }\n" + + "\\chead[ \\fancyplain{} \\bfseries \\footnotesize \\leftmark ]{ \\fancyplain{} \\bfseries \\footnotesize \\rightmark }\n" + + "\\rhead[ ]{ }\n" + end + def footer + base_prog_txt=if @md.base_program + case @md.base_program + when /kdissert/i; " \\\\ \\href{http://freehackers.org/~tnagy/kdissert/}{Kdissert}" + else '' + end + else '' + end + "\\lfoot[\\textrm{\\thepage}]{\\tiny \\href{#{@vz.url_sisu}}{#{@vz.txt_signature}}#{base_prog_txt}}\n" + + "\\cfoot[\\href{#{@vz.url_home}}{#{@vz.url_txt}}]{\\href{#{@vz.url_home}}{#{@vz.url_txt}}}\n" + + "\\rfoot[\\tiny \\href{#{@vz.url_sisu}}{#{@vz.txt_signature}}]{\\textrm{\\thepage}}\n" + end + def site + "\\href{#{@vz.url_home}}{#{@vz.url_txt}}" + end + def sitename #owners site, eg freeculture, free.for.all, gutenberg etc. + "\\href{#{@vz.url_home}}{#{@vz.txt_home}}" + end + def owner_chapter + "Contact Details for Original Promulgating Authority" + end + #BOOK standard dimensions - 229x156 + def newpage(orientation) + case orientation + when /landscape/ # using longtable latex package +<<WOK +\\clearpage +WOK + when /portrait/ +<<WOK +\\newpage +WOK + end + end + def sisu_rights + v=SiSU_Env::Info_version.new.get_version + base_prog_txt=if @md.base_program + case @md.base_program + when /kdissert/i; "\n\\\\ This document prepared using \\href{http://freehackers.org/~tnagy/kdissert/}{Kdissert \\ http://freehackers.org/~tnagy/kdissert/ } \\\\ Kdissert is Document Mapping software by Thomas Nagy" + else '' + end + else '' + end +<<WOK +\\\\ ~ +{\\begin{footnotesize}#{base_prog_txt} +\\\\ Generated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\begin{tiny}[ #{v[:project]} #{v[:version]} of #{v[:date_stamp]} ]\\end{tiny} \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu} +\\\\ Copyright #@copymark 1997, current #{@date.year_static} Ralph Amissah, All Rights Reserved. +\\\\ SiSU is software for document structuring, publishing and search (with object citation numbering), \\href{http://www.sisudoc.org}{www.sisudoc.org} +\\\\ SiSU is released under \\href{http://www.fsf.org/licenses/gpl.html}{GPL 3 } or later, #{@url_brace.tex_open}\\href{http://www.fsf.org/licenses/gpl.html}{http://www.fsf.org/licenses/gpl.html}#{@url_brace.tex_close}. +{\\end{footnotesize} +\\\\ +WOK + end + def doc_sc_info_footnote_full +<<WOK +\\footnote{%\nGenerated by \\href{http://www.jus.uio.no/sisu}{SiSU \\ www.jus.uio.no/sisu }\\ \\newline \\scriptsize{Document version information: \\emph{sourcefile} \\uline{#{@md.fnstex}}; \\emph{version} \\uline{#{@md.sc_number}}; \\emph{date} \\uline{#{@md.sc_date}}; \\emph{time} \\uline{#{@md.sc_time}}}} +WOK + end + def doc_sc_info_footnote_brief + " \\footnote{%\nGenerated by \\href{http://www.jus.uio.no/sisu}{SiSU} \\ \\href{http://www.jus.uio.no/sisu}{www.jus.uio.no/sisu} \\newline \\href{http://www.sisudoc.org}{www.sisudoc.org} \\\n}" + end + def doc_sc_info + v=SiSU_Env::Info_version.new.get_version +<<WOK +\\\\ +{\\begin{footnotesize} +Document version information: \\\\ +\\emph{sourcefile} \\uline{#{@md.fnstex}}; \\emph{version} \\uline{#{@md.sc_number}}; \\emph{date} \\uline{#{@md.sc_date}}; \\emph{time} \\uline{#{@md.sc_time}} \\\\ +Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu }\\- version information: \\\\ +\\uline{ #{v[:project]} #{v[:version]} of #{v[:date_stamp]}} +\\end{footnotesize}}& +WOK + end + def doc_no_sc_info + v=SiSU_Env::Info_version.new.get_version +<<WOK +\\\\ +{\\begin{small} +Document information: \\\\ +\\emph{sourcefile} \\uline{#{@md.fnstex}} \\\\ +Generated by \\href{http://www.jus.uio.no/sisu}{SiSU www.jus.uio.no/sisu } \\\\ version information: \\ +\\uline{ #{v[:project]} #{v[:version]} of #{v[:date_stamp]}} + +\\end{small}}& +WOK + end + def manifest_info + url=@md.fnb.gsub(/(?:\\)*([$&~%_#}{^])/,'\\\\\1') + fn=@md.fn[:manifest].gsub(/(?:\\)*([$&~%_#}{^])/,'\\\\\1') +<<WOK +{\\begin{footnotesize} +\\\\ For alternative output formats of this document check: +\\\\ #{@url_brace.tex_open}\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{fn}}{#{@vz.url_root_http}/#{url}/#{fn}}\\end{scriptsize}#{@url_brace.tex_close} +\\end{footnotesize}}& +WOK + end + def endnotes #not used should be inserted before MetaData section which preceeds doc_tail, but is "part of document" +<<WOK +\\subsection*{Endnotes} +\\addcontentsline{toc}{section}{Endnotes} +\\ +\\listofendnotes +WOK + end + def doc_tail + dir=SiSU_Env::Info_env.new(@md.fns) + base_html="#{dir.url.root}/#{@md.fnb}" + v=SiSU_Env::Info_version.new.get_version + sisu_ico=if FileTest.file?("#{dir.path.image_source_tex}/sisu.png") + "\\includegraphics*[width=60pt]{#{dir.path.image_source_tex}/sisu.png}" + else + tell=SiSU_Screen::Ansi.new(@md.cmd,'WARNING - image directory or image(s) missing:', %{"#{dir.path.image_source_tex}"} ) + tell.warn unless @md.cmd =~/q/ + " SiSU " + end + url=@md.fnb.gsub(/(?:\\)*([$&~%_#}{^])/,'\\\\\1') +<<WOK +\\subsection*{Information on this document copy and an unofficial List of Some web related information and sources} +\\addcontentsline{toc}{section}{Information on this document copy and an unofficial List of Some web related information and sources} +\\\\ +\"Support Open Standards and Software Libre 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. +\\\\ 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{bfseries}#{site}\\end{bfseries} \\\\ \\\\ #{@md.title} \\textbf{pdf} versions can be found at: \\\\ +{\\end{small} +\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_p]}}{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_p]}}\\end{scriptsize} \\\\ +\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_l]}}{#{@vz.url_root_http}/#{url}/#{@md.fn[:pdf_l]}}\\end{scriptsize} \\\\ +\\\\\n#{@md.title} \\textbf{html} versions may be found at: \\\\ +\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:toc]}}{#{@vz.url_root_http}/#{url}/#{@md.fn[:toc]}}\\end{scriptsize} or \\\\ +\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:doc]}}{#{@vz.url_root_http}/#{url}/#{@md.fn[:doc]}}\\end{scriptsize} +\\\\ +\\\\ +\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:manifest]}}{SiSU Manifest} of document output and metadata may be found at: \\\\ +\\begin{scriptsize}\\href{#{@vz.url_root_http}/#{url}/#{@md.fn[:manifest]}}{#{@vz.url_root_http}/#{url}/#{@md.fnl[:pre]}sisu\\_manifest#{@md.fnl[:mid]}.html#{@md.fnl[:post]}}\\end{scriptsize} +\\\\ +\\\\ + #{sitename} found at: \\begin{bfseries}#{site}\\end{bfseries}\\subsubsection*{Links that may be of interest at #{@vz.txt_home} and elsewhere:} +\\addcontentsline{toc}{subsection}{Links that may be of interest} +WOK + end + def mail_tail #not retested, the old mail_tail is commented out and appended to this program + dir=SiSU_Env::Info_env.new(@md.fns) +<<WOK +\\subsection*{Mail sender details} +\\addcontentsline{toc}{subsection}{Mail sender details} +\\\\ +Mail from: ralph@amissah.com\\\\ +44 20 8789 3452\\\\ +44 77 9669 4448 +\\\\ + \"Support Open Standards and Open Sources for the Information Technology Infrastructure\" RA +\\subsubsection*{Information on this document copy #{site}\\copyright} +Presentations' look and feel generated by \\href{http://www.jus.uio.no/sisu/}{SiSU Scribe} \\href{http://www.jus.uio.no/sisu/}{http://www.jus.uio.no/sisu/} programmed in Ruby on Debian/Gnu/Linux by Copyright \\copyright Ralph Amissah, W3 since October 3 1993 \\href{http://www.jus.uio.no/sisu/}{\\includegraphics*[width=35pt]{#{dir.path.image_source_tex}/sisu.png}}for #{sitename}. SiSU Scribe (sisu information structuring unit) produces Electronic Documents, i.e. it generates structured output for use in a number of file formats, including the pdf file produced here. +WOK end end end |