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.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb
index 58a057d8..5c2b7ec5 100644
--- a/lib/sisu/v0/texpdf_format.rb
+++ b/lib/sisu/v0/texpdf_format.rb
@@ -1100,16 +1100,22 @@ WOK
#string.gsub!(/<=lt>/,'\<')
#string.gsub!(/<=gt>/,'\>')
string.gsub!(/<=underscore>/,'\_')
- string.gsub!(/((?:\\href|\\url)\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text
+ while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text
+ string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2')
+ end
string.gsub!(/<=tilde>/,'{$\sim$}')
string.gsub!(/<=pipe>/,'{\textbar}')
string.gsub!(/<=caret>/,'{\^{~}}')
#string.gsub!(/<=caret>/,'\^{}')
string.gsub!(/<=exclaim>/,'\Verbatim{!}')
+ string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text
string.gsub!(/<=hash>/,'{\#}')
#string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}')
#string.gsub!(/<=slash>/,'{\slash}')
string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005
+ while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text
+ string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2')
+ end
string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005
#string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}')
string.gsub!(/<=slash>/,'{/}')
@@ -1202,7 +1208,8 @@ WOK
elsif string=~/#{Mx[:gr_o]}code-end#{Mx[:gr_c]}/; @@flag_code=false
end
if @@flag_code; string.gsub!(/&/,'{\\\&}')
- else string.gsub!(/(\s+&\s+)/,' and ')
+ else string.gsub!(/&/,'<=amp>')
+ #else string.gsub!(/(\s+&\s+)/,' and ')
end
string.gsub!(/§/u,'\S') #latex: space between next character not preserved? #string.gsub!(/§ /,'\S ')
string.gsub!(/£/u,'\pounds')
@@ -1271,16 +1278,22 @@ WOK
#string.gsub!(/<=lt>/,'\<')
#string.gsub!(/<=gt>/,'\>')
string.gsub!(/<=underscore>/,'\_')
- string.gsub!(/((?:\\href|\\url)?\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text
+ while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text
+ string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2')
+ end
string.gsub!(/<=tilde>/,'{$\sim$}')
string.gsub!(/<=pipe>/,'{\textbar}')
string.gsub!(/<=caret>/,'{\^{~}}')
#string.gsub!(/<=caret>/,'\^{}')
string.gsub!(/<=exclaim>/,'\Verbatim{!}')
+ string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text
string.gsub!(/<=hash>/,'{\#}')
#string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}')
#string.gsub!(/<=slash>/,'{\slash}')
string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005
+ while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text
+ string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2')
+ end
string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005
#string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}')
string.gsub!(/<=slash>/,'{/}')