#!/usr/bin/perl use utf8; # FRE: Je ne me souviens plus si cette instruction est nécessaire... # ENG: I do not remember more if this instruction is necessary... ############################################################################## ############################################################################## ## ENG: ? ######################################################### ## FRE: Esplications ######################################################### # # ENG: Installation: do not import or. but it is necessary that this script # (Perl 5, I am not on that it walks just as well with perl 6) have the # privileges d'executions. # FRE: Installation : n'importe ou. mais il faut que ce script (Perl 5, je ne # suis pas sur qu'il marche aussi bien avec perl 6) ait # les privileges d'executions. # # ENG: Usage: one types "aw2tex nom_du_fichier_a_convertir.aw", and it sort a # file nom_du_fichier_a_convertir.tex in the meme repertoire. Usually # there is orders erronées and it is necessary a little recorriger. # FRE: Utilisation : on tape "aw2tex nom_du_fichier_a_convertir.aw" , et il # sort un fichier nom_du_fichier_a_convertir.tex dans le meme repertoire. # En général il y a des commandes erronnées et il faut un peu recorriger. # # ENG: For the instant, the program does not understand the leaf of train # applix: it is necessary to give it to him explicitly, and as I have # had the flemme to perfect something clean a file configuration has to # read by former., it is necessary to be going to write it towards # the line 900 (to replace Headingx by the train). # FRE: Pour l'instant, le programme ne comprend pas la feuille de style applix: # il faut la lui donner explicitement, et comme j'ai eu la flemme de # mettre au point quelque chose de propre un fichier de configuration # a lire par ex., il faut aller l'écrire vers la ligne 900 (remplacer # HeadingX par le style). # # ENG: If one changes (line 40) the variable $avec_equations = 1 in 0, it # does not do more the equations. For the remainder, the program is # enough explicit (it suffices to open a file applix in method text to # see how this is done) ... At last, this program is slow. This is for # çà that I do for him to post the equations, to kill the time. It can # himself also as it plants on the matrices. # FRE: Si on change (ligne 40) la variable $avec_equations = 1 en 0, il ne # fait plus les equations. # Pour le reste, le programme est assez explicite (il suffit d'ouvrir un # fichier applix en mode texte pour voir comment c'est fait)... # Enfin, ce programme est lent. C'est pour çà que je lui fais afficher # les équations, pour tuer le temps. Il se peut aussi # qu'il plante sur les matrices. ############################################################################## # 1. Get the name of xxx # 2. Read the applix file into a variable # # # ############################################################################## # Little french to english translation # --------------------------------------- # fichier = file # convertir = convert # nom = name # avec equations = with equations # slurp # contenu = contained # objet courant = current object # aut de ligne = aut line # inconnu = unknown # bordel = brothel # nom objet = name object # figs # par = by # paragraphes = paragraphes # tableaux = pictures # subst prim # Bracket # motif a chercher = motive has to look for # item subst = ditto subst # en tete # a mettre = has to put # lignes = lines # colonnes = columns # remplacer = replace # debut # passages # nettoye symboles = clean symbols # llettres # fin # greeks # rels # convertit = converts # nouveaux objets = new objects # Limite de mot = Limit word # graphique # nombre tableaux # tableau a regler = picture has regler # motif central # fin # gif a regler # Saut de ligne = Jump line # Ici un Tableau = Here a Picture # Corps de tableau = Bodies picture ############################################################################## ############################################################################## # ENG: Determine the name of the repertoire and file to treat. Here, this is # do-it-yourself... To arrange. # FRE: Determine le nom du repertoire et du fichier à traiter. Ici, c'est du # bricolage... A arranger. # WHAT IS $2 # Get the name of the file that should to convert $fichier_a_convertir = @ARGV[0]; # Get the actual directory open PIPE, "pwd|"; @res = ; $present_dir = @res[0]; $present_dir =~ s/(^.+?)\n/$1\//; # ????? # ????? the file is if ($fichier_a_convertir =~ /(^\/)(.+)/) { $nom_fichier = $2; $fichier = "$fichier_a_convertir"; } # If the file is ????? elsif ($fichier_a_convertir =~ /(^\.\/)(.+)/) { $nom_fichier = $2; $fichier = "$present_dir$2"; } # else { $nom_fichier = $fichier_a_convertir; $fichier = "$present_dir$fichier_a_convertir"; } $_ = @ARGV[0]; $avec_equations = 1; # STANDS FOR WHAT?? ############################################################################## ############################################################################## ########## ENG: Reads the file. Procedure piquee has Latex2html ############## ########## FRE: Lit le fichier. Procedure piquee a Latex2html ############## ############################################################################## ############################################################################## sub slurp { # Get the filename $file = $_; # Open the file open (INPUT, "<$file"); local (@file_string); # Read the file into file_string while () { push (@file_string, $_ ); }; # ?? $string{'STRING'} = join ('', @file_string); # Close the file close INPUT; undef @file_string; # Blow it away and return the result $_ = delete $string{'STRING'}; $_ } slurp; ############################################################################## ############################################################################## ## ENG: Separate the different sections of the document and the placement ## ## in different files. ## ## FRE: Sépare les différentes sections du document et les met dans des t ## ## fichiers différents. ## ############################################################################## ############################################################################## # ??? /(\\n)(\\n)(.+?)(\\n)/s; $flow = $3; ## ENG: Eliminait the sections train, flow and vars of the file applix. ## Abandoned (for the instant ## FRE: Eliminait les sections styles, flow et vars du fichier applix. ## Abandonné (pour l'instant #### #/(\\n)(.+?)(\\n)/s; #$styles = $2; #s/(\\n)(.+?)(\\n)/\n/sg; #s/(\\n)(\\n)(.+?)(\\n)/\n/sg; #/(\\n)(.+?)(\\n)/s; #$variables = $2; #s/(\\n)(.+?)(\\n)/\n/sg; # ENG: Puts in an Array the objects (equations and figure) that are detailed . # in the next to last section of the file applix). # FRE: Met dans un Array les objets (equations et figures) qui sont détaillées # dans l'avant derniere section du fichier applix). sub tri_objets { # ??? %objets = (); # Repeat it till ??? while (/\n(\\n)(\\n)(.*?)(\\n)/s) { $nom = "%$2%"; $contenu = $9; %objet_courant = ($nom => $contenu,); %objets = (%objets, %objet_courant); s/\n(\\n)(\\n)(.*?)(\\n)/\n\n/s; } } # FRE: end of tri_objets # ENG: fin de tri_objets tri_objets; ############################################################################## ############################################################################## ## ENG: Milked it left Flow (principal text) ## ## FRE: Traite la partie Flow (texte principal) ## ############################################################################## ############################################################################## $_ = "\n$flow\n"; ## ENG: Basic eraitement: caracteres speciaux, sauts of lines, etc... ## ## FRE: Eraitement de base : caracteres speciaux,sauts de lignes, etc... ## # ENG: Elimine the description section and the jumps of untimely lines # FRE: Elimine la description de section et les sauts de lignes intempestifs s/\\n/\n/sgo; s/\\\n\s//sg; s/\\n/ /sgo; # ENG: Other eliminations # FRE: Autres eliminations s/\n\\n/\n%%%Saut de ligne%%%\n/sgo; ################## ENG: Substitute the équations, graphiques and pictures ## ################## by the corresponding marquages ## ################## FRE: Substitue les équations ,graphiques et tableaux par ## ################## les marquages correspondants ## # ENG: markers objects # FRE: marqueurs objets sub inconnu { s/\.*?\/\n\n/sg; s/\.*?\/\n\n/sg; } inconnu; sub objets { while (/\n(\\n.*?\n\)\n/s) { s/\n(\\n.*?\n\)\n/\n%objet%\n/s; $bordel = $1; $bordel =~/\n(\)\n/; $nom_objet = $2; s/\n%objet%\n/\n%$nom_objet%\n/; } } objets; sub figs { $nb_eps = 0; $nb_gif = 0; @epostscripts = (); @gifs = (); while (/\n(\)\n(.*?Graphics.+?\n\)\n/s) { if ($2 == 53) { @epostscripts[$nb_eps] = "\n$1$2$3\n$4\n"; $count_eps = "%Eps$nb_eps%"; s/\n(\)\n(.*?Graphics.+?\n\)\n(\\n|)/\n$count_eps\n/s; $nb_eps++; } elsif ($2 == 66) { @gifs[$nb_gif] = "\n$1$2$3\n$4\n"; $count_gif = "%Gif$nb_gif%"; s/\n(\)\n(.*?Graphics.+?\n\)\n(\\n|)/\n$count_gif\n/s; $nb_gif++; } } } figs; sub par { $nb_pr = 0; @paragraphes = (); while (/\n(\)\n/) { @paragraphes[$nb_pr] = "\n$1\n$2\n"; $count_pr = "%Pr$nb_pr%"; s/\n(\)\n/\n$count_pr\n/; $nb_pr++; } while (/\n(\)\n/) { @paragraphes[$nb_pr] = "\n$1\n"; $count_pr = "%Pr$nb_pr%"; s/\n(\)\n/\n$count_pr\n/; $nb_pr++; } } par; sub tab { $nb_tb = 0; @tableaux = (); while (/\n(\)(?!\n\)(?!\n\\n\n/ \n/sgo; s/\\n\\n/\n/sgo; s/\*BEGIN\sEQUATIONS\sVERSION\=442\/320\sENCODING\=7BIT//sgo; s/\*END\sEQUATIONS//sgo; # ENG: Elimination of details superflux for latex # FRE: Elimination des détails superflux pour latex s/\s\sface\:\"\w+\"//sg; s/\synudge\:\d+//sg; s/\n\\n/\n\\\\\n/sg; # ENG: Substitution of primary motives (i.e. motives that do not contain any # motives interlock) # FRE: Substitution des motifs primaires (i.e. motifs qui ne contiennent # pas de motifs imbriques) sub subst_prim { # ENG: Total ?picture of the things has to substitute # FRE: Tableau total des trucs a substituer # ENG: parentheses and things has a composing # FRE: parentheses et trucs a une composante %a_substituer1 = ( paren => "\\left\( %Motif1% \\right\) ", ltparen => "\\left\( %Motif1% \\right\. ", rtparen => "\\left\. %Motif1% \\right\) ", bracket => "\\left\[ %Motif1% \\right\] ", ltbracket => "\\left\[ %Motif1% \\right\. ", rtbracket => "\\left\. %Motif1% \\right\] ", brace => "\\left\{ %Motif1% \\right\} ", ltbrace => "\\left\{ %Motif1% \\right\. ", rtbrace => "\\left\. %Motif1% \\right\} ", vert => "\\left\| %Motif1% \\right\| ", ltvert => "\\left\| %Motif1% \\right\. ", rtvert => "\\left\. %Motif1% \\right\| ", dblvert => "\\left\\Vert %Motif1% \\right\\Vert ", dblltvert => "\\left\\Vert %Motif1% \\right\\. ", dblrtvert => "\\left\\. %Motif1% \\right\\Vert ", ltltbracket => "\\left\[ %Motif1% \\right\[ ", rtrtbracket => "\\left\] %Motif1% \\right\] ", oppBracket => "\\left\] %Motif1% \\right\[ ", bracketParen => "\\left\[ %Motif1% \\right\) ", parenBracket => "\\left\( %Motif1% \\right\] ", sub => "_\{%Motif1%\} ", sup => " \^\{%Motif1%\} ", sum => "\\sum %Motif1%", int => "\\int %Motif1%", oint => "\\oint %Motif1%", tint => "\\int\\int %Motif1%", thint => "\\int\\int\\int %Motif1%", prod => "\\prod\{%Motif1%\} ", cup => "\\cup\{%Motif1%\} ", cap => "\\cap\{%Motif1%\} ", sqrt => "\\sqrt\{%Motif1%\} ", rtarrowup => "\\stackrel\{%Motif1%\} \\longrightarrow ", rtarrowdn => "\%%Aie%%\\stackrel\{%Motif1%\} \\longrightarrow ", ltarrowup => "\\stackrel\{%Motif1%\} \\longleftarrow ", ltarrowdn => "\\stackrel\{%Motif1%\} \\longleftrightarrow ", ltrtarrowup => "\\stackrel\{%Motif1%\} \\longleftrightarrow ", ltrtarrowdn => "\%%Aie%%\\stackrel\{%Motif1%\} \\longleftrightarrow ", overbar => "\\overline\{%Motif1%\} ", underbar => "\\underline\{%Motif1%\} ", dbloverbar => "\\overline\{%Motif1%\} ", dblunderbar => "\\underline\{\\underline\{%Motif1%\}\} ", script => "\{%Motif1%\} ", ); sub subst1 { $nb_motifs = 1; $motif_a_chercher = '(\)\n(.*?)\n(\)' x ($nb_motifs); foreach $item_subst (keys(%a_substituer1)) { $en_tete = '\n(\)\n'; $motifs_a_chercher = $en_tete.$motif_a_chercher; while (/$motifs_a_chercher/) { /$motifs_a_chercher/; local $motif1 = $3; local $subst_command = '$a_mettre = $a_substituer1{'."$item_subst".'}'; local $a_mettre; eval $subst_command; $a_mettre =~ s/%Motif1%/$motif1/; s/$motifs_a_chercher/$a_mettre/ } } # ENG: end of sub subst1 # FRE: end of sub subst1 } subst1; # ENG: Fractions and things to two composing # FRE: Fractions et trucs à deux composantes %a_substituer2 = ( subsup => "\^{%Motif1%\}_{%Motif2%\} ", over => "\\frac\{%Motif1%\}\{%Motif2%\} ", divide => "\\frac\{%Motif1%\}\{%Motif2%\} ", slash => "\\frac\{%Motif1%\}\{%Motif2%\} ", by => "\\frac\{%Motif1%\}\{%Motif2%\} ", vslash => "\\frac\{%Motif1%\}\{%Motif2%\} ", vertslash => "\\frac\{%Motif1%\}\{%Motif2%\} ", nroot => "\^{%Motif2%\}\\sqrt\{%Motif1%\} ", sumup => "\\sum ^{%Motif2%} %Motif1% ", sumsup => "\\sum ^{%Motif2%} %Motif1% ", sumdn => "\\sum _{%Motif2%} %Motif1%", sumsub => "\\sum _{%Motif2%} %Motif1% ", produp => "\\prod ^{%Motif2%} %Motif1% ", prodsup =>"\\prod ^{%Motif2%} %Motif1% ", proddn => "\\prod _{%Motif2%} %Motif1% ", prodsub => "\\prod _{%Motif2%} %Motif1% ", intup => "\\int ^{%Motif2%} %Motif1% ", intsup => "\\int ^{%Motif2%} %Motif1% ", ointup => "\\oint ^{%Motif2%} %Motif1% ", ointsup => "\\oint ^{%Motif2%} %Motif1% ", tintup => "\\int\\int ^{%Motif2%} %Motif1% ", tintsup => "\\int\\int ^{%Motif2%} %Motif1% ", thintup => "\\int\\int\\int ^{%Motif2%} %Motif1% ", thintsup => "\\int\\int\\int ^{%Motif2%} %Motif1% ", intdn => "\\int _{%Motif2%} %Motif1% ", intsub => "\\int _{%Motif2%} %Motif1% ", ointdn => "\\oint _{%Motif2%} %Motif1% ", ointsub => "\\oint _{%Motif2%} %Motif1% ", tintdn => "\\int\\int _{%Motif2%} %Motif1% ", tintsub => "\\int\\int _{%Motif2%} %Motif1% ", thintdn => "\\int\\int\\int _{%Motif2%} %Motif1% ", thintsub => "\\int\\int\\int _{%Motif2%} %Motif1% ", cupup => "\\cup ^{%Motif2%} %Motif1% ", cupsup => "\\cup ^{%Motif2%} %Motif1% ", cupdn => "\\cup _{%Motif2%} %Motif1% ", cupsub => "\\cup _{%Motif2%} %Motif1% ", scriptup => "%Motif1% \^\{%Motif2%\} ", scriptsup => "%Motif1% \^\{%Motif2%\} ", sriptdn => "%Motif1% _\{%Motif2%\} ", scriptsub => "%Motif1% _\{%Motif2%\} ", ); # ENG: substitution # FRE: substitution : sub subst2 { $nb_motifs = 2; $motif_a_chercher = '(\)\n(.*?)\n(\)\n' x ($nb_motifs); foreach $item_subst (keys(%a_substituer2)) { $en_tete = '\n(\)\n'; $motifs_a_chercher = $en_tete.$motif_a_chercher; while (/$motifs_a_chercher/) { /$motifs_a_chercher/; local $motif1 = $3; local $motif2 = $6; local $subst_command = '$a_mettre = $a_substituer2{'."$item_subst".'}'; local $a_mettre; eval $subst_command; $a_mettre =~ s/%Motif1%/$motif1/; $a_mettre =~ s/%Motif2%/$motif2/; s/$motifs_a_chercher/$a_mettre/ } } # end of sub subst2 # FRE: fin de sub subst2 } subst2; # things to 3 composing # FRE: trucs à 3 composantes %a_substituer3 = ( scriptupdn => "%Motif1% \^\{%Motif2%\}_{%Motif3%\} ", scriptsubsup => "%Motif1% \^\{%Motif2%\}_{%Motif3%\} ", sumupdn => "\\sum ^{%Motif2%\}_{%Motif3%\}%Motif1% ", sumsubsup => "\\sum ^{%Motif2%\}_{%Motif3%\}%Motif1% ", intupdn => "\\int ^{%Motif2%\}_{%Motif3%\}%Motif1% ", intsubsup => "\\int ^{%Motif2%\}_{%Motif3%\}%Motif1% ", ointupdn => "\\oint ^{%Motif2%\}_{%Motif3%\}%Motif1% ", tintupdn => "\\int\\int ^{%Motif2%\}_{%Motif3%\}%Motif1% ", thintupdn => "\\int\\int\\int ^{%Motif2%\}_{%Motif3%\}%Motif1% ", ointsubsup => "\\oint ^{%Motif2%\}_{%Motif3%\}%Motif1% ", tintsubsup => "\\int\\int ^{%Motif2%\}_{%Motif3%\}%Motif1% ", thintsubsup => "\\int\\int\\int ^{%Motif2%\}_{%Motif3%\}%Motif1% ", produpdn => "\\prod ^{%Motif2%\}_{%Motif3%\}%Motif1% ", prodsubsup => "\\prod ^{%Motif2%\}_{%Motif3%\}%Motif1% ", cupupdn => "\\cup ^{%Motif2%\}_{%Motif3%\}%Motif1% ", cupsubsup => "\\cup ^{%Motif2%\}_{%Motif3%\}%Motif1% ", capupdn => "\\cap ^{%Motif2%\}_{%Motif3%\}%Motif1% ", capsubsup =>"\\cap ^{%Motif2%\}_{%Motif3%\}%Motif1% ", ); sub subst3 { $nb_motifs = 3; $motif_a_chercher = '(\)\n(.*?)\n(\)\n' x ($nb_motifs); foreach $item_subst (keys(%a_substituer3)) { $en_tete = '\n(\)\n'; $motifs_a_chercher = $en_tete.$motif_a_chercher; while (/$motifs_a_chercher/) { /$motifs_a_chercher/; local $motif1 = $3; local $motif2 = $6; local $motif3 = $9; local $subst_command = '$a_mettre = "\n".$a_substituer3{'."$item_subst".'}'."\n"; local $a_mettre; eval $subst_command; $a_mettre =~ s/%Motif1%/$motif1/; $a_mettre =~ s/%Motif2%/$motif2/; $a_mettre =~ s/%Motif3%/$motif3/; s/$motifs_a_chercher/$a_mettre/ } } # ENG: end of sub subst3 # FRE: fin de sub subst3 } subst3; # ENG: Matrices # FRE: Matrices. # ENG: Here, there was a bug, I have had the flemme to repair it... # Then, the conversion limits itself to the matrices n x's 3 or # 3 x n (but if one some wants more it suffices to change the desired # number in the buckle for. Can etre that with the two lines # commentees ca walks, but I do not have verifie. # FRE: Ici, il y avait un bug, j'ai eu la flemme le réparer... Alors, la # conversion se limite aux matrices n x 3 ou 3 x n (mais si on en # veut plus il suffit de changer le nombre voulu dans la boucle for. # Peut etre qu'avec les deux lignes commentees ca marche, mais je # n'ai pas verifie. #$amax = 20; while (/\)\n'; $motif_a_chercher = '(\)\n(.*?)\n(\)\n' x ($nb_motifs); sub subst_mat { #procedure to classify the indices of the matrices # FRE: procedure pour classer les indices des matrices $motifs_a_chercher = $en_tete.$motif_a_chercher; /($motifs_a_chercher)/; @temp2 = (); for ($i = 1; $i <= $nb_lignes; $i++) { @temp1 = (); for ($j = 1; $j <= $nb_colonnes; $j++) { $case =4+3*$nb_colonnes*($i-1)+3*($j-1); push @temp1, $$case; } $temp2 = join (' & ', @temp1); push @temp2, $temp2; } $motif_a_remplacer = ' '.join (' \\\\ ', @temp2).' '; $debut_tex = ' '.'\\begin{array}'.'{'.'c' x $nb_colonnes.'}'; $fin_tex = '\\end{array}'.' '; $a_remplacer = $debut_tex.$motif_a_remplacer.$fin_tex; s/$en_tete$motif_a_chercher/$debut_tex$motif_a_remplacer$fin_tex/; # ENG: end of the procedure replacement matrices # FRE: fin de la procedure de remplacement des matrices } # while (/matrix/g) { subst_mat }; } } #### ENG: Preparation for the next turn #### FRE: Préparation pour le prochain tour #### s/\n//sg; s/(\)/\n$1\n/sg; s/(\)/\n$1\n/sg; s/(\)/\n$1\n/sg; s/\n\n/\n/sg; } # ENG: One recommences several times, from the bottom up, so as it remains # converted non motives while (/eqn_begin/s) {subst_prim;} abandoned to # the profit of the following, in cases plantage gave an endless buckle # FRE: On recommence plusieurs fois, de bas en haut, tant qu'il reste des # motifs non convertis # while (/eqn_begin/s) {subst_prim;} abandonné au profit du suivant, en # cas de plantage donnait une boucle sans fin $passages = 0; while (/eqn_begin/s && ($passages <= 10)) { subst_prim; $passages++; } # FRE: subst_prim; subst_prim; subst_prim; subst_prim; subst_prim; subst_prim; # subst_prim; # ENG: Cleaning of symbols, of letters, Greek and of relations # FRE: Nettoyage des symboles, de lettres, grecs et de relations sub nettoye_symboles { @lettres = ('a'..'z', 'A'..'Z', '\=', '\*', '\-', '\+', '\<', '\>', '\|', '\!', '\:', '\.', '\;', '\,', '\~', '\#', '\|', '\/', '\%', '\/', '\&', '0'..'9', '\^oj', '\^oi', '\(', '\)', '_', '\^oh', '\^oa', '\^pj', '\^la',); $llettres = scalar(@lettres); while (/(\)/g) { for ($i = 0; $i <= $llettres - 1; $i++) { for ($j = 0; $j <= $llettres - 1; $j++) { $aa = "@lettres[$i]"; $bb = "@lettres[$j]"; $init = "\"; while (/($init)($aa)($bb)(.*?)($fin)/) { s/($init)($aa)($bb)(.*?)($fin)/$1$2$5\n$1$3$4$5/g; } } } } @greeks =('\\\"', '\$', '\'', '^kf', '\^la', '\^nj', '\^nk', '\^nb', '\^oa', '\^\^', '\\{2}', 'a'..'z', 'A'..'Z'); $lgreeks = scalar(@greeks); while (/(\)/g) { for ($i = 0; $i <= $lgreeks - 1; $i++) { for ($j = 0; $j <= $lgreeks - 1; $j++) { $aa = "@greeks[$i]"; $bb = "@greeks[$j]"; $init = "\"; while (/($init)($aa)($bb)(.*?)($fin)/) { s/($init)($aa)($bb)(.*?)($fin)/$1$2$5\n$1$3$4$5/g; } } } } @rels =('\*', '\@', '\^lf', '\^lb', '\^le', '\^li', '\^me',); $lrels = scalar(@rels); while (/(\)/g) { #print "$lrels\n"; for ($i = 0; $i <= $lrels - 1; $i++) { for ($j = 0; $j <= $lrels - 1; $j++) { $aa = "@rels[$i]"; $bb = "@rels[$j]"; $init = "\"; while (/($init)($aa)($bb)(.*?)($fin)/) { s/($init)($aa)($bb)(.*?)($fin)/$1$2$5\n$1$3$4$5/g; } } } } } nettoye_symboles; # ENG: Conversion of symbols in the orders corresponding Latex # FRE: Conversion des symboles dans les commandes LaTex correspondantes sub convertit_symboles { s/\s\sface\:\"\w+\"//g; s/\n//g; # ENG: normal symboles # FRE: symboles normaux s/(\)/$2/g; # ENG: reliquats of normal symbols # FRE: reliquatsdesymbolesnormaux s/\/\\star/g; s/\/\=/g; s/\/\-/g; s/\/\&/g; s/\/\\"\s\>/\>/g; s/\/\|/g; s/\/./g; s/\/,/g; s/\/+/g; s/\/\\left\( \\right\. /g; s/\/\\left\. \\right\) /g; # ENG: has verifier # FRE: a verifier s/\/\'/g; s/\/Aie !!/g; s/\/Aie !!/g; s/\/Aie !!/g; s/\/Aie !!/g; s/\/\!/g; # ENG: complement # FRE: complement? #s/\/\\\\%%Break%%/g; #s/\/\\/g; # ENG: Greek symbol # FRE: symbolegrecs,,etc... sub greeksymbol { s/\s\sface\:\"\w+\"//g; s/\/\\alpha /g; s/\/\\beta /g; s/\/\\gamma /g; s/\/\\delta /g; s/\/\\epsilon /g; #s/ \ / \\varepsilon /g; s/\/\\zeta /g; s/\/\\eta /g; s/\/\\theta /g; #s/\/\\vartheta /g; s/\/\\iota /g; s/\/\\kappa /g; s/\/\\lamba /g; s/\/\\mu /g; s/\/\\o /g; s/\/\\xi /g; s/\/o /g; s/\/\\pi /g; s/\/\\theta /g; #s/\/\\varpi /g; s/\/\\rho /g; s/\/\\sigma /g; #s/\/\\varsigma /g; s/\/\\tau /g; s/\/\\upsilon /g; s/\/\\phi /g; s/\/\\varphi /g; s/\/\\chi /g; s/\/\\psi /g; s/\/\\omega /g; s/\/\A /g; s/\/\B /g; s/\/\\Gamma /g; s/\/\\Delta /g; s/\/E /g; s/\/H /g; s/\/I /g; s/\/K /g; s/\/M /g; s/\/N /g; s/\/O /g; s/\/Z /g; s/\/\\Phi /g; #Lequel ? s/\/\\Theta /g; s/\/\\Lambda /g; s/\/\\Xi /g; s/\/\\Pi /g; s/\/\\Sigma /g; s/\/\\Upsilon /g; s/\/\\Phi /g; s/\/\\Psi /g; s/\/\\Omega /g; s/\/\\forall /g; s/\/\\exists /g; s/\/\i /g; s/\/Aie !! /g; s/\/\\infty /g; s/\/Aie !! /g; s/\/\\wedge /g; s/\/\\vee /g; s/\/\\partial /g; s/\/Aie !! /g; s/\/f /g; s/\/Aie !!Y /g; s/\/\\aleph /g; s/\/\\Im /g; s/\/\\Re /g; s/\/\\wp /g; s/\/\\clubsuit /g; s/\/Aie !!\\diamond /g; s/\/Aie !!\\hartsuit /g; s/\/Aie !!\\spadesuit /g; s/\/\eg /g; s/\/\\angle /g; s/\/\abla /g; s/\/\\diamond /g; s/\/\\bot /g; } if (/greekSymbol/g) { greeksymbol }; sub relsymbol { s/\/\\star /g; s/\/\\cong /g; s/\/\\propto /g; s/\/\\pm /g; s/\/\\times /g; s/\/\\div /g; #s/\/\\propto /g; #\^lf\^lb\^le\^li\^nh\^lh\^me\^mf\^ob\^pb"\s\>/\%%Aie /g; s/\/\\propto /g; s/\/\\leq /g; s/\/\\geq /g; s/\/\\div /g; s/\/\eq /g; s/\/\\equiv /g; s/\/\\approx /g; s/\/\\leftrightarrow /g; s/\/\\leftarrow /g; s/\/\\uparrow /g; s/\/\\rightarrow /g; s/\/\\downarrow /g; s/\/\\Leftrightarrow /g; s/\/\\Leftarrow /g; s/\/\\Uparrow /g; s/\/\\Rightarrow /g; s/\/\\Downarrow /g; s/\/\Aie !! /g; s/\/\\cdot /g; s/\/\\bullet /g; s/\/\\otimes /g; s/\/\\oplus /g; s/\/\\left\\langle\\right. /g; s/\/\\left.\\right\\rangle /g; s/\/\\emptyset /g; s/\/\\bigcap /g; s/\/\\bigcup /g; s/\/\\supset /g; s/\//g; s/\/\\supseteq /g; s/\/\\subset /g; s/\/\\subseteq /g; s/\/\\in /g; s/\/\otin /g; #s/\/\Aie !! /g; } if (/relSymbol/g) { relsymbol }; s/\/\= /g; s/\/\\\, /g; s/\/\\\: /g; s/\/\\\; /g; s/\/\\\: \\\: /g; s/\/\\\; \\\; /g; # ENG: end sub symboles # FRE: fin sub symboles } # ENG: execution of the procedure cleaning symbols # FRE: execution de la procedure de nettoyage des symboles convertit_symboles; # ENG: Final cleaning (suppression of jumps and space, for the appearance; # leave a jump line apres the commentaries Latex)erreur of doubles # subscripts # FRE: Nettoyage final (suppression des sauts et espaces, pour l'apparence ; # laisse un saut de ligne apres les commentaires Latex) # erreur des doubles subscripts #s/\_\{(.*?)\}\s\s*\_\{(.*?)\}/_{$1_{$2}}/g; #s/\^\{(.*?)\}\s\s*\\^\{(.*?)\}/^{$1^{$2}}/g; # ENG: now corrected all to the end # FRE: maintenant corrigé tout à la fin print; print "\n\n"; } # ENG: And this is finished... # FRE: Et c'est fini... # ENG: Execution of the procedure conversion equations # FRE: Execution de la procedure de conversion des equations %nouveaux_objets = (); foreach $objet_a_remplacer (keys(%objets)) { $_ = $objets{$objet_a_remplacer}; if (/EQUATIONS/s) { if ($avec_equations == 1) { eqn_con } elsif ($avec_equations == 0) { $_ = "%%%Limite de mot%%%equation%%%Limite de mot%%%"; } print; #$vide = "%%%Limite de mot%%%equation%%%Limite de mot%%%"; $objets{$objet_a_remplacer} = $_; #$objets{$objet_a_remplacer} = $vide; } elsif (/GRAPHICS/s) {$objets{$objet_a_remplacer}="%%%Limite de mot%%%graphique%%%Limite de mot%%%"} } ############################################################# # ENG: Conversion of pictures to the format tex # FRE: Conversion des tableaux au format tex ############################################################# sub tableaux { @tableaux_tex = (); $nombre_tableaux = scalar(@tableaux); $ii = 0; for ($ii = 0; $ii < $nombre_tableaux; $ii++) { $tableau_a_regler = @tableaux[$ii]; $nb_elements = $tableau_a_regler =~ s/\)//s; push @temp1, "\n$1\n"; } $temp2 = join ("\n".' & '."\n", @temp1); $motif_central = "$motif_central\n"."\\hline"."\n$temp2"."\n\\\\\n"."\\hline"; } $motif_colonnes = '|'.'c|' x $nb_colonnes; $debut_tex = '\\vspace{0.3cm}'."\n".'{\\centering \\begin{tabular}'.'{'."$motif_colonnes".'}'; $fin_tex = "\n".'\\end{tabular}\\par}'."\n".'\\vspace{0.3cm}'."\n"; $a_remplacer = $debut_tex.$motif_central.$fin_tex; push @tableaux_tex, $a_remplacer; } } ####### ENG: end of the conversion of pictures to the format tex ####### FRE: fin de la conversion des tableaux au format tex ###### if ($texte =~ /%Tb/) { tableaux }; ############################################################# # ENG: Conversion of faces eps to the format tex # FRE: Conversion des figures eps au format tex ############################################################ sub epostscripts { @epostscripts_tex = (); $nombre_epostscripts = scalar(@epostscripts); $ii = 0; for ($ii = 0; $ii < $nombre_epostscripts; $ii++) { $epostscript_a_regler = @epostscripts[$ii]; $epostscript_a_regler =~ /\n(\)/s; $motif_central = $2; $debut_figure = '\vspace{0.3cm}'."\n".'{'."\n".'\begin{figure}[h]'."\n".'{\par\centering \resizebox*{0.5\columnwidth}{0.1\textheight}{\includegraphics{'; $fin_figure = '}} \par}'."\n\n".'\caption{}'."\n".'\end{figure}'."\n".'\par}'."\n".'\vspace{0.3cm}'; $a_remplacer = $debut_figure.$motif_central.$fin_figure; push @epostscripts_tex, $a_remplacer; } } ####### ENG: end of the conversion of faces eps to the format tex ####### FRE: fin de la conversion des figures eps au format tex ###### #if ($texte =~/\%Eps/s) {epostscripts} epostscripts; ############################################################# # ENG: Conversion of faces gif to the format tex # FRE: Conversion des figures gif au format tex ############################################################ sub gifs { @gifs_tex = (); $nombre_gifs = scalar(@gifs); $ii = 0; for ($ii = 0; $ii < $nombre_gifs; $ii++) { $gif_a_regler = @gifs[$ii]; $gif_a_regler =~ /\n(\)/s; $motif_central = $2; $convert = 'gif2ps '."$motif_central".'|cat > '."$motif_central".'.eps'; system "$convert"; $convert = 'ps2epsi '."$motif_central".'.eps'; system "$convert"; $motif_central = $motif_central.'.epsi'; $debut_figure = '\vspace{0.3cm}'."\n".'{'."\n".'\begin{figure}[h]'."\n".'{\par\centering \resizebox*{0.5\columnwidth}{0.1\textheight}{\includegraphics{'; $fin_figure = '}} \par}'."\n\n".'\caption{}'."\n".'\end{figure}'."\n".'\par}'."\n".'\vspace{0.3cm}'; $a_remplacer = $debut_figure.$motif_central.$fin_figure; push @gifs_tex, $a_remplacer; } } ####### ENG: end of the conversion of faces gif to the format tex ####### FRE: fin de la conversion des figures gif au format tex ###### #if ($texte =~/\%Gif/s) {gifs} gifs; ############################################################## ####### ENG: Conversion of paragraphs ###################### ####### FRE: Conversion des paragraphes ###################### ############################################################## sub paragraphes { @paragraphes_tex = (); $nombre_paragraphes = scalar(@paragraphes); $ii = 0; for ($ii = 0; $ii <= $nombre_paragraphes; $ii++) { # ENG: Definit the type paragraph and puts the title in head/kopf # FRE: Definit le type de paragraphe et met le titre en tete $par_a_substituer = @paragraphes[$ii]; $par_a_substituer =~ s/\n(\)\n\\n/\n%%%$2%%%\n$1\n%%%Saut de ligne%%%\n/o; $par_a_substituer =~ s/\n\\n/\n%%%Saut de ligne%%%\n/o; $par_a_substituer =~ s/\n\\n/\n$1\n/o; $par_a_substituer =~ s/\n\\n/\n\$\\Delta\$\n/o; # ENG: has to do for the other letters # FRE: a faire pour les autres lettres... $par_a_substituer =~ s/\n\\n/\n\\textbf{$1}\n/o; $par_a_substituer =~ s/\n\\n/\n\\emph{$1}\n/o; $par_a_substituer =~ s/\n\\n/\n\\underbar{$1}\n/o; $par_a_substituer =~ s/\n\\n/\n$1\n/o; $par_a_substituer =~ s/\n\\n/\n\$_{$1}\$\n/o; $par_a_substituer =~ s/\n\\n/\n\$^{$1}\$\n/o; # ENG: other cases of face # FRE: autres cas de figure $par_a_substituer =~ s/\n\\n/\n$1\n/o; # ENG: Behandle die Tab. um daraus die Liste mit Elementen zu machen # FRE: Traite les tabulations pour en faire des listes d'items. #$par_a_substituer =~ s/(\\n\^aj|\^aj)(\-|\-\s|)(.+?)(\"\>)/\n\\begin{itemize}$1$3\n\\end{itemize}\n$4/sg; #$par_a_substituer =~ s/(\^aj){1,}(\-\s|)/\n\\item /sg; ## etc, à compléter... #$par_a_substituer =~ s/\\\"/\"/sgo; #print $par_a_substituer; # ENG: Clean the special characters # FRE: Nettoye les caractères spéciaux $par_a_substituer =~ s/\\\"/\"{}/go; $par_a_substituer =~ s/&/\\&/go; $par_a_substituer =~ s/\^oi/\\`{e}/go; #` $par_a_substituer =~ s/\^oj/\\'{e}/go; #' $par_a_substituer =~ s/\^oa/\\`{a}/go; #` $par_a_substituer =~ s/\^ok/\\^{e}/go; $par_a_substituer =~ s/\^pm/\\"{u}/go; #" $par_a_substituer =~ s/\^pi/\\"{u}/go; #" $par_a_substituer =~ s/\^ol/\\"{e}/go; #" $par_a_substituer =~ s/\^oo/\\^{i}/go; $par_a_substituer =~ s/\^pe/\\^{o}/go; $par_a_substituer =~ s/\^lf/\$\\mu\$/go; $par_a_substituer =~ s/\^jd//go; $par_a_substituer =~ s/\^je//go; $par_a_substituer =~ s/\^lb/\$\\pm\$/go; $par_a_substituer =~ s/\^aj/%%%Saut de ligne%%%/go; $par_a_substituer =~ s/\^la/\$^o\$/go; $par_a_substituer =~ s/\^\w\w/Aie !! /go; ################## ENG: Stylpaper ######################################## ################## FRE: Feuille de style ################################# # ENG: Replace the markers by the orders corresponding Latex # FRE: Remplace les marqueurs par les commandes LaTex correspondantes $par_a_substituer =~ s/\n(%%%Title%%%)\n(.+?)\n/\n\\title{$2}\n\\date{}\n\\author{}\n\\maketitle\n\n/so; $par_a_substituer =~ s/\n(%%%Subtitle%%%)\n(.+?)\n/\n\\section*{$2}\n/so; $par_a_substituer =~ s/\n(%%%Heading1%%%)\n(.+?)\n/\n\\section{$2}\n/so; $par_a_substituer =~ s/\n(%%%Heading2%%%)\n(.+?)\n/\n\\subsection{$2}\n/so; $par_a_substituer =~ s/\n(%%%Heading3%%%)\n(.+?)\n/\n\\subsubsection{$2}\n/so; $par_a_substituer =~ s/\n(%%%Heading\s1%%%)\n(.+?)\n/\n\\section{$2}\n/so; $par_a_substituer =~ s/\n(%%%Heading\s2%%%)\n(.+?)\n/\n\\subsection{$2}\n/so; $par_a_substituer =~ s/\n(%%%Heading\s3%%%)\n(.+?)\n/\n\\subsubsection{$2}\n/so; $par_a_substituer =~ s/\n(%%%heading\s1%%%)\n(.+?)\n/\n\\title{$2}\n\\date{}\n\\author{}\n\\maketitle\n\n/so; $par_a_substituer =~ s/\n(%%%heading\s2%%%)\n(.+?)\n/\n\\section*{$2}\n/so; $par_a_substituer =~ s/\n(%%%heading\s3%%%)\n(.+?)\n/\n\\section{$2}\n/so; $par_a_substituer =~ s/\n(%%%heading\s5%%%)\n(.+?)\n/\n\\section{$2}\n/so; $par_a_substituer =~ s/\n(%%%heading\s4%%%)\n(.+?)\n/\n\\subsection{$2}\n/so; $par_a_substituer =~ s/\n(%%%heading\s5%%%)\n(.+?)\n/\n\\subsubsection{$2}\n/so; $par_a_substituer =~ s/\n(%%%heading\s6%%%)\n(.+?)\n/\n$2\n\n/so; $par_a_substituer =~ s/\n(%%%Normal%%%)\n(.+?)\n/\n$2\n/so; $par_a_substituer =~ s/\n(%%%Paragraph%%%)\n(.+?)\n/\n$2\n/so; $par_a_substituer =~ s/\n(%%%Corps\sde\stexte%%%)\n(.+?)\n/\n$2\n/so; $par_a_substituer =~ s/\n(%%%Alin\\\'\{e\}a\sn\\\'\{e\}gatif%%%)\n(.+?)\n/\n$2\n/so; $par_a_substituer =~ s/\n(%%%WW\-Body\sText\sIndent\s\d%%%)\n(.+?)\n/\n$2\n/so; $par_a_substituer =~ s/\n(%%%Cell%%%)\n(.+?)\n/$2\n/so; $par_a_substituer =~ s/\n(%%%\w+?%%%)\n(.+?)\n/$2\n/so; # ################# ENG: End of the leaf of train ######################## ################# FRE: Fin de la feuille de style ######################## push @paragraphes_tex, $par_a_substituer; # ENG: End of the conversion of paragraphs # FRE: Fin de la conversion des paragraphes # } } paragraphes; ################################################################### ####### ENG: reinsertion of objects has the place of markers ###### ####### FRE: reinsertion des objets a la place des marqueurs ###### ################################################################### $_ = $texte; sub substtab { # ENG: Substitution of pictures in the file tex # FRE: Substitution des tableaux dans le fichier tex for ($iii = 0; $iii <= $nombre_tableaux; $iii++) { $tb_a_substituer = "%Tb$iii%"; s/$tb_a_substituer/%%Ici un Tableau%%\n%%%Saut de ligne%%%\n@tableaux_tex[$iii]/s; } } substtab; sub substpar { # ENG: Substitution of paragraphs in the file tex # FRE: Substitution des paragraphes dans le fichier tex for ($iii = 0; $iii <= $nombre_paragraphes; $iii++) { $pr_a_substituer = "%Pr$iii%"; s/$pr_a_substituer/@paragraphes_tex[$iii]/s; # %%Ici un Paragraphe%%\n } } substpar; sub substobj { # ENG: ? # FRE: Substitution des objets dans le fichier tex foreach $objet_a_remplacer (keys(%objets)) { $truc = $objets{$objet_a_remplacer}; #print $objet_a_remplacer; s/(%%%Saut\sde\sligne%%%)(\n|\s)+$objet_a_remplacer\n/\n \\[$truc\\] \n/sg; s/\n$objet_a_remplacer\n/\n \\($truc\\) \n/sg; } } substobj; sub substeps { # Substitution of objects in the file tex # FRE: Substitution des figures eps dans le fichier tex for ($iii = 0; $iii <= $nombre_epostscripts; $iii++) { $eps_a_substituer = "%Eps$iii%"; s/$eps_a_substituer/@epostscripts_tex[$iii]/s; } } # ENG: substeps # FRE: substeps; sub substgif { # FRE: Substitution des figures gif dans le fichier tex for ($iii = 0; $iii <= $nombre_gifs; $iii++) { $gif_a_substituer = "%Gif$iii%"; s/$gif_a_substituer/@gifs_tex[$iii]/s; } } #substgif; # ENG: Elimination of empty paragraphs # FRE: Elimination des paragraphes vides #s/\n\/\n/g; # ENG: Reparations of last minute # FRE: Reparations de derniere minute s/(?=\s\\\w+)/\n/sg; s/\s{2,}/ /sg; s/\n\s\n/\n/sg; s/\n{1,}//sg; s/\s(?=\$)(?!=\$\\\\)//sg; s/%%%Saut\sde\sligne%%%/\n\n/sgo; s/%%%Limite de mot%%%/\n/sgo; s/%%%Corps de tableau%%%/\n/sgo; s/(?>$present_dir/$nom_fichier.tex"; print FINTEX2; close FINTEX2; #system "latex $fichier"; $fichier = "$present_dir$nom_fichier\.dvi"; #print $fichier; $visualise = "xdvi $fichier"; #system "$visualise"; $detruit = 'rm -f '."$aw2texdir".'/*.cv'; #print $detruit; #system $detruit; $detruit = 'rmdir '."$aw2texdir"; #system $detruit;