From 749e0d8443028eaff7af93d17c8dae8d44be42bc Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 29 Aug 2008 21:40:02 -0400 Subject: texpdf: paper use dimensions, tolerance, url matching; removal of dummy headings when not used; manifest presentation * texpdf: paper use dimensions, tolerance, url matching; * removal of dummy headings when not used (html scroll, latex/pdf, odf) * manifest presentation --- lib/sisu/v0/defaults.rb | 12 +++++----- lib/sisu/v0/html_scroll.rb | 1 + lib/sisu/v0/i18n.rb | 54 +++++++++++++++++++++++++++++++++++++++----- lib/sisu/v0/manifest.rb | 29 ++++++++++++++++-------- lib/sisu/v0/odf.rb | 1 + lib/sisu/v0/plaintext.rb | 4 ---- lib/sisu/v0/texpdf.rb | 15 +++++++----- lib/sisu/v0/texpdf_format.rb | 20 ++++++++-------- lib/sisu/v0/xml.rb | 3 --- 9 files changed, 95 insertions(+), 44 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/defaults.rb b/lib/sisu/v0/defaults.rb index 801b6434..a3e1b16d 100644 --- a/lib/sisu/v0/defaults.rb +++ b/lib/sisu/v0/defaults.rb @@ -2095,7 +2095,7 @@ WOK end def landscape def w - 250 + 238 end def h 160 @@ -2122,7 +2122,7 @@ WOK end def landscape def w - 234 + 226 end def h 166 @@ -2140,7 +2140,7 @@ WOK 168 end def h - 294 + 286 end def img_px 474 @@ -2149,7 +2149,7 @@ WOK end def landscape def w - 306 + 296 end def h 166 @@ -2176,7 +2176,7 @@ WOK end def landscape def w - 208 + 200 end def h 130 @@ -2203,7 +2203,7 @@ WOK end def landscape def w - 164 + 152 end def h 100 diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index 9286df10..3e72f855 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -87,6 +87,7 @@ module SiSU_HTML_scroll #if para =~/^#{Mx[:lv_o]}\d:endnotes#{Mx[:lv_c]}\s*Endnotes/ ## para.gsub!(/Endnotes.+/,'') #end + para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ if para =~/^#{Mx[:lv_o]}\d:meta#{Mx[:lv_c]}\s*Document Information/ para.gsub!(/(Document Information(?: \(metadata\))?)/,'\1') end diff --git a/lib/sisu/v0/i18n.rb b/lib/sisu/v0/i18n.rb index 8ac3ffc8..286ba65d 100644 --- a/lib/sisu/v0/i18n.rb +++ b/lib/sisu/v0/i18n.rb @@ -105,6 +105,9 @@ module SiSU_Translate def metadata @lang_class.metadata end + def filetype_description + @lang_class.filetype_description + end def file_size @lang_class.file_size end @@ -258,6 +261,9 @@ module SiSU_Translate def language @lang_class.language end + def manifest_description + @lang_class.manifest_description + end def manifest_description_output @lang_class.manifest_description_output end @@ -314,6 +320,9 @@ module SiSU_Translate def description 'description' end + def filetype_description + 'filetype description' + end def metadata 'metadata' end @@ -464,11 +473,14 @@ module SiSU_Translate def language_version_list 'Document Language Versions, manifests' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output - 'SiSU manifest' + 'Available document filetypes' end def manifest_description_metadata - 'SiSU manifest of document metadata' + 'Document Metadata' end def language_list_translated lang=case @trans_str @@ -513,6 +525,9 @@ module SiSU_Translate def description 'description' end + def filetype_description + description + end def metadata 'metadonnées' end @@ -663,6 +678,9 @@ module SiSU_Translate def language_version_list 'Versions des langues du document, manifestes' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'Manifeste SiSU du document généré' end @@ -712,6 +730,9 @@ module SiSU_Translate def description 'Beschreibung' end + def filetype_description + description + end def metadata 'Metadata' end @@ -862,6 +883,9 @@ module SiSU_Translate def language_version_list 'verfügbare Sprachen' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'SiSU Zusammenfassung des Dokumentes' end @@ -907,10 +931,13 @@ module SiSU_Translate end def filename 'nombre del fichero' - end - def description - 'descripción' - end + end + def description + 'descripción' + end + def filetype_description + description + end def metadata 'metadatos' end @@ -1061,6 +1088,9 @@ module SiSU_Translate def language_version_list 'Document Language Versions, manifests' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'Manifiesto SiSU de salida generada' end @@ -1110,6 +1140,9 @@ module SiSU_Translate def description 'descrizione' end + def filetype_description + description + end def metadata 'metadati' end @@ -1260,6 +1293,9 @@ module SiSU_Translate def language_version_list 'Traduzioni disponibili' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'Inventario SiSU dell\'output generato' end @@ -1309,6 +1345,9 @@ module SiSU_Translate def description 'kuvaus' end + def filetype_description + description + end def metadata 'metadata' end @@ -1459,6 +1498,9 @@ module SiSU_Translate def language_version_list 'Dokumentin kieliversiot, manifestit' end + def manifest_description + 'SiSU manifest of document filetypes and metadata' + end def manifest_description_output 'Tuotetun tuloksen SISU-manifesti' end diff --git a/lib/sisu/v0/manifest.rb b/lib/sisu/v0/manifest.rb index ffd99695..78045e80 100644 --- a/lib/sisu/v0/manifest.rb +++ b/lib/sisu/v0/manifest.rb @@ -65,6 +65,7 @@ module SiSU_Manifest require "#{SiSU_lib}/particulars" include SiSU_Particulars require "#{SiSU_lib}/html_minitoc" + #require "#{SiSU_lib}/html_format" require "#{SiSU_lib}/html" include SiSU_HTML_Format require "#{SiSU_lib}/param" @@ -119,7 +120,7 @@ module SiSU_Manifest manifest << x end end - def summarize(id,file,img='') + def summarize(id,file,img='● ') size=(File.size("#{@base_path}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" @@ -177,7 +178,7 @@ module SiSU_Manifest elsif url =~/^\.\.\//; url.gsub(/^\.(\.)?/,@env.url.root) else url end - @manifest[:html] << %{

#{lnk}

  #{@url_brace.xml_open}#{static}#{@url_brace.xml_close}

\n} + @manifest[:html] << %{

#{lnk}

  #{@url_brace.xml_open}#{static}#{@url_brace.xml_close}

\n} end def output_tests if FileTest.file?("#@base_path/#{@md.fn[:toc]}")==true @@ -568,16 +569,26 @@ SiSU manifest: #{@md.title} #{minitoc.to_s}
-

#{@md.dc_title}

+

#{@translate.manifest_description}

+

#{@md.dc_title}

#{@md.dc_creator}

+

+  Document, Available Filetypes +

+

+  Document Metadata +

+

+      (metadata suggested links (if any) +

WOK published_versions @manifest[:html] << '
' @manifest[:html] <<<#{@translate.manifest_description_output} - - +

#{@translate.description}

#{@translate.filename}

#{@translate.file_size}

(kB)

+ WOK output_tests @@ -589,7 +600,7 @@ WOK @manifest[:html] << '

#{@translate.filetype_description}

#{@translate.filename}

#{@translate.file_size}

(kB)

' @manifest[:html] <<<#{@translate.manifest_description_metadata} - +
WOK metadata_tests @@ -597,8 +608,8 @@ WOK

#{@translate.metadata}

#{@translate.description}

WOK @manifest[:html] <<< -

#{@translate.suggested_links}:

+

#{@translate.suggested_links}:

+ WOK links_tests @manifest[:html] <<<#{@translate.language_version_list} -
+
WOK diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index 03a94ce6..6b1491c2 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -441,6 +441,7 @@ module SiSU_ODF data.each do |para| #p para if para =~safe_characters and @md.cmd =~/V/ #KEEP #para.gsub!(/<(~\d+;(?:\w|[0-6]:)\d+;\w\d+)><(#@dp:#@dp)>/,'<\1><\2>') + para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ para_array=[] word=para.scan(/\S+|\n/) if word diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index 9d25ed73..4dd808fc 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -378,10 +378,6 @@ WOK #@plaintext[:owner_details]=formatMono.bold_para #para='' elsif para =~/(#{Mx[:tc_p]}|#{Mx[:gr_o]}Th?)/u #tables ! check - #elsif para =~/(.*)(.*)/ - # one,two=$1,$2 - # format_text=Format_text_object.new(one,two) - # para=format_text.seg_no_paranum end para='' if (para =~// \ and para =~/^(-\{{2}~\d+|)/) # -endnote diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index f86d8729..3cf560c4 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -344,6 +344,7 @@ module SiSU_TeX # DEBUG 2003w16 this is a kludge, because i could not get parameters # from param, Sort out ... revert to more elegant solution # even more of a kludge as had to insert newlines where code is used not satisfactory, think about + para='' if para =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ para=if para =~/#{Mx[:br_nl]}|\n/; para.split(/#{Mx[:br_nl]}|\n/) else para end @@ -438,7 +439,7 @@ module SiSU_TeX end elsif x =~/code/; @@flag_alt,@@flag_code=true,true elsif @@flag_alt - if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/m + if para =~ /(?:https?|file|ftp)/m txt_obj={:txt =>para,:paper_size =>'a4'} para=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http end @@ -503,7 +504,7 @@ module SiSU_TeX end para end - if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/ + if para =~ /(?:https?|file|ftp)/ para=if para !~/\.(?:png|jpg|gif)/ txt_obj={:txt =>para,:paper_size =>'a4'} SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http @@ -539,10 +540,12 @@ module SiSU_TeX end @tex_file <<< # note this bit of dereferencing magic + s_lnk_url=%<\\begin{scriptsize}\\url{#{url}}\\end{scriptsize}> # note this bit of dereferencing magic else url.gsub!(/\.\.\//,'') s_lnk_url="(#{@tex.site}) \\\\\n" + ' ' + "\\begin{scriptsize}" + - %<\\href\{#{@vz.url_root_http}/#{url}\}\{#{@vz.url_root_http}/#{url}\}> + # note this bit of dereferencing magic + %<\\url\{#{@vz.url_root_http}/#{url}\}> + # note this bit of dereferencing magic "\\end{scriptsize}" end @tex_file << " #{s_lnk} \\\\\n #{s_lnk_url} \n" unless @md.doc_skin =~/skin_mail/ diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index c224d4aa..b6a1e1f2 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -461,9 +461,9 @@ para @url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/ @words.each do |word| @w << if word=~@url_generic_rgx - if word =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ - regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ - punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.join + if word =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ + regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ + punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?([;.,]?(?:\s|$))/.match(word).captures.join else regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\S+)/ punctuate='' @@ -1042,14 +1042,14 @@ WOK string.gsub!(/&\S+?;/,' ') string.gsub!(//,' ') string.gsub!(/<\/a>/,' ') - string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration unless @@flag_code - string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration 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!(/\\_/,'\<') #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!(/((?:\\href|\\url)\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text string.gsub!(/<=tilde>/,'{$\sim$}') string.gsub!(/<=pipe>/,'{\textbar}') string.gsub!(/<=caret>/,'{\^{~}}') @@ -1209,14 +1209,14 @@ WOK string.gsub!(/&\S+?;/,' ') string.gsub!(//,' ') string.gsub!(/<\/a>/,' ') - string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + string.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, '\1\begin{scriptsize}\url{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url string.gsub!(/[^\}>_]((?:https?|file|ftp):\/\/\S+?)(<\/\S>)/, ' \begin{scriptsize}\url{\1} \end{scriptsize}\2') #special case - string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/, + string.gsub!(/\B(?:\\_|\\)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?:\s|$))/, '\begin{scriptsize}\\url{\1}\end{scriptsize}\2') #specially escaped url no decoration unless @@flag_code - string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/, + string.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, "\\1#{@url_brace.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@url_brace.tex_close}\\3") #url matching with decoration 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!(/\\_/,'\<') #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!(/((?:\\href|\\url)?\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text string.gsub!(/<=tilde>/,'{$\sim$}') string.gsub!(/<=pipe>/,'{\textbar}') string.gsub!(/<=caret>/,'{\^{~}}') diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index 1fc6d221..4826a503 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -389,9 +389,6 @@ WOK format_text.scr_inden_ocn_e_no_paranum end end - if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ - # i don't get the condition for no paranum - end else # end para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para -- cgit v1.2.3

#{@translate.filename}

#{@translate.description}