aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/texpdf_format.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v0/texpdf_format.rb')
-rw-r--r--lib/sisu/v0/texpdf_format.rb40
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb
index d86c053a..83fd90a1 100644
--- a/lib/sisu/v0/texpdf_format.rb
+++ b/lib/sisu/v0/texpdf_format.rb
@@ -498,11 +498,11 @@ WOK
@string.gsub!(/&\S+?;/,' ')
@string.gsub!(/<a href=".+?">/,' ')
@string.gsub!(/<\/a>/,' ')
- @string.gsub!(/[^\}>_]((?:https?|ftp):\/\/\S+?)(<\/\S>)/,' \begin{scriptsize}\href{\1}{\1} \end{scriptsize}\2') #special case
- @string.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\begin{scriptsize}\\href{\2}{\2}\end{scriptsize}\3') #special case \{ e.g. \}http://url
- @string.gsub!(/\B(?:\\_|\\)((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\begin{scriptsize}\\href{\1}{\1}\end{scriptsize}\2') #specially escaped url no decoration
+ @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?|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
+ @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}{>}}')
@@ -724,7 +724,7 @@ WOK
else
tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search path: #{dir.path.image_source_tex}")
tell.error2 unless @md.cmd =~/q/
- @string.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+/,'') # fragile match operator\\ fragile !
+ @string.gsub!(/\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile !
end
end
def image
@@ -744,7 +744,7 @@ WOK
nil
end
if image_source
- @string.gsub!(/<:image\s+((?:https?|ftp)\S+)\s+(\S+)\s+.+\s+?>/,
+ @string.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/,
@center_begin + "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{image_source}/\\2}}" + @center_end )
@string.gsub!(/<:image\s+(\S+)\s+.+\s+?>/,
@center_begin + "\\includegraphics*[width=#{width}pt]{#{image_source}/\\1}" + @center_end )
@@ -794,15 +794,15 @@ WOK
dir=SiSU_Env::Info_env.new(@md.fns)
@words=[]
@string.each do |word|
- @words << if word=~/\\\{.+?\\\}(?:https?|ftp):\S+/
- if word =~/\\\{(.+?)\\\}((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/
- r=%r/\\\{(.+?)\\?\}((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/
- d=/\\\{.+?\\?\}(?:https?|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.to_s
-# if word =~/\\\{(.+?)\\\}((?:https?|ftp)\S+?)([;.,]?(?:\s|$))/
-# r=%r/\\\{(.+?)\\?\}((?:https?|ftp):\S+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/
-# d=/\\\{.+?\\?\}(?:https?|ftp):\S+?([;.,]?(?:\s|$))/.match(word).captures.to_s
+ @words << if word=~/\\\{.+?\\\}(?:https?|file|ftp):\S+/
+ if word =~/\\\{(.+?)\\\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/
+ r=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/
+ d=/\\\{.+?\\?\}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.to_s
+# if word =~/\\\{(.+?)\\\}((?:https?|file|ftp)\S+?)([;.,]?(?:\s|$))/
+# r=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/
+# d=/\\\{.+?\\?\}(?:https?|file|ftp):\S+?([;.,]?(?:\s|$))/.match(word).captures.to_s
else
- r=%r/\\\{(.+?)\\?\}((?:https?|ftp):\S+)/
+ r=%r/\\\{(.+?)\\?\}((?:https?|file|ftp):\S+)/
d=''
end
z,url=r.match(word).captures if word =~r
@@ -845,29 +845,29 @@ WOK
"{\\includegraphics*[width=#{width}pt]" +
"{#{dir.path.image_source_local_tex}/#{image}}}" +
"#{caption}" +
- @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+)/
+ @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/
elsif @md.fns =~/\.-ss[tm]$/ and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}")
@center_begin +
"\\\n\\href{#{url}}" + #not satisfactory: \\ added to ^line to mimic reference file output
"{\\includegraphics*[width=#{width}pt]" +
"{#{dir.path.image_source_remote_tex}/#{image}}}" +
"#{caption}" +
- @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+)/
+ @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/
elsif FileTest.file?("#{dir.path.image_source_tex}/#{image}")
@center_begin +
"\\\n\\href{#{url}}\n" + #not satisfactory: \\ added to ^line to mimic reference file output, mirror above ... not tested
"{\\includegraphics*[width=#{width}pt]" +
"{#{dir.path.image_source_tex}/#{image}}}" +
"#{caption}" +
- @center_end if word =~/(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+)/
+ @center_end if word =~/(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/
else
tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search locations: #{dir.path.image_source_local_tex},#{dir.path.image_source_remote_tex} and #{dir.path.image_source_tex}")
tell.error2 unless @md.cmd =~/q/
- '' if word =~ /\{\S+\.(png|jpg|gif).+?\}(?:https?|ftp):\/\/\S+/
+ '' if word =~ /\{\S+\.(png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+/
end
else
link=z.strip #[/(.+?)\\/m,1]
- word="\\href{#{url}}{#{link}}#{d}" if word =~/\\\{.+?\\\}(?:https?|ftp):\/\/\S+/
+ word="\\href{#{url}}{#{link}}#{d}" if word =~/\\\{.+?\\\}(?:https?|file|ftp):\/\/\S+/
end
else word
end
@@ -875,7 +875,7 @@ WOK
@words.join
end
def http(orientation)
- wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|ftp):\S+|image)|\w+\s*|./m) #first match of interest others passed through
+ wm=@string.dup.scan(/\\\{.+?\\\}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) #first match of interest others passed through
@string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm).http_word_mode(orientation)
end
def language