summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2006-08-04 22:23:00 +0200
committerHans Hagen <pragma@wxs.nl>2006-08-04 22:23:00 +0200
commitf0bcd1905465b37aea4513fe0b256e13db1af9fe (patch)
treee641ead8fb0bd21efd8fd89b93a8ec2b03e23527 /scripts
parent4238f3b0f961c9c01da723d16156630f9136da1f (diff)
downloadcontext-f0bcd1905465b37aea4513fe0b256e13db1af9fe.tar.gz
stable 2006.08.04 22:23
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/perl/texshow.pl72
-rw-r--r--scripts/context/ruby/base/tex.rb2
-rw-r--r--scripts/context/ruby/ctxtools.rb77
3 files changed, 106 insertions, 45 deletions
diff --git a/scripts/context/perl/texshow.pl b/scripts/context/perl/texshow.pl
index 772d4db84..629c28f99 100644
--- a/scripts/context/perl/texshow.pl
+++ b/scripts/context/perl/texshow.pl
@@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' && eval 'exec perl -w -
#D \module
#D [ file=texshow.pl,
-#D version=2006.07.19,
+#D version=2006.08.04,
#D title=TeXShow,
#D subtitle=showing \CONTEXT\ commands,
#D author=Taco Hoekwater,
@@ -27,6 +27,7 @@ eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' && eval 'exec perl -w -
#D ChangeLog:
#D \startitemize
#D \item Add keyboard bindings for quitting the app: Ctrl-q,Ctrl-x,Alt-F4 (2006/07/19)
+#D \item Support for define --resolve (2006/08/04)
#D \stopitemize
use strict;
@@ -68,7 +69,7 @@ my %crosslinks;
print "\n";
-show('TeXShow-XML 0.21 beta','Taco Hoekwater 2006',"/");
+show('TeXShow-XML 0.3 beta','Taco Hoekwater 2006',"/");
print "\n";
@@ -322,41 +323,50 @@ sub setups_found {
sub load_setup {
my ($path,$filename) = @_;
+ my $localdefs = {};
unless (keys %{$setups{$filename}}) {
if (open(IN,"<${path}$filename.xml")) {
my $position = 0 ;
local $/ = '</cd:command>';
while (my $data= <IN>) {
- if ($data =~ /\<\/cd:interface/) {
- next;
- }
- if ($data =~ /\<cd:interface/) {
- $data =~ s/^(.*?)\<cd:command/\<cd:command/sm;
- my $meta = $1;
- }
- #
- $data =~ s/\s*\n\s*//g;
- $data =~ /\<cd:command(.*?)\>/;
- my $info = $1;
- my ($name,$environment) = ('','');
- while ($info =~ s/^\s*(.*?)\s*=\s*(["'])(.*?)\2\s*//) {
- my $a = $1; my $b = $3;
- if ($a eq 'name') {
- $name = $b;
- } elsif ($a eq 'type') {
- $environment = $b;
+ next if $data =~ /\<\/cd:interface/;
+ if ($data =~ /\<cd:interface/) {
+ $data =~ s/^(.*?)\<cd:command/\<cd:command/sm;
+ my $meta = $1;
+ while ($meta =~ s!<cd:define name=(['"])(.*?)\1>(.*?)</cd:define>!!sm) {
+ my $localdef = $2;
+ my $localval = $3;
+ $localdefs->{$localdef} = $localval;
+ }
+ }
+ #
+ if (keys %$localdefs) {
+ while ($data =~ /<cd:resolve/) {
+ $data =~ s/<cd:resolve name=(['"])(.*?)\1\/>/$localdefs->{$2}/ms;
+ }
+ }
+ $data =~ s/\s*\n\s*//g;
+ $data =~ /\<cd:command(.*?)\>/;
+ my $info = $1;
+ my ($name,$environment) = ('','');
+ while ($info =~ s/^\s*(.*?)\s*=\s*(["'])(.*?)\2\s*//) {
+ my $a = $1; my $b = $3;
+ if ($a eq 'name') {
+ $name = $b;
+ } elsif ($a eq 'type') {
+ $environment = $b;
+ }
+ }
+ my $cmd = $name;
+ if ($environment) {
+ $cmd = "start" . $name;
+ }
+ $setups {$filename}{$cmd} = $data ;
+ $trees {$filename}{$cmd} = undef;
+ $positions {$filename}{$cmd} = ++$position ;
+ $crosslinks{$filename}[$position] = $cmd ;
}
- }
- my $cmd = $name;
- if ($environment) {
- $cmd = "start" . $name;
- }
- $setups {$filename}{$cmd} = $data ;
- $trees {$filename}{$cmd} = undef;
- $positions {$filename}{$cmd} = ++$position ;
- $crosslinks{$filename}[$position] = $cmd ;
- }
- close IN;
+ close IN;
# now get explanations as well ...
my $explname = $filename;
$explname =~ s/cont-/expl-/;
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index da94eee21..5e357e6d7 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -1232,7 +1232,7 @@ class TEX
arrangement << "\\v!doublesided" unless getvariable('noduplex')
case getvariable('printformat')
when '' then arrangement << "\\v!normal"
- when /.*up/oi then arrangement << "\\v!rotated"
+ when /.*up/oi then arrangement << ["2UP","\\v!rotated"]
when /.*down/oi then arrangement << ["2DOWN","\\v!rotated"]
when /.*side/oi then arrangement << ["2SIDE","\\v!rotated"]
end
diff --git a/scripts/context/ruby/ctxtools.rb b/scripts/context/ruby/ctxtools.rb
index 48bce8146..0cf96e10d 100644
--- a/scripts/context/ruby/ctxtools.rb
+++ b/scripts/context/ruby/ctxtools.rb
@@ -659,7 +659,7 @@ class Commands
str.chomp!
str.sub!(/\s*$/o, '')
case str
- when /^[%\#]D/io then
+ when /^[%\#]D($| )/io then
if skiplevel == 0 then
someline = if str.length < 3 then "" else str[3,str.length-1] end
if indocument then
@@ -677,7 +677,7 @@ class Commands
nofdocuments += 1
end
end
- when /^[%\#]M/io then
+ when /^[%\#]M($| )/io then
if skiplevel == 0 then
someline = if str.length < 3 then "" else str[3,str.length-1] end
ted.puts("#{someline}\n")
@@ -866,9 +866,11 @@ class Language
preload_accents()
preload_unicode() if @commandline.option('utf8')
case @encoding.downcase
- when 't1', 'ec', 'cork' then preload_vector('ec')
- when 'y', 'texnansi' then preload_vector('texnansi')
- when 'agr', 'agreek' then preload_vector('agr')
+ when 't1', 'ec', 'cork' then preload_vector('ec', 'enco-ec.tex')
+ when 'y', 'texnansi' then preload_vector('texnansi', 'enco-ans.tex')
+ when 'agr', 'agreek' then preload_vector('agr', 'enco-agr.tex')
+ when 't2a' then preload_vector('t2a', 'enco-cyr.tex')
+ when 'cyr' then preload_vector() # somehow loading t2a does not work out well
end
end
@@ -1242,7 +1244,7 @@ class Language
end
- def preload_vector(encoding='')
+ def preload_vector(encoding='', filename='')
# funny polish
@@ -1478,19 +1480,66 @@ class Language
remap(/x/, "[greekxi]")
remap(/y/, "[greekpsi]")
remap(/z/, "[greekzeta]")
+ when 'ru' then
+ remap(/\xC1/, "[cyrillica]")
+ remap(/\xC2/, "[cyrillicb]")
+ remap(/\xD7/, "[cyrillicv]")
+ remap(/\xC7/, "[cyrillicg]")
+ remap(/\xC4/, "[cyrillicd]")
+ remap(/\xC5/, "[cyrillice]")
+ remap(/\xD6/, "[cyrilliczh]")
+ remap(/\xDA/, "[cyrillicz]")
+ remap(/\xC9/, "[cyrillici]")
+ remap(/\xCA/, "[cyrillicishrt]")
+ remap(/\xCB/, "[cyrillick]")
+ remap(/\xCC/, "[cyrillicl]")
+ remap(/\xCD/, "[cyrillicm]")
+ remap(/\xCE/, "[cyrillicn]")
+ remap(/\xCF/, "[cyrillico]")
+ remap(/\xD0/, "[cyrillicp]")
+ remap(/\xD2/, "[cyrillicr]")
+ remap(/\xD3/, "[cyrillics]")
+ remap(/\xD4/, "[cyrillict]")
+ remap(/\xD5/, "[cyrillicu]")
+ remap(/\xC6/, "[cyrillicf]")
+ remap(/\xC8/, "[cyrillich]")
+ remap(/\xC3/, "[cyrillicc]")
+ remap(/\xDE/, "[cyrillicch]")
+ remap(/\xDB/, "[cyrillicsh]")
+ remap(/\xDD/, "[cyrillicshch]")
+ remap(/\xDF/, "[cyrillichrdsn]")
+ remap(/\xD9/, "[cyrillicery]")
+ remap(/\xD8/, "[cyrillicsftsn]")
+ remap(/\xDC/, "[cyrillicerev]")
+ remap(/\xC0/, "[cyrillicyu]")
+ remap(/\xD1/, "[cyrillicya]")
+ remap(/\xA3/, "[cyrillicyo]")
else
end
if ! encoding.empty? then
begin
- filename = `kpsewhich -progname=context enco-#{encoding}.tex`
- if data = IO.read(filename.chomp) then
+ filename = `kpsewhich -progname=context #{filename}`
+ if data = IO.readlines(filename.chomp) then
report("preloading #{encoding} character mappings")
- data.scan(/\\definecharacter\s*([a-zA-Z]+)\s*(\d+)\s*/o) do
- name, number = $1, $2
- remap(/\^\^#{sprintf("%02x",number)}/, "[#{name}]")
- if number.to_i > 127 then
- remap(/#{sprintf("\\%03o",number)}/, "[#{name}]")
+ accept = false
+ data.each do |line|
+ case line.chomp
+ when /\\start(en|)coding\s*\[(.*?)\]/io then
+ enc = $2
+ if accept = (enc == encoding) then
+ report("accepting vector #{enc}")
+ else
+ report("skipping vector #{enc}")
+ end
+ when /\\stop(en|)coding/io then
+ accept = false
+ when accept && /\\definecharacter\s*([a-zA-Z]+)\s*(\d+)\s*/o then
+ name, number = $1, $2
+ remap(/\^\^#{sprintf("%02x",number)}/, "[#{name}]")
+ if number.to_i > 127 then
+ remap(/#{sprintf("\\%03o",number)}/, "[#{name}]")
+ end
end
end
end
@@ -1568,6 +1617,8 @@ class Commands
@@languagedata['sv' ] = [ 'ec' , ['svhyph.tex'] ]
@@languagedata['tr' ] = [ 'ec' , ['tkhyph.tex'] ]
@@languagedata['uk' ] = [ 'default' , [['ukhyphen.tex','ukhyph.tex']] ]
+ # @@languagedata['ru' ] = [ 't2a' , ['ruhyphal.tex'] ] # t2a does not work
+ @@languagedata['ru' ] = [ 'cyr' , ['ruhyphal.tex'] ]
end
class Commands