aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v2/texpdf_format.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v2/texpdf_format.rb')
-rw-r--r--lib/sisu/v2/texpdf_format.rb56
1 files changed, 31 insertions, 25 deletions
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!(/<sup><font face=symbol>&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