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.rb20
1 files changed, 10 insertions, 10 deletions
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!(/<a href=".+?">/,' ')
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 <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}{<}}')
@@ -1100,7 +1100,7 @@ WOK
#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!(/((?:\\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!(/<a href=".+?">/,' ')
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 <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}{<}}')
@@ -1271,7 +1271,7 @@ WOK
#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!(/((?:\\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>/,'{\^{~}}')