summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/context/ruby/ctxtools.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby/ctxtools.rb')
-rw-r--r--Master/texmf-dist/scripts/context/ruby/ctxtools.rb108
1 files changed, 83 insertions, 25 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/ctxtools.rb b/Master/texmf-dist/scripts/context/ruby/ctxtools.rb
index b306ee5dc43..00d2b494bb0 100644
--- a/Master/texmf-dist/scripts/context/ruby/ctxtools.rb
+++ b/Master/texmf-dist/scripts/context/ruby/ctxtools.rb
@@ -44,7 +44,7 @@
# it cannot do that (it tries to hyphenate as if the "ffi" was a
# character), and the result is wrong hyphenation.
-banner = ['CtxTools', 'version 1.3.3', '2004/2006', 'PRAGMA ADE/POD']
+banner = ['CtxTools', 'version 1.3.5', '2004/2008', 'PRAGMA ADE']
$: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq!
@@ -334,7 +334,7 @@ class Commands
report("generating #{keyfile}")
begin
- one = "texexec --make --alone --all #{interface}"
+ one = "texexec --make --all #{interface}"
two = "texexec --batch --silent --interface=#{interface} x-set-01"
if @commandline.option("force") then
system(one)
@@ -534,7 +534,7 @@ class Commands
]
$dontasksuffixes = [
"mp(graph|run)\\.mp", "mp(graph|run)\\.mpd", "mp(graph|run)\\.mpo", "mp(graph|run)\\.mpy",
- "mp(graph|run)\\.\\d+",
+ "mp(graph|run)\\.\\d+", "mp(graph|run)\\.mp.keep",
"xlscript\\.xsl"
]
$forsuresuffixes = [
@@ -866,6 +866,7 @@ class Language
@filenames = filenames
@remapping = Array.new
@demapping = Array.new
+ @cloning = Array.new
@unicode = Hash.new
@encoding = encoding
@data = ''
@@ -895,6 +896,9 @@ class Language
def demap(from, to)
@demapping.push([from,to])
end
+ def clone(from, to)
+ @cloning.push([from,to])
+ end
def load(filenames=@filenames)
found = false
@@ -908,7 +912,7 @@ class Language
@data += data.gsub(/\%.*$/, '').gsub(/\\message\{.*?\}/, '')
data.gsub!(/(\\patterns|\\hyphenation)\s*\{.*/mo) do '' end
@read += "\n% preamble of file #{fname}\n\n#{data}\n"
- @data.gsub!(/^[\s\n]+$/mois, '')
+ @data.gsub!(/^[\s\n]+$/moi, '')
report("file #{fname} is loaded")
found = true
break # next fileset
@@ -957,6 +961,22 @@ class Language
@remapping[$1.to_i][1]
end
report(" nothing remapped") unless done
+ @cloning.each_index do |i|
+ c = 0
+ f, s = @cloning[i][0], @cloning[i][1]
+ str = "#{f}|#{s}"
+ str.gsub!(/([\[\]])/) do "\\" + "#{$1}" end
+ reg = /(#{str})/
+ content.gsub!(/(\S*(#{str})\S*)/) do
+ a, b = $1, $1
+ a.gsub!(reg, f)
+ b.gsub!(reg, s)
+ c = c + 1
+ "#{a} #{b}"
+ end
+ report("#{c.to_s.rjust(5)} times #{f} cloned to #{s}")
+ n += c
+ end
report("")
content.to_s
end
@@ -1300,6 +1320,14 @@ class Language
remap(/\\a\s*/, "[aeligature]")
remap(/\\o\s*/, "[oeligature]")
when 'agr' then
+ # bug fix
+ remap("a2|", "[greekalphaiotasub]")
+ remap("h2|", "[greeketaiotasub]")
+ remap("w2|", "[greekomegaiotasub]")
+ remap(">2r1<2r", "[2ῤ1ῥ]")
+ remap(">a2n1wdu'", "[ἀ2ν1ωδύ]")
+ remap(">e3s2ou'", "[ἐ3σ2ού]")
+ # main conversion
remap(/\<\'a\|/, "[greekalphaiotasubdasiatonos]")
# remap(/\<\'a\|/, "[greekdasiatonos][greekAlpha][greekiota]")
remap(/\>\'a\|/, "[greekalphaiotasubpsilitonos]")
@@ -1399,7 +1427,7 @@ class Language
remap(/\<\'u/, "[greekupsilondasiatonos]")
remap(/\>\'u/, "[greekupsilonpsilitonos]")
remap(/\<\`u/, "[greekupsilondasiavaria]")
- remap(/\>\'u/, "[greekupsilonpsilivaria]")
+ remap(/\>\`u/, "[greekupsilonpsilivaria]")
remap(/\<\~u/, "[greekupsilondasiaperispomeni]")
remap(/\>\~u/, "[greekupsilonpsiliperispomeni]")
remap(/\"\'u/, "[greekupsilondialytikatonos]")
@@ -1433,14 +1461,15 @@ class Language
remap(/\"\'/, "[greekdialytikatonos]")
remap(/\"\`/, "[greekdialytikavaria]")
remap(/\"\~/, "[greekdialytikaperispomeni]")
- remap(/\</, "[dasia]")
- remap(/\>/, "[psili]")
- remap(/\'/, "[oxia]")
+ remap(/\</, "[greekdasia]")
+ remap(/\>/, "[greekpsili]")
+ remap(/\d.{0,2}''/, "")
+ remap(/\'/, "[greekoxia]")
remap(/\`/, "[greekvaria]")
remap(/\~/, "[perispomeni]")
- remap(/\"/, "[dialytika]")
+ remap(/\"/, "[greekdialytika]")
# unknown
- remap(/\|/, "[greekIotadialytika]")
+ # remap(/\|/, "[greekIotadialytika]")
# next
remap(/A/, "[greekAlpha]")
remap(/B/, "[greekBeta]")
@@ -1491,6 +1520,13 @@ class Language
remap(/x/, "[greekxi]")
remap(/y/, "[greekpsi]")
remap(/z/, "[greekzeta]")
+ clone("[greekalphatonos]", "[greekalphaoxia]")
+ clone("[greekepsilontonos]", "[greekepsilonoxia]")
+ clone("[greeketatonos]", "[greeketaoxia]")
+ clone("[greekiotatonos]", "[greekiotaoxia]")
+ clone("[greekomicrontonos]", "[greekomicronoxia]")
+ clone("[greekupsilontonos]", "[greekupsilonoxia]")
+ clone("[greekomegatonos]", "[greekomegaoxia]")
when 'ru' then
remap(/\xC1/, "[cyrillica]")
remap(/\xC2/, "[cyrillicb]")
@@ -1602,14 +1638,14 @@ class Commands
@@languagedata['da' ] = [ 'ec' , ['dkspecial.tex','dkcommon.tex'] ]
# elhyph.tex
@@languagedata['es' ] = [ 'ec' , ['eshyph.tex'] ]
- @@languagedata['fi' ] = [ 'ec' , ['ethyph.tex'] ]
+ @@languagedata['et' ] = [ 'ec' , ['ethyph.tex'] ]
@@languagedata['fi' ] = [ 'ec' , ['fihyph.tex'] ]
@@languagedata['fr' ] = [ 'ec' , ['frhyph.tex'] ]
# ghyphen.readme ghyph31.readme grphyph
@@languagedata['hr' ] = [ 'ec' , ['hrhyph.tex'] ]
@@languagedata['hu' ] = [ 'ec' , ['huhyphn.tex'] ]
- @@languagedata['en' ] = [ 'default' , ['ushyphmax.tex'],['ushyph.tex'],['hyphen.tex'] ]
- @@languagedata['us' ] = [ 'default' , ['ushyphmax.tex'],['ushyph.tex'],['hyphen.tex'] ]
+ @@languagedata['en' ] = [ 'default' , [['ushyphmax.tex'],['ushyph.tex'],['hyphen.tex']] ]
+ @@languagedata['us' ] = [ 'default' , [['ushyphmax.tex'],['ushyph.tex'],['hyphen.tex']] ]
# inhyph.tex
@@languagedata['is' ] = [ 'ec' , ['ishyph.tex'] ]
@@languagedata['it' ] = [ 'ec' , ['ithyph.tex'] ]
@@ -1617,12 +1653,12 @@ class Commands
# mnhyph
@@languagedata['nl' ] = [ 'ec' , ['nehyph96.tex'] ]
# @@languagedata['no' ] = [ 'ec' , ['nohyphbx.tex'],['nohyphb.tex'],['nohyph2.tex'],['nohyph1.tex'],['nohyph.tex'] ]
- @@languagedata['no' ] = [ 'ec' , ['asxsx.tex','nohyphbx.tex'],['nohyphb.tex'],['nohyph2.tex'],['nohyph1.tex'],['nohyph.tex'] ]
- @@languagedata['agr'] = [ 'agr' , [['grahyph4.tex','oldgrhyph.tex']] ] # new, todo
+ @@languagedata['no' ] = [ 'ec' , [['asxsx.tex','nohyphbx.tex'],['nohyphb.tex'],['nohyph2.tex'],['nohyph1.tex'],['nohyph.tex']] ]
+ @@languagedata['agr'] = [ 'agr' , [['grahyph4.tex'], ['oldgrhyph.tex']] ] # new, todo
@@languagedata['pl' ] = [ 'ec' , ['plhyph.tex'] ]
@@languagedata['pt' ] = [ 'ec' , ['pthyph.tex'] ]
@@languagedata['ro' ] = [ 'ec' , ['rohyph.tex'] ]
- @@languagedata['sl' ] = [ 'ec' , ['sihyph.tex'] ]
+ @@languagedata['sl' ] = [ 'ec' , [['slhyph.tex'], ['sihyph.tex']] ]
@@languagedata['sk' ] = [ 'ec' , ['skhyphen.tex','skhyphen.ex'] ]
# sorhyph.tex / upper sorbian
# srhyphc.tex / cyrillic
@@ -1639,19 +1675,22 @@ class Commands
def dpxmapfiles
- force = @commandline.option("force")
+ force = @commandline.option("force")
texmfroot = @commandline.argument('first')
texmfroot = '.' if texmfroot.empty?
- maproot = "#{texmfroot.gsub(/\\/,'/')}/fonts/map/pdftex/context"
-
+ if @commandline.option('maproot') != "" then
+ maproot = @commandline.option('maproot')
+ else
+ maproot = "#{texmfroot.gsub(/\\/,'/')}/fonts/map/pdftex/context"
+ end
if File.directory?(maproot) then
files = Dir.glob("#{maproot}/*.map")
if files.size > 0 then
files.each do |pdffile|
next if File.basename(pdffile) == 'pdftex.map'
pdffile = File.expand_path(pdffile)
- dpxfile = File.expand_path(pdffile.sub(/pdftex/i,'dvipdfm'))
+ dpxfile = File.expand_path(pdffile.sub(/(dvips|pdftex)/i,'dvipdfm'))
unless pdffile == dpxfile then
begin
if data = File.read(pdffile) then
@@ -1737,7 +1776,7 @@ class Array
def add_shebang(filename,program)
unless self[0] =~ /^\#/ then
- self.insert(0,"\#!/usr/env #{program}")
+ self.insert(0,"\#!/usr/bin/env #{program}")
end
unless self[2] =~ /^\#.*?copyright\=/ then
self.insert(1,"\#")
@@ -2238,7 +2277,7 @@ class TexDeps
report('')
n = 0
@files.each do |filename|
- if f = File.open(filename) then
+ if File.file?(filename) and f = File.open(filename) then
defs, uses, l = 0, 0, 0
n += 1
report("#{n.to_s.rjust(5,' ')} #{filename}")
@@ -2592,7 +2631,17 @@ class Commands
def fetchfile(site, name, target=nil)
begin
- http = Net::HTTP.new(site)
+ proxy = @commandline.option('proxy')
+ if proxy && ! proxy.empty? then
+ address, port = proxy.split(":")
+ if address && port then
+ http = Net::HTTP::Proxy(address, port).new(site)
+ else
+ http = Net::HTTP::Proxy(proxy, 80).new(site)
+ end
+ else
+ http = Net::HTTP.new(site)
+ end
resp, data = http.get(name.gsub(/^\/*/, '/'))
rescue
return false
@@ -2640,7 +2689,14 @@ class Commands
end
def remakeformats
- return system("texmfstart texexec --make --all")
+ system("mktexlsr")
+ system("luatools --selfupdate")
+ system("mtxrun --selfupdate")
+ system("luatools --generate")
+ system("texmfstart texexec --make --all --fast --pdftex")
+ system("texmfstart texexec --make --all --fast --luatex")
+ system("texmfstart texexec --make --all --fast --xetex")
+ return true
end
if localtree = locatedlocaltree then
@@ -2693,11 +2749,13 @@ commandline.registeraction('listentities' , 'create doctype entity definiti
commandline.registeraction('brandfiles' , 'add context copyright notice [--force]')
commandline.registeraction('platformize' , 'replace line-endings [--recurse --force] [pattern]')
commandline.registeraction('dependencies' , 'analyze depedencies within context [--save --compact --filter=[macros|filenames]] [filename]')
-commandline.registeraction('updatecontext' , 'download latest version and remake formats')
+commandline.registeraction('updatecontext' , 'download latest version and remake formats [--proxy]')
commandline.registeraction('disarmutfbom' , 'remove utf bom [--force]')
commandline.registervalue('type','')
commandline.registervalue('filter','')
+commandline.registervalue('maproot','')
+commandline.registervalue('proxy','')
commandline.registerflag('recurse')
commandline.registerflag('force')