From a2130055009ddc805a6c2f31309868e75d5fe9b7 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 26 May 2010 12:54:18 -0400 Subject: dal (syntax, doc_str, numbering) add internal document link to tagged point (including ocn) --- lib/sisu/v2/dal_doc_str.rb | 5 +++-- lib/sisu/v2/dal_numbering.rb | 10 +++++++--- lib/sisu/v2/dal_syntax.rb | 32 +++++++++++++++----------------- 3 files changed, 25 insertions(+), 22 deletions(-) (limited to 'lib/sisu/v2') diff --git a/lib/sisu/v2/dal_doc_str.rb b/lib/sisu/v2/dal_doc_str.rb index a250175b..e35baf5a 100644 --- a/lib/sisu/v2/dal_doc_str.rb +++ b/lib/sisu/v2/dal_doc_str.rb @@ -98,7 +98,7 @@ module SiSU_document_structure_extract def endnote_test?(str) bool=((str=~/~\{.+?\}~|~\[.+?\]~/) ? true : false) end - def extract_tags(str) + def extract_tags(str,nametag=nil) tags=[] if str.nil? else @@ -109,6 +109,7 @@ module SiSU_document_structure_extract tags=str.scan(/#{Mx[:tag_o]}(\S+?)#{Mx[:tag_c]}/).flatten str.gsub!(/[ ]?#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}[ ]?/,' ') #may be issues with spaces would leave one, but "code" blocks? end + tags=nametag ? (tags << nametag) : tags end [str,tags] end @@ -164,7 +165,7 @@ module SiSU_document_structure_extract elsif t_o=~/^:?[A-C1-6]\~(\S+)\s+(.+)/ name,obj=$1,$2 note=endnote_test?(obj) - obj,tags=extract_tags(obj) + obj,tags=extract_tags(obj,name) h={:lv=>lv,:name=>name,:obj=>obj,:idx=>idx,:tags=>tags} SiSU_document_structure::Object_heading.new.heading(h) else nil diff --git a/lib/sisu/v2/dal_numbering.rb b/lib/sisu/v2/dal_numbering.rb index c8460ced..c62ff8d9 100644 --- a/lib/sisu/v2/dal_numbering.rb +++ b/lib/sisu/v2/dal_numbering.rb @@ -354,6 +354,10 @@ module SiSU_numbering end if defined? dob.ocn \ and dob.ocn + @segname=((dob.is=='heading'|| dob.is=='heading_insert') && dob.ln==4 && (defined? dob.name)) \ + ? (dob.name) \ + : @segname + tags["#{dob.ocn}"]={:segname=>@segname} ocn_html_seg[dob.ocn]=if dob.is =~/heading/ x=if dob.ln =~/[1-3]/ {:seg=>nil,:level=> dob.ln} @@ -367,9 +371,9 @@ module SiSU_numbering dob.tags=dob.tags.uniq if defined? dob.tags if defined? dob.tags \ and dob.tags.length > 0 - @segname=((dob.is=='heading'|| dob.is=='heading_insert') && dob.ln==4 && (defined? dob.name)) \ - ? (dob.name) \ - : @segname + #@segname=((dob.is=='heading'|| dob.is=='heading_insert') && dob.ln==4 && (defined? dob.name)) \ + #? (dob.name) \ + #: @segname dob.tags.each do |x| tags[x]={:ocn=>dob.ocn.to_s,:segname=>@segname} #@tags[x.to_s]=[dob.ocn.to_s,@segname.to_s] end diff --git a/lib/sisu/v2/dal_syntax.rb b/lib/sisu/v2/dal_syntax.rb index 9774f7c1..07186d67 100644 --- a/lib/sisu/v2/dal_syntax.rb +++ b/lib/sisu/v2/dal_syntax.rb @@ -325,29 +325,25 @@ module SiSU_Syntax dob.obj.gsub!(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}") #escaped special character dob.obj.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character dob.obj.gsub!(/(?:<:?br>|
)/,"#{Mx[:br_line]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') - if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}[.]{1,2}\/)\S+/m - if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, + if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m + if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m + dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch end - if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m - dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m + dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") end - dob.obj.gsub!(/\{\s*([^{}]+?)\s*\}((?:https?:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + dob.obj.gsub!(/\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) - if dob.obj=~/#{Mx[:lnk_c]}([.]{2}\/\S+?[^>< ]+?)[,.;'"]?(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m - lnk=$1 - dob.obj.gsub!(/#{Mx[:lnk_c]}#{lnk}([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}#{lnk}#{Mx[:rel_c]}\\1}) - end - if dob.obj=~/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)[,.;'"]?(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m - lnk=$1 - dob.obj.gsub!(/#{Mx[:lnk_c]}##{lnk}([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}#{lnk}#{Mx[:rel_c]}\\1}) - end + dob.obj.gsub!(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}\\1#{Mx[:rel_c]}\\2}) + dob.obj.gsub!(/#{Mx[:lnk_c]}:(\S+?[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) + dob.obj.gsub!(/#{Mx[:lnk_c]}[.]{2}\/(\S+?[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) end if dob.obj=~/_(?:https?|ftp):\S+/m # _http://url #CHECK dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])(_(?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, @@ -414,8 +410,10 @@ module SiSU_Syntax "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image dob.obj.gsub!(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4") #any remaining linked text or image + dob.obj.gsub!(/\{\s*(.+?)\s*\}#(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3") #any remaining linked text or image, check need dob.obj.gsub!(/\{\s*(.+?)\s*\}(#{Mx[:rel_o]}\S+?#{Mx[:rel_c]})/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image, check need dob.obj.gsub!(/\{\s*(.+?)\s*\}(image)/, "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image elsif dob.is=='table' -- cgit v1.2.3 From bf068fdee8c5c966748f42784fa3ad73544d8526 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 26 May 2010 12:57:18 -0400 Subject: sysenv, require constants, (issue with webrick) --- lib/sisu/v2/sysenv.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/sisu/v2') diff --git a/lib/sisu/v2/sysenv.rb b/lib/sisu/v2/sysenv.rb index f11cdcbd..4daccbcd 100644 --- a/lib/sisu/v2/sysenv.rb +++ b/lib/sisu/v2/sysenv.rb @@ -59,6 +59,7 @@ @@cX=nil @@current_document=Dir.pwd #nil #'' module SiSU_Env + require "#{SiSU_lib}/constants" # constants.rb require 'fileutils' include FileUtils::Verbose require 'singleton' -- cgit v1.2.3 From fec639c59a032977b87ff49920e74ae08d485f04 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 26 May 2010 13:18:31 -0400 Subject: output formats internal document (and relative) linking as possible --- lib/sisu/v2/concordance.rb | 2 +- lib/sisu/v2/epub_segments.rb | 18 +++++++++---- lib/sisu/v2/epub_tune.rb | 16 +++++++++++- lib/sisu/v2/html_scroll.rb | 1 + lib/sisu/v2/html_segments.rb | 14 ++++++++--- lib/sisu/v2/html_tune.rb | 5 ++++ lib/sisu/v2/odf.rb | 56 +++++++++++++++++++++++++++++++++++++---- lib/sisu/v2/particulars.rb | 3 ++- lib/sisu/v2/plaintext.rb | 1 + lib/sisu/v2/shared_html_lite.rb | 29 +++++++++++++++++---- lib/sisu/v2/shared_xml.rb | 2 ++ lib/sisu/v2/texpdf_format.rb | 56 +++++++++++++++++++++++------------------ lib/sisu/v2/webrick.rb | 4 ++- 13 files changed, 160 insertions(+), 47 deletions(-) (limited to 'lib/sisu/v2') diff --git a/lib/sisu/v2/concordance.rb b/lib/sisu/v2/concordance.rb index d8da2005..03635cd0 100644 --- a/lib/sisu/v2/concordance.rb +++ b/lib/sisu/v2/concordance.rb @@ -191,7 +191,7 @@ WOK @rxp_t1=Regexp.new('^T1') @rxp_t2=Regexp.new('^T2') @rxp_t3=Regexp.new('^T3') - @rxp_excluded1=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ + @rxp_excluded1=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#{@dp}|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! @rgx_splitlist=%r{[—.,;:#{Mx[:nbsp]}-]}mi @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|\w+|[a-zA-Z]+}mi diff --git a/lib/sisu/v2/epub_segments.rb b/lib/sisu/v2/epub_segments.rb index 35edf971..66d73f4f 100644 --- a/lib/sisu/v2/epub_segments.rb +++ b/lib/sisu/v2/epub_segments.rb @@ -181,11 +181,19 @@ WOK SiSU_Screen::Ansi.new(@md.cmd,@@seg_name.length) if @md.cmd =~/[MVv]/ map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map #p map_nametags data.each do |dob| - if defined? dob.obj \ - and dob.obj =~/href="#{Xx[:segment]}#(\S+?)"/ - m=$1 - dob.obj.gsub!(/href="#{Xx[:segment]}#(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) - end + #if defined? dob.obj \ + #and dob.obj =~/href="#{Xx[:segment]}#+\S+?"/ + # ##Consider: remove, reinstate earlier? + # #while dob.obj =~/href="#{Xx[:segment]}#+(\S+?)"/ + # # m=$1 + # # if map_nametags[m][:segname] + # # dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) + # # else + # # p "NOT FOUND name_tags: #{m}" + # # dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#\\1"}) # not satisfactory + # # end + # #end + #end if (dob.is=='heading' or dob.is=='heading_insert') \ and dob.ln==4 if dob.ocn==0 diff --git a/lib/sisu/v2/epub_tune.rb b/lib/sisu/v2/epub_tune.rb index d49ac3c1..9115a14d 100644 --- a/lib/sisu/v2/epub_tune.rb +++ b/lib/sisu/v2/epub_tune.rb @@ -285,7 +285,21 @@ module SiSU_EPUB_Tune link=m[/(.+)/m] png=m.scan(/\S+/)[0].strip link=link.strip - u.gsub!(/(\S+)/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#\\1") if u !~/\// unless http_ + u.sub!(/^#*/,'') #make neater + if map_nametags[u] \ + and map_nametags[u][:segname] + if u=~/^\d+$/ + u.gsub!(/^(\d+)$/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#o\\1") if u !~/\// unless http_ + else + u.gsub!(/(\S+)/,"#{map_nametags[u][:segname]}#{Sfx[:xhtml]}#\\1") if u !~/\// unless http_ + end + elsif u =~/^:/ + u.gsub!(/^:/,"#{@env.url.root}/") + elsif u =~/^\.\.\// + u.gsub!(/^\.\.\//,"#{@env.url.root}/") + elsif u =~/http:\/\// + else p "NOT FOUND name_tags: #{u}" + end ins=%{#{link}} word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins) word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) diff --git a/lib/sisu/v2/html_scroll.rb b/lib/sisu/v2/html_scroll.rb index a5ff9b00..b0581ead 100644 --- a/lib/sisu/v2/html_scroll.rb +++ b/lib/sisu/v2/html_scroll.rb @@ -94,6 +94,7 @@ module SiSU_HTML_scroll and dob.obj =~/Document Information/ #fix no current match @rcdc=true end + dob.obj.gsub!(/href="[a-z0-9._-]+(#\S+?")/m,'href="\1') # internal document links dob.obj.gsub!(/href="#{Xx[:segment]}/m,'href="') dob.obj.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'


') if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]})/ diff --git a/lib/sisu/v2/html_segments.rb b/lib/sisu/v2/html_segments.rb index 83f9c5c9..bed30afa 100644 --- a/lib/sisu/v2/html_segments.rb +++ b/lib/sisu/v2/html_segments.rb @@ -166,9 +166,17 @@ module SiSU_HTML_seg map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map #p map_nametags data.each do |dob| if defined? dob.obj \ - and dob.obj =~/href="#{Xx[:segment]}#(\S+?)"/ - m=$1 - dob.obj.gsub!(/href="#{Xx[:segment]}#(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) + and dob.obj =~/href="#{Xx[:segment]}#+\S+?"/ + while dob.obj =~/href="#{Xx[:segment]}#+(\S+?)"/ + m=$1 + if map_nametags[m] \ + and map_nametags[m][:segname] + dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#{map_nametags[m][:segname]}#{Sfx[:html]}#\\1"}) + else + p "NOT FOUND name_tags: #{m}" + dob.obj.sub!(/href="#{Xx[:segment]}#+(\S+?)"/,%{href="#\\1"}) # not satisfactory + end + end end if (dob.is=='heading' or dob.is=='heading_insert') \ and dob.ln==4 diff --git a/lib/sisu/v2/html_tune.rb b/lib/sisu/v2/html_tune.rb index c0efb72e..11b1dbde 100644 --- a/lib/sisu/v2/html_tune.rb +++ b/lib/sisu/v2/html_tune.rb @@ -255,6 +255,10 @@ module SiSU_HTML_Tune http_=true if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/.match(word).captures + elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}:\S+?#{Mx[:rel_c]}/ + #http_=false + m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/.match(word).captures + u='../' + u elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ http_=false m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/.match(word).captures @@ -326,6 +330,7 @@ module SiSU_HTML_Tune and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ dob.obj.gsub!(/(\.\.\/\S+)/,'\1') end + dob.obj.gsub!(//m,'\1>') #code-block: angle brackets special characters diff --git a/lib/sisu/v2/odf.rb b/lib/sisu/v2/odf.rb index dc8c90a8..24f45f50 100644 --- a/lib/sisu/v2/odf.rb +++ b/lib/sisu/v2/odf.rb @@ -236,7 +236,27 @@ module SiSU_ODF def text_link_odf(txt,url,trail) txt.gsub!(/(\\\+)/,'+') #this is convoluted, and risky :-( url.gsub!(/(\\\+)/,'+') #this is convoluted, and risky :-( - %{#{txt.strip}#{trail}} + map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map + t=case url + when /^http:/ + %{#{txt.strip}#{trail}} + when /^:/ # site same document collection html link + url.gsub!(/^:/,"#{@env.url.root}/") + %{#{txt.strip}#{trail}} + when /^\.\.\// # site same document collection html link + url.gsub!(/^\.\.\//,"#{@env.url.root}/") + %{#{txt.strip}#{trail}} + else # document internal link + if map_nametags[url] \ + and map_nametags[url][:segname] + else p "NOT FOUND name_tags: #{url}" + end + t=map_nametags[url] \ + && map_nametags[url][:segname] \ + ? %{#{txt.strip}#{trail}} \ + : %{#{txt.strip}#{trail}} + end + t end def text_link(dob) m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]})/) #sort @@ -253,6 +273,21 @@ module SiSU_ODF end dob end + def text_link_relative(dob) + m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]})/) #sort + if m + m.each do |i| + txt,url,trail=i[1],i[2] + txt.gsub!(/([)(\]\[])/,"\\\\\\1") + txt.gsub!(/([+?*])/,"\\\\\\1") # problems with + + url.gsub!(/([+?])/,"\\\\\\1") # problems with + + dob.obj.gsub!(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url + dob.obj.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix + end + m=nil + end + dob + end def normal(dob) #P1 - P3 dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, '\1') #http ftp matches escaped, no decoration @@ -268,6 +303,13 @@ module SiSU_ODF end def fontface(dob) end + def footnote_urls(str) + str.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) + str=text_link(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ + str=text_link_relative(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ + str + end def footnote(t_o) str=if defined? t_o.obj; t_o.obj elsif t_o.class==String; t_o @@ -281,6 +323,8 @@ module SiSU_ODF asterisk=str.scan(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/) asterisk.each do |x| a=x[0].gsub(/([*+])/,"\\\\\\1") + str=group_clean(str) + str=footnote_urls(str) str.gsub!(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,%{\\1 \\2}) @astx+=1 end @@ -289,6 +333,8 @@ module SiSU_ODF asterisk=str.scan(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/) asterisk.each do |x| a=x[0].gsub(/([*+])/,"\\\\\\1") + str=group_clean(str) + str=footnote_urls(str) str.gsub!(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,%{\\1 \\2}) @astx+=1 end @@ -362,10 +408,10 @@ module SiSU_ODF def odf_structure(md,dob) @md,@dob=md,dob dob=if dob.is !='code' - dob=if dob.obj =~/#{Mx[:lnk_o]}[ ]*\S+?\.(?:png|jpg|gif)\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/; image(dob) - elsif dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/; text_link(dob) - else dob - end + dob=image(dob) if dob.obj =~/#{Mx[:lnk_o]}[ ]*\S+?\.(?:png|jpg|gif)\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ + dob=text_link(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ + dob=text_link_relative(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ + dob else dob end dob=footnote(dob) diff --git a/lib/sisu/v2/particulars.rb b/lib/sisu/v2/particulars.rb index 96c4fbac..b2f533e1 100644 --- a/lib/sisu/v2/particulars.rb +++ b/lib/sisu/v2/particulars.rb @@ -177,7 +177,8 @@ module SiSU_Particulars attr_accessor :nametags_map def set_nametags_map begin - @nametags_map=SiSU_DAL::Source.new(@md).get_map_nametags + opt=@md ? @md : @opt + @nametags_map=SiSU_DAL::Source.new(opt).get_map_nametags self rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error end diff --git a/lib/sisu/v2/plaintext.rb b/lib/sisu/v2/plaintext.rb index a57339f4..4acdec93 100644 --- a/lib/sisu/v2/plaintext.rb +++ b/lib/sisu/v2/plaintext.rb @@ -299,6 +299,7 @@ WOK dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, "#{Px[:strike_o]}\\1#{Px[:strike_c]}") unless dob.is=='code' + dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1') dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1') dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]') dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]') diff --git a/lib/sisu/v2/shared_html_lite.rb b/lib/sisu/v2/shared_html_lite.rb index 6303691b..c1f53e10 100644 --- a/lib/sisu/v2/shared_html_lite.rb +++ b/lib/sisu/v2/shared_html_lite.rb @@ -62,6 +62,7 @@ module SiSU_Format_Shared include SiSU_Viz class CSS_Format require "#{SiSU_lib}/defaults" # defaults.rb + require "#{SiSU_lib}/particulars" # particulars.rb @@fns=nil def initialize(md,t_o) @md,@t_o=md,t_o @@ -85,10 +86,13 @@ module SiSU_Format_Shared end def urls(data) @words=[] + map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map data.each do |word| - @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ + @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/.match(word).captures + elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ + m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/.match(word).captures elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image/ m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(image)/.match(word).captures end @@ -107,12 +111,27 @@ module SiSU_Format_Shared end word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else + u=case u + when /^http:\/\// + u + when /^:/ + u.gsub!(/^:/,'') + "#{@env.url.root}/#{u}" + when /^\.\.\// # can remove + u.gsub!(/^\.\.\//,'') + "#{@env.url.root}/#{u}" + else + "#{@env.url.root}/#{@md.fnb}/#{map_nametags[u][:segname]}#{Sfx[:html]}##{u}" + end link=m[/(.+)/m] png=m.scan(/\S+/)[0].strip link=link.strip ins=%{#{link}} word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins) + word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) + word end + word else word end word @@ -134,8 +153,8 @@ module SiSU_Format_Shared s=t_o.obj if t_o.is !='code' s=markup_generic(s) - if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)|\S+/) + if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ + wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)|\S+/) words=urls(wm) s.gsub!(/.+/m,words) end @@ -152,8 +171,8 @@ module SiSU_Format_Shared end def markup_note(s) s=markup_generic(s) - if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)|\S+/) + if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ + wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)|\S+/) words=urls(wm) s=s.gsub(/.+/m,words) end diff --git a/lib/sisu/v2/shared_xml.rb b/lib/sisu/v2/shared_xml.rb index 8a58909b..4d504882 100644 --- a/lib/sisu/v2/shared_xml.rb +++ b/lib/sisu/v2/shared_xml.rb @@ -372,6 +372,8 @@ module SiSU_XML_munge dob.obj.gsub!(/href="#{Xx[:segment]}/m,'href="') dob.obj.gsub!(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\.\.\/\S+?)#{Mx[:rel_c]}/, '\1') + dob.obj.gsub!(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/, + '\1') dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/, '\1') dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, diff --git a/lib/sisu/v2/texpdf_format.rb b/lib/sisu/v2/texpdf_format.rb index 1d2e891f..68190407 100644 --- a/lib/sisu/v2/texpdf_format.rb +++ b/lib/sisu/v2/texpdf_format.rb @@ -357,47 +357,53 @@ module SiSU_TeX_Pdf end def url_str_internal(str,idx=nil) map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map #p map_nametags - url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/m - url_relative_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\.\.\/\S+?#{Mx[:rel_c]}/m - url_internal_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}#?\S+?#{Mx[:rel_c]}/m - while str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\.\.\/\S+?)#{Mx[:rel_c]}/m + rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/m + rgx_url_relative=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}:\S+?#{Mx[:rel_c]}/m + rgx_url_internal=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}#?\S+?#{Mx[:rel_c]}/m + while str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/m link,url=$1,$2 link,url=link.strip,url.strip link.gsub!(/&/,"#{Xx[:protect]}&") - url.gsub!(/^(\.\.\/)/,"#{@env.url.root}/") - str.sub!(/#{Mx[:lnk_o]}[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+#{Mx[:lnk_c]}#{Mx[:rel_o]}\.\.\/\S+?#{Mx[:rel_c]}/m,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}") + url="#{@env.url.root}/" + url + str.sub!(/#{Mx[:lnk_o]}[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+#{Mx[:lnk_c]}#{Mx[:rel_o]}:\S+?#{Mx[:rel_c]}/m,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}") end while str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}#?(\S+?)#{Mx[:rel_c]}/m link,url=$1,$2 link,url=link.strip,url.strip link.gsub!(/&/,"#{Xx[:protect]}&") + url.gsub!(/\\_/,'_') + ocn_lnk=if map_nametags[url] \ + and map_nametags[url][:ocn] + map_nametags[url][:ocn] + else nil + end ocn_lnk=(url=~/^\d+$/ ? url : (map_nametags[url][:ocn])) - if not ocn_lnk.empty? + if ocn_lnk and not ocn_lnk.empty? idx \ - ? (str.sub!(url_internal_rgx,"\\hyperlink{#{ocn_lnk}}{#{link}}")) \ - : (str.sub!(url_internal_rgx,"#{@brace_rel.tex_open}\\hyperlink{#{ocn_lnk}}{#{link}}#{@brace_rel.tex_close}")) + ? (str.sub!(rgx_url_internal,"\\hyperlink{#{ocn_lnk}}{#{link}}")) \ + : (str.sub!(rgx_url_internal,"#{@brace_rel.tex_open}\\hyperlink{#{ocn_lnk}}{#{link}}#{@brace_rel.tex_close}")) else puts %{name tag: "#{url}" not found} - str.sub!(url_internal_rgx,"#{link}") + str.sub!(rgx_url_internal,"#{link}") end #[keep] code that follows uses nametags directly, currently nametags converted to their ocn, related code: |texpdf.rb|@|hypertargets| #idx \ - #? (str.sub!(url_internal_rgx,"\\hyperlink{#{url}}{#{link}}")) \ - #: (str.sub!(url_internal_rgx,"#{@brace_rel.tex_open}\\hyperlink{#{url}}{#{link}}#{@brace_rel.tex_close}")) + #? (str.sub!(rgx_url_internal,"\\hyperlink{#{url}}{#{link}}")) \ + #: (str.sub!(rgx_url_internal,"#{@brace_rel.tex_open}\\hyperlink{#{url}}{#{link}}#{@brace_rel.tex_close}")) end str.gsub!(/#{Xx[:protect]}/,'') str end def url_str(str) - url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m - while str =~url_generic_rgx - if str=~url_generic_rgx + rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m + while str =~rgx_url_generic + if str=~rgx_url_generic regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m z,url=regx_url.match(str).captures if str =~regx_url url=url.strip link=z.strip link.gsub!(/&/,"#{Xx[:protect]}&") - str.sub!(url_generic_rgx,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}") + str.sub!(rgx_url_generic,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}") str.gsub!(/#{Xx[:protect]}/,'') str else str @@ -407,9 +413,9 @@ module SiSU_TeX_Pdf str end def url_with_txt(dob) - url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m - while dob.tmp =~url_generic_rgx - if dob.tmp=~url_generic_rgx + rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m + while dob.tmp =~rgx_url_generic + if dob.tmp=~rgx_url_generic if dob.tmp =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m.match(dob.tmp).captures.join @@ -421,7 +427,7 @@ module SiSU_TeX_Pdf url=url.strip link=z.strip link.gsub!(/&/,"#{Xx[:protect]}&") - dob.tmp.sub!(url_generic_rgx,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}#{punctuate}") + dob.tmp.sub!(rgx_url_generic,"#{@brace_rel.tex_open}\\href{#{url}}{#{link}}#{@brace_rel.tex_close}#{punctuate}") dob.tmp.gsub!(/#{Xx[:protect]}/,'') dob else dob @@ -442,18 +448,18 @@ module SiSU_TeX_Pdf } images_hash={ } generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image\b)/m - url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m + rgx_url_generic=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m url_bare_rgx=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m url_image_rgx=/#{Mx[:lnk_o]}[a-zA-Z0-9_\\-]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m image_rgx=/#{Mx[:lnk_o]}[a-zA-Z0-9_\\-]+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}image/m @md.papersize_array.each do |ps| images_hash[ps] = dob.tmp while images_hash[ps] =~generic_rgx - if dob.tmp =~url_generic_rgx \ + if dob.tmp =~rgx_url_generic \ and dob.tmp !~/\.(?:png|jpg|gif)|#{Mx[:lnk_c]}image\b/m dob=url_with_txt(dob) elsif images_hash[ps]=~generic_rgx - if dob.tmp=~url_generic_rgx + if dob.tmp=~rgx_url_generic if images_hash[ps] =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/m punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m.match(images_hash[ps]).captures.join @@ -940,6 +946,7 @@ WOK w.gsub!(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,' \newline ') #watch w.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') #126 usual w.gsub!(/\\?\||#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'<=pipe>') #unless is=='code' #unless w=~/<~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+>/ # | SiSU not really special sisu character but done, also LaTeX + w.gsub!(/\#/,'<=hash>') unless w =~/#{Mx[:rel_o]}/ para_array << w end str=para_array.join(' ') @@ -971,7 +978,6 @@ WOK str.gsub!(/#{Mx[:gl_o]}#124#{Mx[:gl_c]}/,'|') # | SiSU not really special sisu character but done, also LaTeX str.gsub!(/#{Mx[:gl_o]}#058#{Mx[:gl_c]}/,':') # : SiSU not really special sisu character but done, also LaTeX str.gsub!(/#{Mx[:gl_o]}#094#{Mx[:gl_c]}|\^/,'<=caret>') # ^ SiSU not really special sisu character but done, also LaTeX - str.gsub!(/\#/,'<=hash>') ##watch placement, problem sequence ^ str.gsub!(/&atild;<\/font><\/sup>/,' ') str.gsub!(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript @@ -1101,7 +1107,7 @@ WOK def special_word_break_points str=@txt str.gsub!(/([_,.;:\/|=])/,'\1\-') - str.gsub!(/(--)(\S{4,)/,'\1\-\2') + str.gsub!(/(--)(\S{4,})/,'\1\-\2') @txt=str end def special_number_break_points diff --git a/lib/sisu/v2/webrick.rb b/lib/sisu/v2/webrick.rb index 05aac1ee..ff228a65 100644 --- a/lib/sisu/v2/webrick.rb +++ b/lib/sisu/v2/webrick.rb @@ -168,7 +168,9 @@ WOK puts " #{@cX.off}" get=@argv.shift if @argv[0] =~/pwd/ #% argv brick(@port,get) -rescue; SiSU_Errors::Info_error.new($!,$@,'-W',nil).error #fix +rescue; + require "#{SiSU_lib}/sysenv" # sysenv.rb + SiSU_Errors::Info_error.new($!,$@,'-W',nil).error #fix ensure end __END__ -- cgit v1.2.3