diff options
author | Hans Hagen <pragma@wxs.nl> | 2007-09-28 11:58:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2007-09-28 11:58:00 +0200 |
commit | 19af23ac5cb927d986a64ac1dc52ed2d7bad2450 (patch) | |
tree | 2c44222c2581e462afc58122ee79aadf8169316b /scripts/context/ruby | |
parent | 104ea1dae3d609aeb395e19658ad6ea7d4c85eea (diff) | |
download | context-19af23ac5cb927d986a64ac1dc52ed2d7bad2450.tar.gz |
stable 2007.09.28 11:58
Diffstat (limited to 'scripts/context/ruby')
-rw-r--r-- | scripts/context/ruby/base/pdf.rb | 2 | ||||
-rw-r--r-- | scripts/context/ruby/base/tex.rb | 55 | ||||
-rw-r--r-- | scripts/context/ruby/base/texutil.rb | 84 | ||||
-rw-r--r-- | scripts/context/ruby/www/dir.rb | 6 |
4 files changed, 90 insertions, 57 deletions
diff --git a/scripts/context/ruby/base/pdf.rb b/scripts/context/ruby/base/pdf.rb index 9f4e9a6c3..5aec06fc5 100644 --- a/scripts/context/ruby/base/pdf.rb +++ b/scripts/context/ruby/base/pdf.rb @@ -7,7 +7,7 @@ module PDFview @method = 'default' # 'xpdf' - @opencalls['default'] = "pdfopen --file" + @opencalls['default'] = "pdfopen --file" # "pdfopen --back --file" @opencalls['xpdf'] = "xpdfopen" @closecalls['default'] = "pdfclose --file" diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb index ceb9473c0..73b382af9 100644 --- a/scripts/context/ruby/base/tex.rb +++ b/scripts/context/ruby/base/tex.rb @@ -72,6 +72,7 @@ class TEX @@backends = Hash.new @@mappaths = Hash.new @@runoptions = Hash.new + @@tcxflag = Hash.new @@draftoptions = Hash.new @@texformats = Hash.new @@mpsformats = Hash.new @@ -169,13 +170,19 @@ class TEX ['cont-en','cont-nl','cont-de','cont-it', 'cont-fr','cont-cz','cont-ro','cont-uk'] .each do |f| @@texprocstr[f] = "\\emergencyend" end - # @@runoptions['xetex'] = ['--8bit','-output-driver="xdvipdfmx -E -d 4 -V 5 -q"'] - @@runoptions['xetex'] = ['--8bit','-output-driver="xdvipdfmx -E -d 4 -V 5"'] - @@runoptions['pdfetex'] = ['--8bit'] # obsolete - @@runoptions['pdftex'] = ['--8bit'] # pdftex is now pdfetex - @@runoptions['luatex'] = ['--file-line-error'] @@runoptions['aleph'] = ['--8bit'] + @@runoptions['luatex'] = ['--file-line-error'] @@runoptions['mpost'] = ['--8bit'] + @@runoptions['pdfetex'] = ['--8bit'] # obsolete + @@runoptions['pdftex'] = ['--8bit'] # pdftex is now pdfetex + @@runoptions['xetex'] = ['--8bit','-output-driver="xdvipdfmx -E -d 4 -V 5"'] + + @@tcxflag['aleph'] = true + @@tcxflag['luatex'] = false + @@tcxflag['mpost'] = true + @@tcxflag['pdfetex'] = true + @@tcxflag['pdftex'] = true + @@tcxflag['xetex'] = false @@draftoptions['pdftex'] = ['--draftmode'] @@ -540,11 +547,16 @@ class TEX "--ini" end end - def tcxflag(file="natural.tcx") - if Kpse.miktex? then - "-tcx=#{file}" + def tcxflag(engine) + if @@tcxflag[engine] then + file = "natural.tcx" + if Kpse.miktex? then + "-tcx=#{file}" + else + "-translate-file=#{file}" + end else - "-translate-file=#{file}" + "" end end @@ -661,7 +673,7 @@ class TEX texformats.each do |texformat| report("generating tex format #{texformat}") progname = validprogname([getvariable('progname'),texformat,texengine]) - runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag,prefixed(texformat,texengine),texmakeextras(texformat)]) + runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag(texengine),prefixed(texformat,texengine),texmakeextras(texformat)]) end end else @@ -682,7 +694,7 @@ class TEX mpsformats.each do |mpsformat| report("generating mps format #{mpsformat}") progname = validprogname([getvariable('progname'),mpsformat,mpsengine]) - if not runcommand([quoted(mpsengine),prognameflag(progname),iniflag,tcxflag,runoptions(mpsengine),mpsformat,mpsmakeextras(mpsformat)]) then + if not runcommand([quoted(mpsengine),prognameflag(progname),iniflag,tcxflag(mpsengine),runoptions(mpsengine),mpsformat,mpsmakeextras(mpsformat)]) then setvariable('error','no format made') end end @@ -1559,7 +1571,7 @@ end run_luatools("--fmt=#{texformat} #{filename}") else progname = validprogname([getvariable('progname'),texformat,texengine]) - runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag,runoptions(texengine),filename,texprocextras(texformat)]) + runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag(texengine),runoptions(texengine),filename,texprocextras(texformat)]) end # true else @@ -1574,8 +1586,7 @@ end if mpsengine && mpsformat then ENV["MPXCOMMAND"] = "0" unless mpx progname = validprogname([getvariable('progname'),mpsformat,mpsengine]) - runcommand([quoted(mpsengine),prognameflag(progname),formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),mpname,mpsprocextras(mpsformat)]) - # runcommand([quoted(mpsengine),formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),mpname,mpsprocextras(mpsformat)]) + runcommand([quoted(mpsengine),prognameflag(progname),formatflag(mpsengine,mpsformat),tcxflag(mpsengine),runoptions(mpsengine),mpname,mpsprocextras(mpsformat)]) true else false @@ -1790,10 +1801,10 @@ end forcexml = getvariable('forcexml') -if dummyfile || forcexml then # after ctx? - jobsuffix = makestubfile(rawname,rawbase,forcexml) - checkxmlfile(rawname) -end + if dummyfile || forcexml then # after ctx? + jobsuffix = makestubfile(rawname,rawbase,forcexml) + checkxmlfile(rawname) + end # preprocess files @@ -1929,7 +1940,15 @@ end end end # goto . + ok = runtex(File.suffixed(if dummyfile || forcexml then rawbase else rawname end,jobsuffix)) + +if getvariable('texengine') == "xetex" then + ok = true +end + +############################ + # goto tmp/jobname when present if ok && (nofruns > 1) then unless getvariable('nompmode') then diff --git a/scripts/context/ruby/base/texutil.rb b/scripts/context/ruby/base/texutil.rb index 726e31381..9c43f00e9 100644 --- a/scripts/context/ruby/base/texutil.rb +++ b/scripts/context/ruby/base/texutil.rb @@ -400,7 +400,7 @@ class TeXUtil def MyCommands::writer(logger,handle) handle << logger.banner("commands: #{@@commands.size}") @@commands.each do |c| - handle << "#{c}\n" + handle << "#{c}%\n" end end @@ -494,7 +494,7 @@ class TeXUtil end end list.each do |entry| - handle << "\\synonymentry{#{entry.type}}{#{entry.command}}{#{entry.key}}{#{entry.data}}\n" + handle << "\\synonymentry{#{entry.type}}{#{entry.command}}{#{entry.key}}{#{entry.data}}%\n" end end @@ -602,7 +602,7 @@ class TeXUtil end else # @entry, @key = cleanupsplit(@entry), cleanupsplit(@key) -@entry, @key = cleanupsplit(@entry), xcleanupsplit(@key) + @entry, @key = cleanupsplit(@entry), xcleanupsplit(@key) end @sortkey = sorter.simplify(@key) # special = @sortkey =~ /^([^a-zA-Z\\])/o @@ -632,23 +632,23 @@ class TeXUtil end end -def xcleanupsplit(target) # +a+b+c &a&b&c a+b+c a&b&c - t = Array.new - case target[0,1] - when '&' then - t = target.sub(/^./o,'').split(/([^\\])\&/o) - when '+' then - t = target.sub(/^./o,'').split(/([^\\])\+/o) - else - # t = target.split(/([^\\])[\&\+]/o) - # t = target.split(/[\&\+]/o) - t = target.split(/(?!\\)[\&\+]/o) # lookahead - end - if not t[1] then t[1] = " " end # we need some entry else we get subentries first - if not t[2] then t[2] = " " end # we need some entry else we get subentries first - return t.join(@@split) -end - + def xcleanupsplit(target) # +a+b+c &a&b&c a+b+c a&b&c + t = Array.new + case target[0,1] + when '&' then + t = target.sub(/^./o,'').split(/([^\\])\&/o) + when '+' then + t = target.sub(/^./o,'').split(/([^\\])\+/o) + else + # t = target.split(/([^\\])[\&\+]/o) + # t = target.split(/[\&\+]/o) + t = target.split(/(?!\\)[\&\+]/o) # lookahead + end + if not t[1] then t[1] = " " end # we need some entry else we get subentries first + if not t[2] then t[2] = " " end # we need some entry else we get subentries first + if not t[3] then t[3] = " " end # we need some entry else we get subentries first + return t.join(@@split) + end def <=> (other) @sortkey <=> other.sortkey end @@ -661,10 +661,10 @@ end def Register.flushsavedline(handle) if @@collapse && ! @@savedfrom.empty? then if ! @@savedto.empty? then - handle << "\\registerfrom#{@@savedfrom}" - handle << "\\registerto#{@@savedto}" + handle << "\\registerfrom#{@@savedfrom}%" + handle << "\\registerto#{@@savedto}%" else - handle << "\\registerpage#{@@savedfrom}" + handle << "\\registerpage#{@@savedfrom}%" end end @@savedhowto, @@savedfrom, @@savedto, @@savedentry = '', '', '', '' @@ -706,15 +706,15 @@ end elsif alpha == @@specialsymbol then character = @@specialbanner elsif alpha.length > 1 then - # character = "\\getvalue\{#{alpha}\}" - character = "\\#{alpha}" + # character = "\\getvalue\{#{alpha}\}%" + character = "\\#{alpha}%" else character = "\\unknown" end - handle << "\\registerentry{#{entry.type}}{#{character}}\n" + handle << "\\registerentry{#{entry.type}}{#{character}}%\n" end end - current = [entry.entry.split(@@split),'','',''].flatten + current = [entry.entry.split(@@split),'','','',''].flatten howto = current.collect do |e| e + '::' + entry.texthowto end @@ -724,38 +724,51 @@ end previous[0] = howto[0].dup previous[1] = '' previous[2] = '' + previous[3] = '' end if howto[1] == previous[1] then current[1] = '' else previous[1] = howto[1].dup previous[2] = '' + previous[3] = '' end if howto[2] == previous[2] then current[2] = '' else previous[2] = howto[2].dup + previous[3] = '' + end + if howto[3] == previous[3] then + current[3] = '' + else + previous[3] = howto[3].dup end copied = false unless current[0].empty? then Register.flushsavedline(handle) - handle << "\\registerentrya{#{entry.type}}{#{current[0]}}\n" + handle << "\\registerentrya{#{entry.type}}{#{current[0]}}%\n" copied = true end unless current[1].empty? then Register.flushsavedline(handle) - handle << "\\registerentryb{#{entry.type}}{#{current[1]}}\n" + handle << "\\registerentryb{#{entry.type}}{#{current[1]}}%\n" copied = true end unless current[2].empty? then Register.flushsavedline(handle) - handle << "\\registerentryc{#{entry.type}}{#{current[2]}}\n" + handle << "\\registerentryc{#{entry.type}}{#{current[2]}}%\n" + copied = true + end + unless current[3].empty? then + Register.flushsavedline(handle) + handle << "\\registerentryd{#{entry.type}}{#{current[3]}}%\n" copied = true end @nofentries += 1 if copied if entry.realpage.to_i == 0 then Register.flushsavedline(handle) - handle << "\\registersee{#{entry.type}}{#{entry.pagehowto},#{entry.texthowto}}{#{entry.seetoo}}{#{entry.page}}\n" ; + handle << "\\registersee{#{entry.type}}{#{entry.pagehowto},#{entry.texthowto}}{#{entry.seetoo}}{#{entry.page}}%\n" ; lastpage, lastrealpage = entry.page, entry.realpage copied = false # no page ! elsif @@savedhowto != entry.pagehowto and ! entry.pagehowto.empty? then @@ -763,14 +776,14 @@ end end # beware, we keep multiple page entries per realpage because of possible prefix usage if copied || ! ((lastpage == entry.page) && (lastrealpage == entry.realpage)) then - nextentry = "{#{entry.type}}{#{previous[0]}}{#{previous[1]}}{#{previous[2]}}{#{entry.pagehowto},#{entry.texthowto}}" + nextentry = "{#{entry.type}}{#{previous[0]}}{#{previous[1]}}{#{previous[2]}}{#{previous[3]}}{#{entry.pagehowto},#{entry.texthowto}}" savedline = "{#{entry.type}}{#{@@savedhowto},#{entry.texthowto}}{#{entry.location}}{#{entry.page}}{#{entry.realpage}}" if entry.state == 1 then # from Register.flushsavedline(handle) - handle << "\\registerfrom#{savedline}\n" + handle << "\\registerfrom#{savedline}%\n" elsif entry.state == 3 then # to Register.flushsavedline(handle) - handle << "\\registerto#{savedline}\n" + handle << "\\registerto#{savedline}%\n" @@savedhowto = '' # test elsif @@collapse then if savedentry != nextentry then @@ -779,7 +792,7 @@ end savedTo, savedentry = savedline, nextentry end else - handle << "\\registerpage#{savedline}\n" + handle << "\\registerpage#{savedline}%\n" @@savedhowto = '' # test end @nofpages += 1 @@ -1027,6 +1040,7 @@ end begin if f = File.open(File.suffixed(filename,'tuo'),'w') then @plugins.writers(f) + f << "\\endinput\n" f.close end rescue diff --git a/scripts/context/ruby/www/dir.rb b/scripts/context/ruby/www/dir.rb index 09e088d77..115fd8911 100644 --- a/scripts/context/ruby/www/dir.rb +++ b/scripts/context/ruby/www/dir.rb @@ -62,9 +62,9 @@ class WWW end u = dir_uri(@variables.get('path') || '.') str << "<div class='dir-view'>\n<pre>\n" - str << "<a href=\"#{u}&n=#{d1}\">name</A>".ljust(49+u.length) - str << "<a href=\"#{u}&m=#{d1}\">last modified</A>".ljust(41+u.length) - str << "<a href=\"#{u}&s=#{d1}\">size</A>".rjust(31+u.length) << "\n" << "\n" + str << "<a href=\"#{u}&n=#{d1}\">name</a>".ljust(49+u.length) + str << "<a href=\"#{u}&m=#{d1}\">last modified</a>".ljust(41+u.length) + str << "<a href=\"#{u}&s=#{d1}\">size</a>".rjust(31+u.length) << "\n" << "\n" # parent path if showdirs && ! hidden.include?('..') then dname = "parent directory" |