lib/scripts/update_sub_sup
author wenzelm
Thu Nov 13 23:45:15 2014 +0100 (2014-11-13)
changeset 58999 ed09ae4ea2d8
parent 52921 0ea2b657eb42
permissions -rwxr-xr-x
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
discontinued obsolete 'txt_raw' (superseded by 'text_raw');
eliminated obsolete Outer_Syntax.markup (superseded by keyword kinds);
'text' and 'txt' no longer appear in Sidekick tree due to change of keyword kind;
changed tagging of diagnostic commands within proof;
     1 #!/usr/bin/env perl
     2 #
     3 # Author: Makarius
     4 #
     5 # update_sub_sup - update Isabelle symbols involving sub/superscripts
     6 
     7 use warnings;
     8 use strict;
     9 
    10 sub update_sub_sup {
    11     my ($file) = @_;
    12 
    13     open (FILE, $file) || die $!;
    14     undef $/; my $text = <FILE>; $/ = "\n";         # slurp whole file
    15     close FILE || die $!;
    16 
    17     $_ = $text;
    18 
    19     s/\Q\<^isub>\E/\\<^sub>/g;
    20     s/\Q\<^isup>\E/\\<^sup>/g;
    21     s/\Q\<onesuperior>\E/\\<^sup>1/g;
    22     s/\Q\<twosuperior>\E/\\<^sup>2/g;
    23     s/\Q\<threesuperior>\E/\\<^sup>3/g;
    24 
    25     my $result = $_;
    26 
    27     if ($text ne $result) {
    28         print STDERR "changing $file\n";
    29         if (! -f "$file~~") {
    30             rename $file, "$file~~" || die $!;
    31         }
    32         open (FILE, "> $file") || die $!;
    33         print FILE $result;
    34         close FILE || die $!;
    35     }
    36 }
    37 
    38 
    39 ## main
    40 
    41 foreach my $file (@ARGV) {
    42   eval { &update_sub_sup($file); };
    43   if ($@) { print STDERR "*** update_sub_sup $file: ", $@, "\n"; }
    44 }