summaryrefslogtreecommitdiff
path: root/scripts/context/ruby/base
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/context/ruby/base')
-rw-r--r--scripts/context/ruby/base/tex.rb29
-rw-r--r--scripts/context/ruby/base/texutil.rb23
2 files changed, 31 insertions, 21 deletions
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 382b5aa73..e2013b87e 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -126,7 +126,7 @@ class TEX
'mpyforce', 'forcempy',
'forcetexutil', 'texutil',
'globalfile', 'autopath',
- 'purge', 'autopdf', 'simplerun', 'verbose',
+ 'purge', 'purgeall', 'autopdf', 'simplerun', 'verbose',
]
@@stringvars = [
'modefile', 'result', 'suffix', 'response', 'path',
@@ -767,15 +767,19 @@ class TEX
xml.each do |line|
if line =~ /<[a-z]+/io then
break
- elsif line =~ /<\?context\-directive\s+(.+?)\s+(.+?)\s+(.+?)\s*\?>/o then
- category, key, value = $1, $2, $3
+ elsif line =~ /<\?context\-directive\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*?)\s*\?>/o then
+ category, key, value, rest = $1, $2, $3, $4
case category
when 'job' then
case key
+ when 'control' then
+ setvariable(value,if rest.empty? then true else rest end)
+ when 'mode', 'modes' then
+ tmp << "\\enablemode[#{value}]\n"
when 'stylefile', 'environment' then
- tmp << "\\environment $value\n"
+ tmp << "\\environment #{value}\n"
when 'module' then
- tmp << "\\usemodule[$value]\n"
+ tmp << "\\usemodule[#{value}]\n"
when 'interface' then
contextinterface = value
end
@@ -1260,7 +1264,8 @@ class TEX
end
end
- Kpse.runscript('ctxtools',jobname,'--purge') if getvariable('purge')
+ Kpse.runscript('ctxtools',jobname,'--purge') if getvariable('purge')
+ Kpse.runscript('ctxtools',jobname,'--purgeall') if getvariable('purgeall')
when 'latex' then
@@ -1272,13 +1277,15 @@ class TEX
end
- begin
- File.delete(File.suffixed(jobname,jobsuffix)) if dummyfile || forcexml
- rescue
- report("unable to delete stub file")
+ if (dummyfile or forcexml) and FileTest.file?(File.suffixed(jobname,jobsuffix)) then
+ begin
+ File.delete(File.suffixed(jobname,jobsuffix))
+ rescue
+ report("unable to delete stub file")
+ end
end
- if ok && getvariable('autopdf') then
+ if ok and getvariable('autopdf') then
PDFview.open(File.suffixed(if result.empty? then jobname else result end,'pdf'))
end
diff --git a/scripts/context/ruby/base/texutil.rb b/scripts/context/ruby/base/texutil.rb
index 8a40627d3..083e11bdb 100644
--- a/scripts/context/ruby/base/texutil.rb
+++ b/scripts/context/ruby/base/texutil.rb
@@ -738,17 +738,20 @@ class TeXUtil
def loaded(filename)
begin
report("parsing file #{filename}")
- File.open(File.suffixed(filename,'tui')).each do |line|
- case line.chomp
- when /^f (.*)$/o then @plugins.reader('MyFiles', $1.splitdata)
- when /^c (.*)$/o then @plugins.reader('MyCommands', [$1])
- when /^e (.*)$/o then @plugins.reader('MyExtras', $1.splitdata)
- when /^s (.*)$/o then @plugins.reader('MySynonyms', $1.splitdata)
- when /^r (.*)$/o then @plugins.reader('MyRegisters',$1.splitdata)
- when /^p (.*)$/o then @plugins.reader('MyPlugins', $1.splitdata)
- when /^x (.*)$/o then @plugins.reader('MyKeys', $1.splitdata)
- else report("unknown entry #{line[0,1]} in line #{line.chomp}")
+ if f = open(File.suffixed(filename,'tui')) then
+ f.each do |line|
+ case line.chomp
+ when /^f (.*)$/o then @plugins.reader('MyFiles', $1.splitdata)
+ when /^c (.*)$/o then @plugins.reader('MyCommands', [$1])
+ when /^e (.*)$/o then @plugins.reader('MyExtras', $1.splitdata)
+ when /^s (.*)$/o then @plugins.reader('MySynonyms', $1.splitdata)
+ when /^r (.*)$/o then @plugins.reader('MyRegisters',$1.splitdata)
+ when /^p (.*)$/o then @plugins.reader('MyPlugins', $1.splitdata)
+ when /^x (.*)$/o then @plugins.reader('MyKeys', $1.splitdata)
+ else report("unknown entry #{line[0,1]} in line #{line.chomp}")
+ end
end
+ f.close
end
rescue
report("fatal error in parsing #{filename}")