Rev 7232 | Rev 7395 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7232 | Rev 7387 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | my $TOOLTIP = 0 ; |
35 | my $TOOLTIP = 0 ; |
36 | my $STYLE = '' ; |
36 | my $STYLE = '' ; |
37 | my $OPTION = '' ; |
37 | my $OPTION = '' ; |
38 | my $tooltip_prompt = '<img src="gifs/picto.gif" alt="picto" />' ; |
38 | my $tooltip_prompt = '<img src="gifs/picto.gif" alt="picto" />' ; |
39 | $tooltip_prompt=''; |
39 | $tooltip_prompt=''; |
40 | my $linkout='' ; |
40 | my $linkout='' ; |
41 | $worksheet= ''; |
41 | $worksheet= ''; |
42 | $SHEET = '' ; |
42 | $SHEET = '' ; |
43 | $DIR = ''; |
43 | $DIR = ''; |
44 | $doc_DIR = ''; |
44 | $doc_DIR = ''; |
45 | $SUBDIR='1'; |
45 | $SUBDIR='1'; |
46 | my @SECTIONS = qw(document part chapter section subsection subsubsection); |
46 | my @SECTIONS = qw(document part chapter section subsection subsubsection); |
47 | #my @SECTIONS = ( document part entete frame subsection subsubsection ); |
47 | #my @SECTIONS = ( document part entete frame subsection subsubsection ); |
48 | #TODO biblio dans un fichier séparé si on a rencontré \begin{thebibliography} Non, |
48 | #TODO biblio dans un fichier séparé si on a rencontré \begin{thebibliography} Non, |
49 | # on n'a qu'a mettre cet environnement de type link |
49 | # on n'a qu'a mettre cet environnement de type link |
50 | #$doc_DIR=$ENV{'w_docdir'}; |
50 | #$doc_DIR=$ENV{'w_docdir'}; |
51 | #$DIR=$ENV{'w_dir'}; |
51 | #$DIR=$ENV{'w_dir'}; |
52 | #$DIR =~ s/ +//; |
52 | #$DIR =~ s/ +//; |
53 | push (@ARGV,split(' ', $ENV{'wims_exec_parm'})) if ($ENV{'wims_exec_parm'}) ; |
53 | push (@ARGV,split(' ', $ENV{'wims_exec_parm'})) if ($ENV{'wims_exec_parm'}) ; |
54 | 54 | ||
55 | while ($_ = shift (@ARGV)) |
55 | while ($_ = shift (@ARGV)) |
56 | { |
56 | { |
57 | last if (!/^--/); |
57 | last if (!/^--/); |
58 | if (/^--style=(.*)$/) { $STYLE = $1; } |
58 | if (/^--style=(.*)$/) { $STYLE = $1; } |
59 | elsif (/^--macro=(.*)$/) { $MACRO = $1; } |
59 | elsif (/^--macro=(.*)$/) { $MACRO = $1; } |
60 | elsif (/^--docdir=(.*)$/){ $doc_DIR = $1; } |
60 | elsif (/^--docdir=(.*)$/){ $doc_DIR = $1; } |
61 | elsif (/^--dir=(.*)$/) { $DIR = $1; } |
61 | elsif (/^--dir=(.*)$/) { $DIR = $1; } |
62 | elsif (/^--subdir=(.*)$/){ $SUBDIR = $1; } |
62 | elsif (/^--subdir=(.*)$/){ $SUBDIR = $1; } |
63 | elsif (/^--embed=(.*)$/) { $EMBED = $1; } |
63 | elsif (/^--embed=(.*)$/) { $EMBED = $1; } |
64 | elsif (/^--verbose$/) { $verbose = 1; } |
64 | elsif (/^--verbose$/) { $verbose = 1; } |
65 | elsif (/^--author=(.*)$/){ $author = $1; } |
65 | elsif (/^--author=(.*)$/){ $author = $1; } |
66 | elsif (/^--email=(.*)$/) { $email = $1; } |
66 | elsif (/^--email=(.*)$/) { $email = $1; } |
67 | elsif (/^--worksheet=(.*)$/) { $worksheet = $1; } |
67 | elsif (/^--worksheet=(.*)$/) { $worksheet = $1; } |
68 | elsif (/^--tooltip_prompt=(.*)$/) { $tooltip_prompt = $1; } |
68 | elsif (/^--tooltip_prompt=(.*)$/) { $tooltip_prompt = $1; } |
69 | elsif (/^--linkout=(.*)$/) { $linkout = $1; } |
69 | elsif (/^--linkout=(.*)$/) { $linkout = $1; } |
70 | elsif (/^--cut=(.*)$/) { @SECTIONS = split(',',$1) ;} |
70 | elsif (/^--cut=(.*)$/) { @SECTIONS = split(',',$1) ;} |
71 | elsif (/^--help$/) { |
71 | elsif (/^--help$/) { |
72 | usage(); # includes --help ! |
72 | usage(); # includes --help ! |
73 | exit 1; |
73 | exit 1; |
74 | } |
74 | } |
75 | } ; |
75 | } ; |
Line 82... | Line 82... | ||
82 | my $BASE = $doc_DIR . "doc/$SUBDIR/src"; |
82 | my $BASE = $doc_DIR . "doc/$SUBDIR/src"; |
83 | my $BASE0= $doc_DIR . "doc/$SUBDIR"; |
83 | my $BASE0= $doc_DIR . "doc/$SUBDIR"; |
84 | 84 | ||
85 | my $LOAD = '\reload{<img src="gifs/doc/etoile.gif" alt="rechargez" style="width:20px;height:20px;" />}'; |
85 | my $LOAD = '\reload{<img src="gifs/doc/etoile.gif" alt="rechargez" style="width:20px;height:20px;" />}'; |
86 | my $FLECHE = '→'; |
86 | my $FLECHE = '→'; |
87 | $linkout = "\\doc{module=$linkout}" . $FLECHE if ($linkout) ; |
87 | $linkout = "\\doc{module=$linkout}" . $FLECHE if ($linkout) ; |
88 | 88 | ||
89 | ################################## |
89 | ################################## |
90 | ##Initialisation |
90 | ##Initialisation |
91 | #si je rajoute les listes : type=fold : signifierait que les item sont en fold [demande |
91 | #si je rajoute les listes : type=fold : signifierait que les item sont en fold [demande |
92 | #d'avoir des titres, ca serait du type description en latex |
92 | #d'avoir des titres, ca serait du type description en latex |
93 | #pas de titre ? deb fin <ul ... > </ul> |
93 | #pas de titre ? deb fin <ul ... > </ul> |
94 | #type = |
94 | #type = |
95 | #hash contenant les caractéristiques des environnements latex, voir \environmentwims |
95 | #hash contenant les caractéristiques des environnements latex, voir \environmentwims |
96 | my %hash_environ = ( |
96 | my %hash_environ = ( |
97 | titre => {}, |
97 | titre => {}, |
98 | style => {}, |
98 | style => {}, |
99 | type => {}, |
99 | type => {}, |
Line 110... | Line 110... | ||
110 | my %hash_command = ( |
110 | my %hash_command = ( |
111 | cnt_arg => {}, |
111 | cnt_arg => {}, |
112 | definition => {}, |
112 | definition => {}, |
113 | origin => {}, |
113 | origin => {}, |
114 | ); |
114 | ); |
115 | my @liste_env_list = ('itemize', 'description', 'enumerate', 'trivlist') ; |
115 | my @liste_env_list = ('itemize', 'description', 'enumerate', 'trivlist') ; |
116 | $hash_environ{type}{'description_item'} = 'fold' ; |
116 | $hash_environ{type}{'description_item'} = 'fold' ; |
117 | $hash_environ{titre}{'description_item'} = ' ' ; |
117 | $hash_environ{titre}{'description_item'} = ' ' ; |
118 | 118 | ||
119 | my @liste_env_tabular = ('tabular') ; |
119 | my @liste_env_tabular = ('tabular') ; |
120 | 120 | ||
121 | my @liste_env_spec = ('equation', 'multline', 'latexonly', |
121 | my @liste_env_spec = ('equation', 'multline', 'latexonly', |
122 | 'pmatrix','smallmatrix', 'eqnarray', 'array', 'algorithmic', 'algorithm', 'align', |
122 | 'pmatrix','smallmatrix', 'eqnarray', 'array', 'algorithmic', 'algorithm', 'align', |
123 | 'thebibliography', 'pspicture', 'picture', 'cases', 'gather', |
123 | 'thebibliography', 'pspicture', 'picture', 'cases', 'gather', |
124 | 'displaymath', 'math', 'center', 'minipage', 'lstlisting', 'columns', 'column'); |
124 | 'displaymath', 'math', 'center', 'minipage', 'lstlisting', 'columns', 'column', 'figure'); |
125 | - | ||
126 | my @liste_com_spec = ('paragraph', 'href', 'url', 'exercise', 'doc') ; #je ne m'en sers pas encore |
- | |
127 | 125 | ||
- | 126 | my @liste_com_spec = ('paragraph', 'href', 'url', 'exercise', 'doc') ; #je ne m'en sers pas encore |
|
- | 127 | ||
128 | #commandes par défaut : sont écrasés par un \def ou un \defwims |
128 | #commandes par défaut : sont écrasés par un \def ou un \defwims |
129 | 129 | ||
130 | #$hash_command{cnt_arg}{text} = 1 ; |
130 | #$hash_command{cnt_arg}{text} = 1 ; |
131 | #$hash_command{definition}{text} = '\) #1 \(' ; |
131 | #$hash_command{definition}{text} = '\) #1 \(' ; |
132 | #$hash_command{origin}{text} = 'defaut' ; |
132 | #$hash_command{origin}{text} = 'defaut' ; |
133 | 133 | ||
134 | $hash_command{cnt_arg}{paragraph} = 1 ; |
134 | $hash_command{cnt_arg}{paragraph} = 1 ; |
135 | $hash_command{definition}{paragraph} = '<p class="paragraph"> #1 </p>' ; |
135 | $hash_command{definition}{paragraph} = '<p class="paragraph"> #1 </p>' ; |
136 | $hash_command{origin}{paragraph} = 'defaut' ; |
136 | $hash_command{origin}{paragraph} = 'defaut' ; |
137 | 137 | ||
138 | $hash_command{cnt_arg}{href} = 2 ; |
138 | $hash_command{cnt_arg}{href} = 2 ; |
139 | $hash_command{definition}{href} = '<a href="http:#1" target="wims_external">#2</a>'; |
139 | $hash_command{definition}{href} = '<a href="http:#1" target="wims_external">#2</a>'; |
140 | $hash_command{origin}{href} = 'defaut' ; |
140 | $hash_command{origin}{href} = 'defaut' ; |
141 | 141 | ||
142 | $hash_command{cnt_arg}{url} = 1 ; |
142 | $hash_command{cnt_arg}{url} = 1 ; |
Line 144... | Line 144... | ||
144 | $hash_command{origin}{url} = 'defaut' ; |
144 | $hash_command{origin}{url} = 'defaut' ; |
145 | 145 | ||
146 | $hash_command{cnt_arg}{exercise} = 2 ; |
146 | $hash_command{cnt_arg}{exercise} = 2 ; |
147 | $hash_command{definition}{exercise} = "\\exercise\{\#1\}\{\#2\}"; |
147 | $hash_command{definition}{exercise} = "\\exercise\{\#1\}\{\#2\}"; |
148 | $hash_command{origin}{exercise} = 'defwims' ; |
148 | $hash_command{origin}{exercise} = 'defwims' ; |
149 | 149 | ||
150 | $hash_command{cnt_arg}{doc} = 2 ; |
150 | $hash_command{cnt_arg}{doc} = 2 ; |
151 | $hash_command{definition}{doc} = '\doc{#1&cmd=new}{#2}'; |
151 | $hash_command{definition}{doc} = '\doc{#1&cmd=new}{#2}'; |
152 | $hash_command{origin}{doc} = 'defwims' ; |
152 | $hash_command{origin}{doc} = 'defwims' ; |
153 | 153 | ||
154 | #a un label est associé son bloc [nom de fichier] |
154 | #a un label est associé son bloc [nom de fichier] |
Line 159... | Line 159... | ||
159 | 159 | ||
160 | my %hash_index = ( |
160 | my %hash_index = ( |
161 | page => {}, |
161 | page => {}, |
162 | ); |
162 | ); |
163 | 163 | ||
164 | #type sert à repérer les fichiers embed ou fold. |
164 | #type sert à repérer les fichiers embed ou fold. |
165 | my %hash = ( |
165 | my %hash = ( |
166 | text => {}, |
166 | text => {}, |
167 | prev => {}, |
167 | prev => {}, |
168 | next => {}, |
168 | next => {}, |
169 | upbl => {}, |
169 | upbl => {}, |
Line 173... | Line 173... | ||
173 | datm => {}, |
173 | datm => {}, |
174 | label => {}, |
174 | label => {}, |
175 | toc => {}, |
175 | toc => {}, |
176 | chemin => {}, |
176 | chemin => {}, |
177 | niveau => {}, |
177 | niveau => {}, |
178 | type => {}, |
178 | type => {}, |
179 | author => {}, |
179 | author => {}, |
180 | title => {}, |
180 | title => {}, |
181 | email => {}, |
181 | email => {}, |
182 | toctip => {}, |
182 | toctip => {}, |
183 | ); |
183 | ); |
Line 210... | Line 210... | ||
210 | suite => {} |
210 | suite => {} |
211 | ) ; |
211 | ) ; |
212 | my $algo_noend = 0 ; |
212 | my $algo_noend = 0 ; |
213 | my $voca = %{$hash_algo{titre}} ; |
213 | my $voca = %{$hash_algo{titre}} ; |
214 | my @liste_voca = ('FOR', 'IF','WHILE','REPEAT','ELSE','ELSIF','ENDIF','DO', |
214 | my @liste_voca = ('FOR', 'IF','WHILE','REPEAT','ELSE','ELSIF','ENDIF','DO', |
215 | 'ENDWHILE', 'REQUIRE','ENSURE','ENDFOR','STATE','UNTIL','THEN', 'RETURN') ; |
215 | 'ENDWHILE', 'REQUIRE','ENSURE','ENDFOR','STATE','UNTIL','THEN', 'RETURN') ; |
216 | 216 | ||
217 | $hash_command{definition}{algorithmicrequire}='<b>Require</b>'; |
217 | $hash_command{definition}{algorithmicrequire}='<b>Require</b>'; |
218 | $hash_command{origin}{algorithmicrequire}='defaut'; |
218 | $hash_command{origin}{algorithmicrequire}='defaut'; |
219 | $hash_command{cnt_arg}{algorithmicrequire}= 0 ; |
219 | $hash_command{cnt_arg}{algorithmicrequire}= 0 ; |
220 | $hash_command{definition}{algorithmicensure}='<b>Ensure</b>'; |
220 | $hash_command{definition}{algorithmicensure}='<b>Ensure</b>'; |
Line 254... | Line 254... | ||
254 | for my $cmd ('ENDFOR','ENDIF','ENDWHILE','REQUIRE','ENSURE', 'STATE','UNTIL') { |
254 | for my $cmd ('ENDFOR','ENDIF','ENDWHILE','REQUIRE','ENSURE', 'STATE','UNTIL') { |
255 | $hash_algo{apres}{$cmd} = 0 ; |
255 | $hash_algo{apres}{$cmd} = 0 ; |
256 | } |
256 | } |
257 | 257 | ||
258 | 258 | ||
259 | # lit les fichiers wims.sty puis les fichers .tex. pour éviter : un seul fichier tex, le premier ? |
259 | # lit les fichiers wims.sty puis les fichers .tex. pour éviter : un seul fichier tex, le premier ? |
260 | 260 | ||
261 | my $TEXT = Init($FILE, \%hash_environ, \%hash_command, \%hash, \%hash_algo); |
261 | my $TEXT = Init($FILE, \%hash_environ, \%hash_command, \%hash, \%hash_algo); |
262 | out1 ('sheet', $SHEET) ; |
262 | out1 ('sheet', $SHEET) ; |
263 | $ABOUT = $hash{about}{main} ; |
263 | $ABOUT = $hash{about}{main} ; |
264 | out1 ('about.phtml', (($ABOUT)? $ABOUT :'') . ' |
264 | out1 ('about.phtml', (($ABOUT)? $ABOUT :'') . ' |
265 | <p> |
265 | <p> |
266 | Ce document a été créé par Latex2wims.</p> |
266 | Ce document a été créé par Latex2wims.</p> |
267 | 267 | ||
268 | !changeto docu/about.phtml') ; |
268 | !changeto docu/about.phtml') ; |
Line 273... | Line 273... | ||
273 | warn " ATTENTION : Vous devez mettre un titre : \\title{xx} " ; |
273 | warn " ATTENTION : Vous devez mettre un titre : \\title{xx} " ; |
274 | $hash{title}{main} = '??' } ; |
274 | $hash{title}{main} = '??' } ; |
275 | if (!($hash{email}{main})) { |
275 | if (!($hash{email}{main})) { |
276 | warn " ATTENTION : Vous devez mettre un email \\email{xxx}" ; |
276 | warn " ATTENTION : Vous devez mettre un email \\email{xxx}" ; |
277 | $hash{email}{main}=$email } ; |
277 | $hash{email}{main}=$email } ; |
278 | 278 | ||
279 | 279 | ||
280 | # PASSE 2: ferme les \section & co |
280 | # PASSE 2: ferme les \section & co |
281 | my $SEC_MIN_GLOBAL = 10; # = \infty |
281 | my $SEC_MIN_GLOBAL = 10; # = \infty |
282 | #$SEC_MIN_GLOBAL = 3 ; |
282 | #$SEC_MIN_GLOBAL = 3 ; |
283 | my @cnt = (0) x ($#SECTIONS + 1); |
283 | my @cnt = (0) x ($#SECTIONS + 1); |
284 | my ($secpattern) = join('|', @SECTIONS); |
284 | my ($secpattern) = join('|', @SECTIONS); |
285 | $TEXT =~ s/\\begin\s*{($secpattern)\s*}/cnt_section($1,\@cnt)/eg; |
285 | $TEXT =~ s/\\begin\s*{($secpattern)\s*}/cnt_section($1,\@cnt)/eg; |
286 | $TEXT =~ s/\[fragile\]//g; |
286 | $TEXT =~ s/\[fragile\]//g; |
287 | $TEXT =~ s/\\end\s*{\s*($secpattern)\s*}/<\/$1>/g; |
287 | $TEXT =~ s/\\end\s*{\s*($secpattern)\s*}/<\/$1>/g; |
288 | $TEXT =~ s/\\wimsentre{($secpattern)}/\\wimsentre$1/g; |
288 | $TEXT =~ s/\\wimsentre{($secpattern)}/\\wimsentre$1/g; |
289 | $TEXT =~ s/\\(wimsentre)?($secpattern)\b\*?/open_close($2,\@cnt,$1)/eg; |
289 | $TEXT =~ s/\\(wimsentre)?($secpattern)\b\*?/open_close($2,\@cnt,$1)/eg; |
290 | $TEXT =~ s|</document>.*||s; |
290 | $TEXT =~ s|</document>.*||s; |
291 | $TEXT =~ s|.*<document>||s; |
291 | $TEXT =~ s|.*<document>||s; |
292 | if($SEC_MIN_GLOBAL == 10) {$SEC_MIN_GLOBAL = 0} ; |
292 | if($SEC_MIN_GLOBAL == 10) {$SEC_MIN_GLOBAL = 0} ; |
293 | my ($NIVEAU, $NIVEAU_max) = ($SEC_MIN_GLOBAL, $SEC_MIN_GLOBAL + $depth - 1); |
293 | my ($NIVEAU, $NIVEAU_max) = ($SEC_MIN_GLOBAL, $SEC_MIN_GLOBAL + $depth - 1); |
294 | 294 | ||
295 | 295 | ||
296 | 296 | ||
297 | # PASSE 3: crée les blocs venant des sections et co |
297 | # PASSE 3: crée les blocs venant des sections et co |
298 | # et renvoie une partie de la table des matières |
298 | # et renvoie une partie de la table des matières |
299 | my $toc = analyse_texte ($TEXT, \%hash, 'main', $NIVEAU, $NIVEAU_max, ''); |
299 | my $toc = analyse_texte ($TEXT, \%hash, 'main', $NIVEAU, $NIVEAU_max, ''); |
Line 318... | Line 318... | ||
318 | $hash{text}{$tag} = $T; |
318 | $hash{text}{$tag} = $T; |
319 | my $tagupbl = $hash{upbl}{$tag}; |
319 | my $tagupbl = $hash{upbl}{$tag}; |
320 | #plus utilisé, mais j'hésite ! |
320 | #plus utilisé, mais j'hésite ! |
321 | # $hash_toc{$tag} = "\\link{$tagupbl}\n\n" . $hash{toc}{$tagupbl}; |
321 | # $hash_toc{$tag} = "\\link{$tagupbl}\n\n" . $hash{toc}{$tagupbl}; |
322 | } |
322 | } |
323 | 323 | ||
324 | 324 | ||
325 | # PASSE 6: sort l'index mis à jour des ref à l'aide des labels créés auparavant et rajoute |
325 | # PASSE 6: sort l'index mis à jour des ref à l'aide des labels créés auparavant et rajoute |
326 | #TODO rajouter eqref mais ca dépend vraiment de la phrase ! |
326 | #TODO rajouter eqref mais ca dépend vraiment de la phrase ! |
327 | for my $tag (keys %{$hash{text}}) { |
327 | for my $tag (keys %{$hash{text}}) { |
328 | my $macro = '\\\\ref|\\\\cite|\\\\eqref'; |
328 | my $macro = '\\\\ref|\\\\cite|\\\\eqref'; |
329 | my $T = $hash{text}{$tag}; |
329 | my $T = $hash{text}{$tag}; |
330 | my $cle = 'prev|next|upbl|titb|keyw|datm'; |
330 | my $cle = 'prev|next|upbl|titb|keyw|datm'; |
331 | $T =~ s/($macro)\{([^}]+)\}\{([^}]+)\}/store_ref($2, $3, $2, \%hash_bloc)/eg; |
331 | $T =~ s/($macro)\{([^}]+)\}\{([^}]+)\}/store_ref($2, $3, $2, \%hash_bloc)/eg; |
332 | # repere toto~\cite{} |
332 | # repere toto~\cite{} |
333 | $T =~ s/([^\s]+)\~($macro)\s*([.*])?\s*\{([^}]+)\}/store_ref($4, $1 . |
333 | $T =~ s/([^\s]+)\~($macro)\s*([.*])?\s*\{([^}]+)\}/store_ref($4, $1 . |
334 | ($3||''), $4, \%hash_bloc)/eg; |
334 | ($3||''), $4, \%hash_bloc)/eg; |
335 | $T =~ s/($macro)\s*([.*])?\{([^}]+)\}/store_ref($3, ($2 ? "$3: $2" : $3), $3, \%hash_bloc)/eg; |
335 | $T =~ s/($macro)\s*([.*])?\{([^}]+)\}/store_ref($3, ($2 ? "$3: $2" : $3), $3, \%hash_bloc)/eg; |
336 | $T =~ s/\\($cle)\s*\{(\w*)\}/store_tag($1, $2, $tag, \%hash, \%hash_bloc)/eg; |
336 | $T =~ s/\\($cle)\s*\{(\w*)\}/store_tag($1, $2, $tag, \%hash, \%hash_bloc)/eg; |
337 | $hash{text}{$tag} = $T; |
337 | $hash{text}{$tag} = $T; |
338 | } |
338 | } |
339 | my @ListIndex = sort {$a cmp $b} (keys %{$hash_index{page}}) ; |
339 | my @ListIndex = sort {$a cmp $b} (keys %{$hash_index{page}}) ; |
340 | out('index', selection('<div class="index">' . makeindex (\%hash_index, 0, @ListIndex) . '</div>' |
340 | out('index', selection('<div class="index">' . makeindex (\%hash_index, 0, @ListIndex) . '</div>' |
341 | ,'left-selection','index')) if ((@ListIndex) && $INDEX == 1 && makeindex (\%hash_index)); |
341 | ,'left-selection','index')) if ((@ListIndex) && $INDEX == 1 && makeindex (\%hash_index)); |
342 | 342 | ||
343 | #crée les blocs [entourés de la table des matières] |
343 | #crée les blocs [entourés de la table des matières] |
344 | 344 | ||
345 | #crée les deux sortes de fichiers demandés par wims .def (fichier de définition général) + |
345 | #crée les deux sortes de fichiers demandés par wims .def (fichier de définition général) + |
346 | # nom.hd qui gère les règles de navigation pour chaque bloc |
346 | # nom.hd qui gère les règles de navigation pour chaque bloc |
347 | #attention : dans le cas où il y a un \\embed{toto}, il faut créer le fichier toto.hd ... |
347 | #attention : dans le cas où il y a un \\embed{toto}, il faut créer le fichier toto.hd ... |
348 | #TODO : \embed{toto} : je suppose ici que le contenu de toto est du wims à ne pas |
348 | #TODO : \embed{toto} : je suppose ici que le contenu de toto est du wims à ne pas |
349 | #interpréter |
349 | #interpréter |
350 | #pour l'instant je m'en suis servi pour stocker des programmes qui interviennent plusieurs fois. |
350 | #pour l'instant je m'en suis servi pour stocker des programmes qui interviennent plusieurs fois. |
351 | 351 | ||
352 | #Crée le vrai fichier qui est mis dans le dossier src |
352 | #Crée le vrai fichier qui est mis dans le dossier src |
353 | #On ne met pas de table de matières si le bloc est de type fold |
353 | #On ne met pas de table de matières si le bloc est de type fold |
354 | #TODO option = chemin tout seul, toc à gauche + chemin, toc à gauche et à droite + chemin, |
354 | #TODO option = chemin tout seul, toc à gauche + chemin, toc à gauche et à droite + chemin, |
355 | #style selection droite, selection gauche |
355 | #style selection droite, selection gauche |
356 | 356 | ||
357 | for my $tag (keys %{$hash{text}}) { |
357 | for my $tag (keys %{$hash{text}}) { |
358 | complete ($tag, \%hash); |
358 | complete ($tag, \%hash); |
359 | out ("$tag.hd", hd($tag,\%hash)); |
359 | out ("$tag.hd", hd($tag,\%hash)); |
360 | my $txt = traitement_final($hash{text}{$tag}); |
360 | my $txt = traitement_final($hash{text}{$tag}); |
361 | my $tagupbl = $hash{upbl}{$tag}; |
361 | my $tagupbl = $hash{upbl}{$tag}; |
362 | my $type = $hash{type}{$tag} ; |
362 | my $type = $hash{type}{$tag} ; |
363 | my $style = $hash{style}{$tag}; |
363 | my $style = $hash{style}{$tag}; |
364 | #si type est non vide il est égal à embed ou fold |
364 | #si type est non vide il est égal à embed ou fold |
Line 368... | Line 368... | ||
368 | my $dotoc_down = ($OPTION =~ /toc_down/ && !$type); |
368 | my $dotoc_down = ($OPTION =~ /toc_down/ && !$type); |
369 | my $CHEMIN = chemin($tag, \%hash); |
369 | my $CHEMIN = chemin($tag, \%hash); |
370 | #J'ai enlevé $LOAD |
370 | #J'ai enlevé $LOAD |
371 | $CHEMIN = ($dotoc_up || $dotoc_down) && ($CHEMIN =~ $FLECHE) ? $CHEMIN : ''; |
371 | $CHEMIN = ($dotoc_up || $dotoc_down) && ($CHEMIN =~ $FLECHE) ? $CHEMIN : ''; |
372 | my $CHEMIN_up=($dotoc_up) ? "<div id=\"up_toc\">$CHEMIN</div>": '' ; |
372 | my $CHEMIN_up=($dotoc_up) ? "<div id=\"up_toc\">$CHEMIN</div>": '' ; |
373 | my $CHEMIN_down=($dotoc_down) ? "<div id=\"down_toc\">$CHEMIN</div>" : '' ; |
373 | my $CHEMIN_down=($dotoc_down) ? "<div id=\"down_toc\">$CHEMIN</div>" : '' ; |
374 | my @Chemin = split(',', $hash{chemin}{$tag}); |
374 | my @Chemin = split(',', $hash{chemin}{$tag}); |
375 | my $TOCg = $dotoc_left ? selection($hash{toc}{main}, 'left_selection', @Chemin) : ''; |
375 | my $TOCg = $dotoc_left ? selection($hash{toc}{main}, 'left_selection', @Chemin) : ''; |
376 | my $TOCd = ($dotoc_right && $tag ne 'main' && (!($dotoc_left) || $tagupbl ne 'main' )) ? selection($hash{toc}{$tagupbl}, 'right_selection', @Chemin) : ''; |
376 | my $TOCd = ($dotoc_right && $tag ne 'main' && (!($dotoc_left) || $tagupbl ne 'main' )) ? selection($hash{toc}{$tagupbl}, 'right_selection', @Chemin) : ''; |
377 | 377 | ||
378 | my $tit_index = ($hash{titb}{index})? $hash{titb}{index} : 'Index' ; |
378 | my $tit_index = ($hash{titb}{index})? $hash{titb}{index} : 'Index' ; |
379 | my $index = ($INDEX == 1 && (@ListIndex)) ? "<li>\\link{index}{$tit_index}</li>" : ''; |
379 | my $index = ($INDEX == 1 && (@ListIndex)) ? "<li>\\link{index}{$tit_index}</li>" : ''; |
380 | my $tooltip = ""; |
380 | my $tooltip = ""; |
381 | ##$txt="<div class=\"fold\"> ".$txt ."<\/div>" if ($type=~/fold/) ; |
381 | ##$txt="<div class=\"fold\"> ".$txt ."<\/div>" if ($type=~/fold/) ; |
382 | my $pat= '<br\s+class="spacer"\s*/>'; |
382 | my $pat= '<br\s+class="spacer"\s*/>'; |
Line 432... | Line 432... | ||
432 | $ref->{prev}{$id} = $idold; |
432 | $ref->{prev}{$id} = $idold; |
433 | $ref->{next}{$idold} = $id; |
433 | $ref->{next}{$idold} = $id; |
434 | #modifier avec selection |
434 | #modifier avec selection |
435 | my $tp = '' ; |
435 | my $tp = '' ; |
436 | if ($TOOLTIP==1) { |
436 | if ($TOOLTIP==1) { |
437 | if (!$ref->{toctip}{$Id}) {$ref->{toctip}{$Id}=($ref->{tittoc}{$id}) ? |
437 | if (!$ref->{toctip}{$Id}) {$ref->{toctip}{$Id}=($ref->{tittoc}{$id}) ? |
438 | "<li>\\link{$id}{$ref->{tittoc}{$id}}</li>": '' ; } |
438 | "<li>\\link{$id}{$ref->{tittoc}{$id}}</li>": '' ; } |
439 | else { |
439 | else { |
440 | $ref->{toctip}{$Id} .= ($ref->{tittoc}{$id}) ? "<li>\\link{$id}{$ref->{tittoc}{$id}}</li>": '' ; |
440 | $ref->{toctip}{$Id} .= ($ref->{tittoc}{$id}) ? "<li>\\link{$id}{$ref->{tittoc}{$id}}</li>": '' ; |
441 | } |
441 | } |
442 | #$ref->{toctip}{$Id} .= $ref->{tittoc}{$id} ; |
442 | #$ref->{toctip}{$Id} .= $ref->{tittoc}{$id} ; |
443 | $tp = "ZZZZZ$id" ; } |
443 | $tp = "ZZZZZ$id" ; } |
Line 455... | Line 455... | ||
455 | $ref->{$cle}{$tag} = $ref_bloc->{fichier}{$label} ; |
455 | $ref->{$cle}{$tag} = $ref_bloc->{fichier}{$label} ; |
456 | ''; |
456 | ''; |
457 | } |
457 | } |
458 | 458 | ||
459 | sub store_label { my ($label, $Id, $ref) = @_; |
459 | sub store_label { my ($label, $Id, $ref) = @_; |
460 | $ref->{fichier}{$label} = $Id; |
460 | $ref->{fichier}{$label} = $Id; |
461 | "<a id=\"$label\"></a>"; |
461 | "<a id=\"$label\"></a>"; |
462 | } |
462 | } |
463 | 463 | ||
464 | sub dbg { print STDERR "$_[0]\n" if ($verbose); } |
464 | sub dbg { print STDERR "$_[0]\n" if ($verbose); } |
465 | 465 | ||
466 | sub store_index { my ($label, $Id, $ref_index) = @_; |
466 | sub store_index { my ($label, $Id, $ref_index) = @_; |
467 | dbg("... index: \"$label\""); |
467 | dbg("... index: \"$label\""); |
468 | my $L = $ref_index->{page}{$label}; |
468 | my $L = $ref_index->{page}{$label}; |
469 | $ref_index->{page}{$label} = !$L ? $Id : "$L,$Id"; |
469 | $ref_index->{page}{$label} = !$L ? $Id : "$L,$Id"; |
470 | "<a id=\"$label\"></a>"; |
470 | "<a id=\"$label\"></a>"; |
471 | } |
471 | } |
472 | 472 | ||
473 | sub class_index { my ($index,$level) = @_ ; |
473 | sub class_index { my ($index,$level) = @_ ; |
474 | my @a = split('!', $index) ; |
474 | my @a = split('!', $index) ; |
475 | ($a[$level])? $a[$level] : $index ; |
475 | ($a[$level])? $a[$level] : $index ; |
476 | } |
476 | } |
477 | #!(keys %{$ref_index->{page}} |
477 | #!(keys %{$ref_index->{page}} |
478 | #sort keys %{$ref_index->{page}} ; |
478 | #sort keys %{$ref_index->{page}} ; |
479 | 479 | ||
480 | sub makeindex { my ($ref_index, $level, @L ) = @_; |
480 | sub makeindex { my ($ref_index, $level, @L ) = @_; |
481 | return '' if (!$#L) ; |
481 | return '' if (!$#L) ; |
482 | my $dejavu = '' ; |
482 | my $dejavu = '' ; |
483 | my $TEXT = "\n<ul class=\"index\">"; |
483 | my $TEXT = "\n<ul class=\"index\">"; |
484 | for my $index (@L) { |
484 | for my $index (@L) { |
485 | next if ($dejavu =~ /\b$index\b/) ; |
485 | next if ($dejavu =~ /\b$index\b/) ; |
486 | my @list = sort {$a cmp $b} grep {class_index($_, $level) eq class_index($index, $level)} @L ; |
486 | my @list = sort {$a cmp $b} grep {class_index($_, $level) eq class_index($index, $level)} @L ; |
487 | my @l = split('!', $index) ; |
487 | my @l = split('!', $index) ; |
488 | if ($l[$level]) { |
488 | if ($l[$level]) { |
489 | $TEXT .= "<li> " ; |
489 | $TEXT .= "<li> " ; |
490 | for my $ind (split(',',$ref_index->{page}{$index})) { |
490 | for my $ind (split(',',$ref_index->{page}{$index})) { |
491 | if ($ind && !($dejavu =~ /\b$ind\b/)) { |
491 | if ($ind && !($dejavu =~ /\b$ind\b/)) { |
492 | $TEXT .= "\\link{$ind}{". $l[$level] . " }{$ind}" ; |
492 | $TEXT .= "\\link{$ind}{". $l[$level] . " }{$ind}" ; |
493 | } |
493 | } |
494 | } |
494 | } |
495 | $dejavu .= ' ' . join (' , ', @list) ; |
495 | $dejavu .= ' ' . join (' , ', @list) ; |
496 | $TEXT .= makeindex ($ref_index, $level + 1, @list) . "</li>" ; |
496 | $TEXT .= makeindex ($ref_index, $level + 1, @list) . "</li>" ; |
Line 504... | Line 504... | ||
504 | #0 ul et li sans rien |
504 | #0 ul et li sans rien |
505 | #1 avec style |
505 | #1 avec style |
506 | $TEXT =~ s/\\(begin|end)\s*{wimsonly}//g; |
506 | $TEXT =~ s/\\(begin|end)\s*{wimsonly}//g; |
507 | for my $rubrique (keys %{$ref_env->{list}}) { |
507 | for my $rubrique (keys %{$ref_env->{list}}) { |
508 | $TEXT = traite_list ($TEXT, $ref, $ref_env, $Id, $rubrique,1); |
508 | $TEXT = traite_list ($TEXT, $ref, $ref_env, $Id, $rubrique,1); |
509 | } |
509 | } |
510 | 510 | ||
511 | for my $rubrique (@liste_env_list) { |
511 | for my $rubrique (@liste_env_list) { |
512 | $TEXT = traite_list ($TEXT, $ref, $ref_env, $Id, $rubrique,0); |
512 | $TEXT = traite_list ($TEXT, $ref, $ref_env, $Id, $rubrique,0); |
513 | } |
513 | } |
514 | 514 | ||
515 | for my $rubrique (keys %{$ref_env->{tabular}}) { |
515 | for my $rubrique (keys %{$ref_env->{tabular}}) { |
516 | if ($TEXT =~ /\\begin{$rubrique}/) { |
516 | if ($TEXT =~ /\\begin{$rubrique}/) { |
517 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique,0); |
517 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique,0); |
518 | } |
518 | } |
519 | } |
519 | } |
520 | 520 | ||
521 | for my $rubrique (@liste_env_tabular) { |
521 | for my $rubrique (@liste_env_tabular) { |
522 | if ($TEXT =~ /\\begin{$rubrique}/) { |
522 | if ($TEXT =~ /\\begin{$rubrique}/) { |
523 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique,0); |
523 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique,0); |
524 | } |
524 | } |
525 | } |
525 | } |
526 | 526 | ||
527 | for my $rubrique (@liste_env_spec) { |
527 | for my $rubrique (@liste_env_spec) { |
528 | if ($TEXT =~ /\\begin{$rubrique(\*)?}/) { |
528 | if ($TEXT =~ /\\begin{$rubrique(\*)?}/) { |
529 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique, 1); |
529 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique, 1); |
530 | } |
530 | } |
531 | } |
531 | } |
532 | #le 1 et 0 servent à initialiser le compteur dans le cas ou on doit créer de nouveaux blocs dans la même page |
532 | #le 1 et 0 servent à initialiser le compteur dans le cas ou on doit créer de nouveaux blocs dans la même page |
533 | 533 | ||
534 | for my $rubrique (keys %{$ref_env->{titre}}) { |
534 | for my $rubrique (keys %{$ref_env->{titre}}) { |
535 | if ($TEXT =~ /\\begin{$rubrique}/) { |
535 | if ($TEXT =~ /\\begin{$rubrique}/) { |
536 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique,1); |
536 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique,1); |
537 | } |
537 | } |
538 | } |
538 | } |
539 | for my $rubrique (keys %{$ref_env->{list}}) { |
539 | for my $rubrique (keys %{$ref_env->{list}}) { |
540 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique,0); |
540 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique,0); |
541 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique . '_item',0); |
541 | $TEXT = traite_environ ($TEXT, $ref, $ref_env, $Id, $rubrique . '_item',0); |
542 | } |
542 | } |
543 | 543 | ||
544 | if ($TEXT =~ /\\begin\{\s*(\w*)\s*\}/g) { |
544 | if ($TEXT =~ /\\begin\{\s*(\w*)\s*\}/g) { |
545 | warn " ATTENTION : environnement non répertorié : $1" if $1 ne 'matrix' && $1 ne 'split'; |
545 | warn " ATTENTION : environnement non répertorié : $1" if $1 ne 'matrix' && $1 ne 'split'; |
546 | } |
546 | } |
547 | $TEXT =~ s,<li>\n+</li>,<li></li>,g; |
547 | $TEXT =~ s,<li>\n+</li>,<li></li>,g; |
548 | $TEXT =~ s,</div>\s+</div>,</div></div>,g; |
548 | $TEXT =~ s,</div>\s+</div>,</div></div>,g; |
Line 564... | Line 564... | ||
564 | $e_item = "\\end{$environ\_item}" ; |
564 | $e_item = "\\end{$environ\_item}" ; |
565 | $b_item = "\\begin{$environ\_item}" ; |
565 | $b_item = "\\begin{$environ\_item}" ; |
566 | my $style = $ref_env->{style}{$environ} ; |
566 | my $style = $ref_env->{style}{$environ} ; |
567 | $style = ($style) ? $style : $environ; |
567 | $style = ($style) ? $style : $environ; |
568 | $b_class= "ul class=\"$style\"" ; |
568 | $b_class= "ul class=\"$style\"" ; |
569 | $e_class= "\/ul" ; |
569 | $e_class= "\/ul" ; |
570 | } |
570 | } |
571 | { |
571 | { |
572 | if ($environ eq 'enumerate'){ $b_class = "ol class=\"enumerate\"" ; $e_class= "\/ol" ; } |
572 | if ($environ eq 'enumerate'){ $b_class = "ol class=\"enumerate\"" ; $e_class= "\/ol" ; } |
573 | elsif ($environ eq 'itemize'){ $b_class = "ul class=\"itemize\"" ; $e_class= "\/ul" ;} |
573 | elsif ($environ eq 'itemize'){ $b_class = "ul class=\"itemize\"" ; $e_class= "\/ul" ;} |
574 | elsif ($environ eq 'description'){ |
574 | elsif ($environ eq 'description'){ |
575 | $b_class = "ul style=\"list-style:none;\"" ; |
575 | $b_class = "ul style=\"list-style:none;\"" ; |
576 | $e_class= "\/ul" ; |
576 | $e_class= "\/ul" ; |
577 | $e_item = "\\end{$environ\_item}" ; |
577 | $e_item = "\\end{$environ\_item}" ; |
578 | $b_item = "\\begin{$environ\_item}" |
578 | $b_item = "\\begin{$environ\_item}" |
579 | } |
579 | } |
580 | elsif ($environ eq 'trivlist') { $b_class = "ul style=\"list-style:none;\"" ; |
580 | elsif ($environ eq 'trivlist') { $b_class = "ul style=\"list-style:none;\"" ; |
581 | $e_class= "\/ul" ; |
581 | $e_class= "\/ul" ; |
582 | } |
582 | } |
583 | }; |
583 | }; |
584 | $TEXT =~ s/\\begin{$environ(\*)?}/<$environ>/g; |
584 | $TEXT =~ s/\\begin{$environ(\*)?}/<$environ>/g; |
585 | $TEXT =~ s|\\end{$environ(\*)?}|<\/$environ>|g; |
585 | $TEXT =~ s|\\end{$environ(\*)?}|<\/$environ>|g; |
586 | 586 | ||
587 | my @decoup = split ("<$environ>", $TEXT); |
587 | my @decoup = split ("<$environ>", $TEXT); |
588 | 588 | ||
589 | my $a = join ("<$environ>", @decoup[1..$#decoup]); |
589 | my $a = join ("<$environ>", @decoup[1..$#decoup]); |
590 | return $TEXT if (!$a) ; |
590 | return $TEXT if (!$a) ; |
591 | my @u = extract_tagged ("<$environ>$a", "<$environ>"); |
591 | my @u = extract_tagged ("<$environ>$a", "<$environ>"); |
592 | my $milieu = "<$environ>" . $u[4] . "<\/$environ>" ; |
592 | my $milieu = "<$environ>" . $u[4] . "<\/$environ>" ; |
593 | #FIXME pas de listes emboitées de type différent ! |
593 | #FIXME pas de listes emboitées de type différent ! |
594 | $milieu =~ s|<$environ>\s*\\item|<$environ><li>$b_item|g ; |
594 | $milieu =~ s|<$environ>\s*\\item|<$environ><li>$b_item|g ; |
595 | $milieu =~ s|</$environ>|</li><$e_class>|g; |
595 | $milieu =~ s|</$environ>|</li><$e_class>|g; |
596 | $milieu =~ s|\\item|$e_item</li><li>$b_item|g; |
596 | $milieu =~ s|\\item|$e_item</li><li>$b_item|g; |
597 | $milieu =~ s|</li><$e_class>|$e_item</li><$e_class>|g; |
597 | $milieu =~ s|</li><$e_class>|$e_item</li><$e_class>|g; |
598 | $milieu =~ s|<$environ>|<$b_class>|g; |
598 | $milieu =~ s|<$environ>|<$b_class>|g; |
599 | $decoup[0] . $milieu . traite_list ($u[1], $ref, $ref_env, $Id, $environ,$option); |
599 | $decoup[0] . $milieu . traite_list ($u[1], $ref, $ref_env, $Id, $environ,$option); |
600 | } |
600 | } |
601 | 601 | ||
602 | sub traite_environ {my ($TEXT, $ref, $ref_env, $Id, $environ, $cnt) = @_; |
602 | sub traite_environ {my ($TEXT, $ref, $ref_env, $Id, $environ, $cnt) = @_; |
603 | $TEXT =~ s/\\begin{$environ\*?}/<$environ>/g; |
603 | $TEXT =~ s/\\begin{$environ\*?}/<$environ>/g; |
604 | $TEXT =~ s|\\end{$environ\*?}|</$environ>|g; |
604 | $TEXT =~ s|\\end{$environ\*?}|</$environ>|g; |
605 | 605 | ||
606 | my @decoup = split ("<$environ>", $TEXT); |
606 | my @decoup = split ("<$environ>", $TEXT); |
607 | 607 | ||
608 | my $a = join ("<$environ>", @decoup[1..$#decoup]); |
608 | my $a = join ("<$environ>", @decoup[1..$#decoup]); |
609 | return $TEXT if (!$a); |
609 | return $TEXT if (!$a); |
610 | 610 | ||
611 | my @u = extract_tagged ("<$environ>$a", "<$environ>"); |
611 | my @u = extract_tagged ("<$environ>$a", "<$environ>"); |
612 | my $milieu = $u[4]; |
612 | my $milieu = $u[4]; |
613 | return $TEXT if (!$milieu); |
613 | return $TEXT if (!$milieu); |
614 | 614 | ||
615 | my $pat_env = join('|', @liste_env_spec); |
615 | my $pat_env = join('|', @liste_env_spec); |
616 | my $patt_env = join('|', @liste_env_tabular); |
616 | my $patt_env = join('|', @liste_env_tabular); |
617 | if ($environ =~ /\b($pat_env)\b/) { $milieu = $1->($milieu) ; } |
617 | if ($environ =~ /\b($pat_env)\b/) { $milieu = $1->($milieu) ; } |
618 | elsif ($environ =~ /\b($patt_env)\b/) { $milieu = tabular->($milieu,$environ) ; } |
618 | elsif ($environ =~ /\b($patt_env)\b/) { $milieu = tabular->($milieu,$environ) ; } |
619 | else { my @milieu1 = extract_bracketed ($milieu, '{}'); |
619 | else { my @milieu1 = extract_bracketed ($milieu, '{}'); |
620 | if ($milieu1[0]) { $milieu = $milieu1[4] ; }; |
620 | if ($milieu1[0]) { $milieu = $milieu1[4] ; }; |
621 | my $type = $ref_env->{type}{$environ}; |
621 | my $type = $ref_env->{type}{$environ}; |
Line 633... | Line 633... | ||
633 | $ref->{text}{$newtag} = encadrement("<$environ>$milieu<\/$environ>", $environ, $ref_env); |
633 | $ref->{text}{$newtag} = encadrement("<$environ>$milieu<\/$environ>", $environ, $ref_env); |
634 | $ref->{upbl}{$newtag} = $Id; |
634 | $ref->{upbl}{$newtag} = $Id; |
635 | $milieu = "\n\\$type\{$newtag\}\{" |
635 | $milieu = "\n\\$type\{$newtag\}\{" |
636 | . encadr_defaut("<$environ>$titre<\/$environ>", $environ, $ref_env,'titre') |
636 | . encadr_defaut("<$environ>$titre<\/$environ>", $environ, $ref_env,'titre') |
637 | . "\}\n" ; |
637 | . "\}\n" ; |
638 | } else { my $milieu1 = $milieu ; |
638 | } else { my $milieu1 = $milieu ; |
639 | $milieu = encadrement("<$environ>$milieu<\/$environ>", $environ, $ref_env, 'full'); |
639 | $milieu = encadrement("<$environ>$milieu<\/$environ>", $environ, $ref_env, 'full'); |
640 | } |
640 | } |
641 | } |
641 | } |
642 | $decoup[0] . $milieu . traite_environ ($u[1], $ref, $ref_env, $Id, $environ, $cnt); |
642 | $decoup[0] . $milieu . traite_environ ($u[1], $ref, $ref_env, $Id, $environ, $cnt); |
643 | } |
643 | } |
Line 649... | Line 649... | ||
649 | $txt .= "!set $cle=$KEY\n" if ($KEY); |
649 | $txt .= "!set $cle=$KEY\n" if ($KEY); |
650 | } |
650 | } |
651 | $txt; |
651 | $txt; |
652 | } |
652 | } |
653 | #rajoute un next aux section/subsection/ si cela n'existe pas [dernier] dernier sur index si il y a |
653 | #rajoute un next aux section/subsection/ si cela n'existe pas [dernier] dernier sur index si il y a |
654 | #rajoute main pour ceux qui n'ont pas de parents. |
654 | #rajoute main pour ceux qui n'ont pas de parents. |
655 | sub complete {my ($tag, $ref) = @_; |
655 | sub complete {my ($tag, $ref) = @_; |
656 | $ref->{datm}{$tag} = isotime() if !($ref->{datm}{$tag}) ; |
656 | $ref->{datm}{$tag} = isotime() if !($ref->{datm}{$tag}) ; |
657 | $ref->{upbl}{$tag} = 'main' if !($ref->{upbl}{$tag}) ; |
657 | $ref->{upbl}{$tag} = 'main' if !($ref->{upbl}{$tag}) ; |
658 | my $upbl = $ref->{upbl}{$tag}; |
658 | my $upbl = $ref->{upbl}{$tag}; |
659 | if (!$ref->{next}{$tag}) { |
659 | if (!$ref->{next}{$tag}) { |
660 | my $a = $ref->{next}{$upbl}; |
660 | my $a = $ref->{next}{$upbl}; |
661 | $ref->{next}{$tag} = $a || 'main'; |
661 | $ref->{next}{$tag} = $a || 'main'; |
Line 678... | Line 678... | ||
678 | $ref_env->{style}{$rubrique} = $b; |
678 | $ref_env->{style}{$rubrique} = $b; |
679 | dbg("... environnement $rubrique sans style css, par defaut $rubrique") |
679 | dbg("... environnement $rubrique sans style css, par defaut $rubrique") |
680 | }; |
680 | }; |
681 | my $div_d = "<div class=\"l2w_content $b\">"; |
681 | my $div_d = "<div class=\"l2w_content $b\">"; |
682 | my $div_f = '</div>'; |
682 | my $div_f = '</div>'; |
683 | if ( $option eq 'titre') { |
683 | if ( $option eq 'titre') { |
684 | $TEXT =~ s/<$rubrique>/<span class=\"l2w_content $b\">/g; |
684 | $TEXT =~ s/<$rubrique>/<span class=\"l2w_content $b\">/g; |
685 | $TEXT =~ s/<\/$rubrique>/<\/span>\n/g; |
685 | $TEXT =~ s/<\/$rubrique>/<\/span>\n/g; |
686 | } elsif (!$a || $option eq 'bloc') { |
686 | } elsif (!$a || $option eq 'bloc') { |
687 | $TEXT =~ s/<$rubrique>\s*(\[[^\]]+\])?/$div_d/g; |
687 | $TEXT =~ s/<$rubrique>\s*(\[[^\]]+\])?/$div_d/g; |
688 | $TEXT =~ s/<\/$rubrique>/$div_f/g; |
688 | $TEXT =~ s/<\/$rubrique>/$div_f/g; |
689 | } elsif ($option eq 'full') { |
689 | } elsif ($option eq 'full') { |
690 | $TEXT =~ s/<$rubrique>\s*(\[[^\]]+\])/<h2 class=\"l2w_content $b\">$a $1<\/h2>$div_d/g; |
690 | $TEXT =~ s/<$rubrique>\s*(\[[^\]]+\])/<h2 class=\"l2w_content $b\">$a $1<\/h2>$div_d/g; |
691 | $TEXT =~ s/<$rubrique>/<h2 class=\"l2w_content $b\">$a<\/h2>$div_d/g; |
691 | $TEXT =~ s/<$rubrique>/<h2 class=\"l2w_content $b\">$a<\/h2>$div_d/g; |
692 | $TEXT =~ s/<\/$rubrique>/$div_f/g; |
692 | $TEXT =~ s/<\/$rubrique>/$div_f/g; |
693 | } else { |
693 | } else { |
694 | $TEXT =~ s/<$rubrique>/<span class=\"$b\">/g; |
694 | $TEXT =~ s/<$rubrique>/<span class=\"$b\">/g; |
695 | $TEXT =~ s/<\/$rubrique>/<\/span>\n/g; |
695 | $TEXT =~ s/<\/$rubrique>/<\/span>\n/g; |
696 | } |
696 | } |
697 | $TEXT; |
697 | $TEXT; |
698 | } |
698 | } |
699 | sub encadrement { my ($TEXT, $rubrique, $ref_env) = @_; |
699 | sub encadrement { my ($TEXT, $rubrique, $ref_env) = @_; |
700 | my $debut = $ref_env->{deb}{$rubrique}; |
700 | my $debut = $ref_env->{deb}{$rubrique}; |
701 | my $fin = $ref_env->{fin}{$rubrique}; |
701 | my $fin = $ref_env->{fin}{$rubrique}; |
702 | my $opt= ($ref_env->{type}{$rubrique} && $ref_env->{type}{$rubrique}=~ /fold/) ? 'bloc' : 'full' ; |
702 | my $opt= ($ref_env->{type}{$rubrique} && $ref_env->{type}{$rubrique}=~ /fold/) ? 'bloc' : 'full' ; |
703 | return encadr_defaut ($TEXT, $rubrique, $ref_env, $opt) if (!$debut && !$fin); |
703 | return encadr_defaut ($TEXT, $rubrique, $ref_env, $opt) if (!$debut && !$fin); |
704 | 704 | ||
705 | $TEXT =~ s/<$rubrique>//; |
705 | $TEXT =~ s/<$rubrique>//; |
706 | my $cnt_arg = $ref_env->{cnt_arg}{$rubrique}; |
706 | my $cnt_arg = $ref_env->{cnt_arg}{$rubrique}; |
707 | my $d = join(' ', subst($TEXT, $cnt_arg, $debut, $rubrique, $ref_env)); |
707 | my $d = join(' ', subst($TEXT, $cnt_arg, $debut, $rubrique, $ref_env)); |
Line 709... | Line 709... | ||
709 | $d =~ s/<\/$rubrique>/$com/; |
709 | $d =~ s/<\/$rubrique>/$com/; |
710 | $d; |
710 | $d; |
711 | } |
711 | } |
712 | 712 | ||
713 | 713 | ||
714 | sub tabular { my ( $b, $style ) = @_; |
714 | sub tabular { my ( $b, $style ) = @_; |
715 | my @v = extract_bracketed ($b, '{}') ; |
715 | my @v = extract_bracketed ($b, '{}') ; |
716 | my $stylerow = $style . "_row"; |
716 | my $stylerow = $style . "_row"; |
717 | my $stylecell = $style . "_cell"; |
717 | my $stylecell = $style . "_cell"; |
718 | $b = "<table class=\"$style\"><tr class=\"$stylerow\"><td class=\"$stylecell\">" . $v[1] . '</table>'; |
718 | $b = "<table class=\"$style\"><tr class=\"$stylerow\"><td class=\"$stylecell\">" . $v[1] . '</table>'; |
719 | $b =~ s|\&| </td><td class=\"$stylecell\"> |g; |
719 | $b =~ s|\&| </td><td class=\"$stylecell\"> |g; |
720 | $b =~ s/\\hline//g; |
720 | $b =~ s/\\hline//g; |
721 | $b =~ s|\\\\\s*</table>|</td></tr></table>|g; |
721 | $b =~ s|\\\\\s*</table>|</td></tr></table>|g; |
722 | my $par="\\\\\\(|\\\\\\)" ; |
722 | my $par="\\\\\\(|\\\\\\)" ; |
723 | my @dectab = split(/$par/, $b) ; |
723 | my @dectab = split(/$par/, $b) ; |
724 | $b = $dectab[0] ; |
724 | $b = $dectab[0] ; |
725 | $b =~ s|\\\\|</td></tr><tr class=\"$stylerow\"><td class=\"$stylecell\">|g; |
725 | $b =~ s|\\\\|</td></tr><tr class=\"$stylerow\"><td class=\"$stylecell\">|g; |
726 | my $cnt = 0; $b = '' ; |
726 | my $cnt = 0; $b = '' ; |
727 | while ($cnt <= $#dectab/2) { |
727 | while ($cnt <= $#dectab/2) { |
728 | my $c = $dectab[2*$cnt] ; |
728 | my $c = $dectab[2*$cnt] ; |
729 | $c =~ s|\\\\|</td></tr><tr class=\"stylerow\"><td class=\"$stylecell\">|g; |
729 | $c =~ s|\\\\|</td></tr><tr class=\"stylerow\"><td class=\"$stylecell\">|g; |
730 | $b .= $c . (($dectab[2*$cnt+1]) ? "\\(" . $dectab[2*$cnt+1] . "\\)" : '' ) ; |
730 | $b .= $c . (($dectab[2*$cnt+1]) ? "\\(" . $dectab[2*$cnt+1] . "\\)" : '' ) ; |
731 | $cnt ++ ; |
731 | $cnt ++ ; |
732 | }; |
732 | }; |
733 | $b ; |
733 | $b ; |
734 | } |
734 | } |
735 | 735 | ||
736 | ###demande de convertir d'abord de manière indépendante les pdf tiff eps svg en un format d'image png |
736 | ###demande de convertir d'abord de manière indépendante les pdf tiff eps svg en un format d'image png |
737 | sub includegraphics{ my ( $b, $opt ) = @_; |
737 | sub includegraphics{ my ( $b, $opt ) = @_; |
738 | $b=~ s/.(pdf|tiff|eps|svg)/.png/ ; |
738 | $b=~ s/.(pdf|tiff|eps|svg)/.png/ ; |
739 | $opt =~ s/.*(width|height)\s*=\s*([0-9]*\.?[0-9]*\s*)(\\(line|text)width)/linewidth("$2$3",$1)/eg; |
739 | $opt =~ s/.*(width|height)\s*=\s*([0-9]*\.?[0-9]*\s*)(\\(line|text)width)/linewidth("$2$3",$1)/eg; |
740 | $opt =~ s/.*(width|height)\s*=\s*([0-9]*\.?[0-9]*\s*)(cm|px)/ style=\"$1:$2$3;\"/; |
740 | $opt =~ s/.*(width|height)\s*=\s*([0-9]*\.?[0-9]*\s*)(cm|px)/ style=\"$1:$2$3;\"/; |
741 | "<img src=\"\\filedir\/$b\" $opt alt=\"\" />"; |
741 | "<img src=\"\\filedir\/$b\" $opt alt=\"\" />"; |
742 | } |
742 | } |
743 | 743 | ||
744 | sub minipage { my ( $b ) = @_; |
744 | sub minipage { my ( $b ) = @_; |
745 | my @v = extract_bracketed ($b, '[]') ; |
745 | my @v = extract_bracketed ($b, '[]') ; |
746 | my $option = $v[0] ; |
746 | my $option = $v[0] ; |
747 | if($option) { |
747 | if($option) { |
748 | $option=~ s/\[\s*b\s*\]/bottom/ ; |
748 | $option=~ s/\[\s*b\s*\]/bottom/ ; |
749 | $option=~ s/\[\s*t\s*\]/top/ ; |
749 | $option=~ s/\[\s*t\s*\]/top/ ; |
750 | $option=~ s/\[\s*c\s*\]/middle/ ; |
750 | $option=~ s/\[\s*c\s*\]/middle/ ; |
751 | $option=~ |
751 | $option=~ s/\[\s*\]/middle/; |
752 | } else { |
752 | } else { |
753 | $option='middle'} ; |
753 | $option='middle'} ; |
754 | @v = extract_bracketed ($v[1], '{}') ; |
754 | @v = extract_bracketed ($v[1], '{}') ; |
755 | my $width = $v[0] ; |
755 | my $width = $v[0] ; |
756 | $width =~ s/\{(.*)\}/$1/; |
756 | $width =~ s/\{(.*)\}/$1/; |
757 | $width = linewidth($width); |
757 | $width = linewidth($width); |
758 | "<div style=\"width:$width; display:inline-block;vertical-align:$option;\" class=\"minipage\"> |
758 | "<div style=\"width:$width; display:inline-block;vertical-align:$option;\" class=\"minipage\"> |
759 | $v[1] |
759 | $v[1] |
760 | </div>"; |
760 | </div>"; |
761 | } |
761 | } |
762 | sub columns { my ( $b ) = @_; |
762 | sub columns { my ( $b ) = @_; |
763 | "<div class=\"columns\">$b</div>" |
763 | "<div class=\"columns\">$b</div>" |
764 | } |
764 | } |
765 | 765 | ||
766 | sub column { my ( $b ) = @_; |
766 | sub column { my ( $b ) = @_; |
767 | my @v = extract_bracketed ($b, '[]') ; |
767 | my @v = extract_bracketed ($b, '[]') ; |
768 | my $option = ''; |
768 | my $option = ''; |
769 | $option= $v[0] ; |
769 | $option= $v[0] ; |
770 | if($option) { |
770 | if($option) { |
771 | $option=~ s/\[\s*b\s*\]/bottom/ ; |
771 | $option=~ s/\[\s*b\s*\]/bottom/ ; |
772 | $option=~ s/\[\s*t\s*\]/top/ ; |
772 | $option=~ s/\[\s*t\s*\]/top/ ; |
773 | $option=~ s/\[\s*c\s*\]/middle/ ; |
773 | $option=~ s/\[\s*c\s*\]/middle/ ; |
774 | $option=~s/\[\s*\]/middle/; |
774 | $option=~s/\[\s*\]/middle/; |
775 | } |
775 | } |
776 | else{ $option='top'} ; |
776 | else{ $option='top'} ; |
777 | @v = extract_bracketed ($v[1], '{}') ; |
777 | @v = extract_bracketed ($v[1], '{}') ; |
778 | my $width = $v[0] ; |
778 | my $width = $v[0] ; |
779 | $width =~ s/\{(.*)\}/$1/; |
779 | $width =~ s/\{(.*)\}/$1/; |
780 | $width = linewidth($width) ; |
780 | $width = linewidth($width) ; |
781 | "<div style=\"width:$width; display:inline-block;vertical-align:$option;\" class=\"column\"> |
781 | "<div style=\"width:$width; display:inline-block;vertical-align:$option;\" class=\"column\"> |
782 | $v[1] |
782 | $v[1] |
783 | </div>"; |
783 | </div>"; |
784 | } |
784 | } |
785 | 785 | ||
786 | 786 | ||
787 | sub lstlisting { my ($b,$id ) = @_ ; |
787 | sub lstlisting { my ($b,$id ) = @_ ; |
Line 801... | Line 801... | ||
801 | } |
801 | } |
802 | 802 | ||
803 | sub equation { my ( $b) = @_; |
803 | sub equation { my ( $b) = @_; |
804 | $b = "\\( $b \\)"; |
804 | $b = "\\( $b \\)"; |
805 | if ($b =~ s/\\label{([^\}]+)}//) { $b = "\\label{$1}" . $b }; |
805 | if ($b =~ s/\\label{([^\}]+)}//) { $b = "\\label{$1}" . $b }; |
- | 806 | $b =~ s/\n{2,}/\n/; |
|
806 | '<div class="math">' . $b . '</div>' ; |
807 | '<div class="math">' . $b . '</div>' ; |
807 | } |
808 | } |
808 | 809 | ||
809 | sub align1 { my ( $b) = @_; |
810 | sub align1 { my ( $b) = @_; |
810 | $b = "\\(\\begin{matrix} $b \\end{matrix} \\)"; |
811 | $b = "\\(\\begin{matrix} $b \\end{matrix} \\)"; |
Line 850... | Line 851... | ||
850 | } |
851 | } |
851 | 852 | ||
852 | sub displaymath {"<div class=\"math\">\\(\\displaystyle{ " . $_[0]. "}\\)</div>"; } |
853 | sub displaymath {"<div class=\"math\">\\(\\displaystyle{ " . $_[0]. "}\\)</div>"; } |
853 | sub math {" \\( " . $_[0]. "\\) "; } |
854 | sub math {" \\( " . $_[0]. "\\) "; } |
854 | 855 | ||
- | 856 | sub figure { my $caption=''; |
|
- | 857 | if ( $_[0] =~ s/\\caption\{([^}]+)}//) {$caption=$1 }; |
|
- | 858 | "<div class=\"figure\"> " . |
|
- | 859 | (($caption) ? "<div class=\"caption\">". $caption . "</div>":"") |
|
- | 860 | . $_[0] . "</div>" ;} |
|
855 | 861 | ||
856 | sub thebibliography { my ( $b ) = @_; |
862 | sub thebibliography { my ( $b ) = @_; |
857 | $b =~ s/\\bibitem{([^}]+)}/<\/li>\n<li>\[$1\]\\label{$1} /g; |
863 | $b =~ s/\\bibitem{([^}]+)}/<\/li>\n<li>\[$1\]\\label{$1} /g; |
858 | $b =~ s/\{\d+\}\s*<\/li>//; |
864 | $b =~ s/\{\d+\}\s*<\/li>//; |
859 | '<h2 class="thebibliography">' . $hash{titb}{ref} |
865 | '<h2 class="thebibliography">' . $hash{titb}{ref} |
860 | . "</h2>\n<ul class=\"thebibliography\">$b </li></ul>\n"; |
866 | . "</h2>\n<ul class=\"thebibliography\">$b </li></ul>\n"; |
861 | } |
867 | } |
862 | sub pspicture { '<p>dessin à faire dans wims</p>' ; } |
868 | sub pspicture { '<p>dessin à faire dans wims</p>' ; } |
863 | sub picture { '<p>dessin à faire dans wims</p>' ; } |
869 | sub picture { '<p>dessin à faire dans wims</p>' ; } |
864 | 870 | ||
Line 897... | Line 903... | ||
897 | $ref_command->{cnt_arg}{$id} = $narg; |
903 | $ref_command->{cnt_arg}{$id} = $narg; |
898 | $ref_command->{definition}{$id} = $val; |
904 | $ref_command->{definition}{$id} = $val; |
899 | dbg("... commande perso \"$id\": argument: \"$narg\" definition: \"$val\""); |
905 | dbg("... commande perso \"$id\": argument: \"$narg\" definition: \"$val\""); |
900 | '' ; |
906 | '' ; |
901 | } |
907 | } |
902 | 908 | ||
903 | sub store_environ { my ($def, $cmd, $narg, $titre, $deb, $fin, $ref_env) = @_; |
909 | sub store_environ { my ($def, $cmd, $narg, $titre, $deb, $fin, $ref_env) = @_; |
904 | my $origin = $ref_env->{origin}{$cmd}; |
910 | my $origin = $ref_env->{origin}{$cmd}; |
905 | return '' if ($origin && $origin eq 'environmentwims' && $def ne 'environmentwims'); |
911 | return '' if ($origin && $origin eq 'environmentwims' && $def ne 'environmentwims'); |
906 | $ref_env->{deb}{$cmd} = $deb; |
912 | $ref_env->{deb}{$cmd} = $deb; |
907 | $ref_env->{fin}{$cmd} = $fin; |
913 | $ref_env->{fin}{$cmd} = $fin; |
Line 911... | Line 917... | ||
911 | $titre=$hash_command{definition}{$1} if $hash_command{definition}{$1} |
917 | $titre=$hash_command{definition}{$1} if $hash_command{definition}{$1} |
912 | } |
918 | } |
913 | $ref_env->{titre}{$cmd} = $titre; |
919 | $ref_env->{titre}{$cmd} = $titre; |
914 | $ref_env->{origin}{$cmd} = $def; |
920 | $ref_env->{origin}{$cmd} = $def; |
915 | my $style = $ref_env->{style}{$cmd} ; |
921 | my $style = $ref_env->{style}{$cmd} ; |
916 | $style = ($style)? $style : $cmd ; |
922 | $style = ($style)? $style : $cmd ; |
917 | #if (!$ref_env->{deb}{$cmd}) { $ref_env->{deb}{$cmd} = "<div class=\"$style\"> "; } |
923 | #if (!$ref_env->{deb}{$cmd}) { $ref_env->{deb}{$cmd} = "<div class=\"$style\"> "; } |
918 | #if (!$ref_env->{fin}{$cmd}) { $ref_env->{fin}{$cmd} = "</div> "; } |
924 | #if (!$ref_env->{fin}{$cmd}) { $ref_env->{fin}{$cmd} = "</div> "; } |
919 | dbg("... environnement perso \"$cmd\" argument: \"$narg\" titre: \"$titre\" style: \"$style\" debut: \"$deb\" fin: \"$fin\""); |
925 | dbg("... environnement perso \"$cmd\" argument: \"$narg\" titre: \"$titre\" style: \"$style\" debut: \"$deb\" fin: \"$fin\""); |
920 | ''; |
926 | ''; |
921 | } |
927 | } |
922 | 928 | ||
923 | 929 | ||
924 | sub recup_command {my ($TEXT, $ref_command) = @_; |
930 | sub recup_command {my ($TEXT, $ref_command) = @_; |
925 | my $DEF = '(defwims|def|newcommand|renewcommand)'; |
931 | my $DEF = '(defwims|def|newcommand|renewcommand)'; |
926 | #FIXME ? mauvais pour def \def\toto#1#2 ... demander de le refaire avec defwims s'il y a plus de 3 arguments ? |
932 | #FIXME ? mauvais pour def \def\toto#1#2 ... demander de le refaire avec defwims s'il y a plus de 3 arguments ? |
927 | $TEXT =~ s/\\$DEF\s*\\(\w*)#(\d)\{(.*)\}/store_cmd($1,$2,$3,$4,$ref_command)/eg; |
933 | $TEXT =~ s/\\$DEF\s*\\(\w*)#(\d)\{(.*)\}/store_cmd($1,$2,$3,$4,$ref_command)/eg; |
928 | #2 arguments |
934 | #2 arguments |
929 | $TEXT =~ s/\\$DEF\s*\\(\w*)#(\d)#(\d)\{(.*)\}/store_cmd($1,$2,$4,$5,$ref_command)/eg; |
935 | $TEXT =~ s/\\$DEF\s*\\(\w*)#(\d)#(\d)\{(.*)\}/store_cmd($1,$2,$4,$5,$ref_command)/eg; |
930 | $TEXT =~ s/\\$DEF\s*\\(\w*)\s*\{(.*)\}/store_cmd($1,$2,0,$3,$ref_command)/eg; |
936 | $TEXT =~ s/\\$DEF\s*\\(\w*)\s*\{(.*)\}/store_cmd($1,$2,0,$3,$ref_command)/eg; |
931 | #3 arguments |
937 | #3 arguments |
Line 946... | Line 952... | ||
946 | if ($cmd eq 'tablewims') { $type = 'tabular' ; }; |
952 | if ($cmd eq 'tablewims') { $type = 'tabular' ; }; |
947 | if ($cmd eq 'listwims') { $type = 'list' }; |
953 | if ($cmd eq 'listwims') { $type = 'list' }; |
948 | for my $rubrique (@L) { |
954 | for my $rubrique (@L) { |
949 | $ref_env->{$type}{$rubrique} = $style; |
955 | $ref_env->{$type}{$rubrique} = $style; |
950 | dbg("... commande $rubrique de $type $style"); |
956 | dbg("... commande $rubrique de $type $style"); |
951 | if ($cmd eq 'listwims') { $ref_env->{'style'}{$rubrique . '_item'} = $style . '_item' ; |
957 | if ($cmd eq 'listwims') { $ref_env->{'style'}{$rubrique . '_item'} = $style . '_item' ; |
952 | $ref_env->{'titre'}{$rubrique . '_item'} = '' } |
958 | $ref_env->{'titre'}{$rubrique . '_item'} = '' } |
953 | } |
959 | } |
954 | push @liste_env_tabular, (keys %{$ref_env->{tabular}}) ; |
960 | push @liste_env_tabular, (keys %{$ref_env->{tabular}}) ; |
955 | ''; |
961 | ''; |
956 | } |
962 | } |
957 | sub recup_environ {my ($TEXT, $ref_env) = @_; |
963 | sub recup_environ {my ($TEXT, $ref_env) = @_; |
958 | my $pat = '\s*\{(.*)\}'; |
964 | my $pat = '\s*\{(.*)\}'; |
959 | $TEXT =~ s/\\(typefold|typelink|samestyle|listwims|tablewims)\{([^\}]+)\}/recup_config($1,$2, $ref_env)/eg; |
965 | $TEXT =~ s/\\(typefold|typelink|samestyle|listwims|tablewims)\{([^\}]+)\}/recup_config($1,$2, $ref_env)/eg; |
Line 991... | Line 997... | ||
991 | @a = extract_tagged($TEXT, '\[','\]'); |
997 | @a = extract_tagged($TEXT, '\[','\]'); |
992 | ($u,$v) = ($a[1],$a[4]); |
998 | ($u,$v) = ($a[1],$a[4]); |
993 | } |
999 | } |
994 | $TEXT = $u; |
1000 | $TEXT = $u; |
995 | $cnt ++; |
1001 | $cnt ++; |
996 | my $sub="" ; |
1002 | my $sub="" ; |
997 | if ($v) { |
1003 | if ($v) { |
998 | $sub = $environ && $ref_env->{titre}{$environ} ? join (' ' , ( $ref_env->{titre}{$environ}, $v)) : $v;} |
1004 | $sub = $environ && $ref_env->{titre}{$environ} ? join (' ' , ( $ref_env->{titre}{$environ}, $v)) : $v;} |
999 | else {$sub=''} ; |
1005 | else {$sub=''} ; |
1000 | if (($com) && ("#$cnt")) { $com =~ s/#$cnt/$sub/ge ; } ; |
1006 | if (($com) && ("#$cnt")) { $com =~ s/#$cnt/$sub/ge ; } ; |
1001 | } |
1007 | } |
1002 | ($com, $TEXT); |
1008 | ($com, $TEXT); |
1003 | } |
1009 | } |
1004 | 1010 | ||
1005 | sub Traite_command { my ($TEXT, $command, $ref_command) = @_; |
1011 | sub Traite_command { my ($TEXT, $command, $ref_command) = @_; |
Line 1039... | Line 1045... | ||
1039 | open (OUT, ">$BASE0/$bloc") || die "peut pas créer $BASE0/$bloc"; |
1045 | open (OUT, ">$BASE0/$bloc") || die "peut pas créer $BASE0/$bloc"; |
1040 | print OUT $text ; close OUT; |
1046 | print OUT $text ; close OUT; |
1041 | } |
1047 | } |
1042 | 1048 | ||
1043 | # PASSE 1: développe 'input/include' |
1049 | # PASSE 1: développe 'input/include' |
1044 | sub find_expand { my ($file) = @_; |
1050 | sub find_expand { my ($file) = @_; |
1045 | if (!open(IN, $DIR . $file)) { warn "$DIR$file n'existe pas"; return; } |
1051 | if (!open(IN, $DIR . $file)) { warn "$DIR$file n'existe pas"; return; } |
1046 | dbg("... lecture de $file"); |
1052 | dbg("... lecture de $file"); |
1047 | my $text = <IN>; close(IN); |
1053 | my $text = <IN>; close(IN); |
1048 | $text =~ s/([^%]\s*\\end{document})[[:print:][:space:]]+/$1/; |
1054 | $text =~ s/([^%]\s*\\end{document})[[:print:][:space:]]+/$1/; |
1049 | $text =~ s/([^%])\s*\\endinput[[:print:][:space:]]+/$1/; |
1055 | $text =~ s/([^%])\s*\\endinput[[:print:][:space:]]+/$1/; |
1050 | $text =~ s/\%\\(input|include|wimsinclude)([^\n]+)?//g; |
1056 | $text =~ s/\%\\(input|include|wimsinclude)([^\n]+)?//g; |
1051 | $text =~ s/\\(input|include|wimsinclude)\s*{?([a-zA-Z0-9\-_\/]+)\.(sty|tex)\s*}?/find_expand("$2.$3")/eg; |
1057 | $text =~ s/\\(input|include|wimsinclude)\s*{?([a-zA-Z0-9\-_\/]+)\.(sty|tex)\s*}?/find_expand("$2.$3")/eg; |
1052 | $text =~ s/\\lstinputlisting\s*\{([a-zA-Z0-9\-_\/\.]+)\s*\}/"\\begin\{lstlisting\}\n" . find_expand($1) . "\n\\end\{lstlisting\}"/eg; |
1058 | $text =~ s/\\lstinputlisting\s*\{([a-zA-Z0-9\-_\/\.]+)\s*\}/"\\begin\{lstlisting\}\n" . find_expand($1) . "\n\\end\{lstlisting\}"/eg; |
1053 | 1059 | ||
1054 | $text; |
1060 | $text; |
1055 | } |
1061 | } |
1056 | 1062 | ||
1057 | sub open_close { my ($sec, $cnt, $entre) = @_; |
1063 | sub open_close { my ($sec, $cnt, $entre) = @_; |
1058 | my ($txt) = ''; |
1064 | my ($txt) = ''; |
Line 1068... | Line 1074... | ||
1068 | $SEC_MIN_GLOBAL = $ind if ($ind < $SEC_MIN_GLOBAL && $ind); |
1074 | $SEC_MIN_GLOBAL = $ind if ($ind < $SEC_MIN_GLOBAL && $ind); |
1069 | } |
1075 | } |
1070 | $txt; |
1076 | $txt; |
1071 | } |
1077 | } |
1072 | 1078 | ||
1073 | sub cnt_section { my ($sec, $cnt) = @_ ; |
1079 | sub cnt_section { my ($sec, $cnt) = @_ ; |
1074 | my ($txt) = ''; |
1080 | my ($txt) = ''; |
1075 | my ($ind) = $hash_secinv{$sec}; |
1081 | my ($ind) = $hash_secinv{$sec}; |
1076 | $SEC_MIN_GLOBAL = $ind if ($ind < $SEC_MIN_GLOBAL && $ind); |
1082 | $SEC_MIN_GLOBAL = $ind if ($ind < $SEC_MIN_GLOBAL && $ind); |
1077 | "<$sec>" |
1083 | "<$sec>" |
1078 | } |
1084 | } |
1079 | 1085 | ||
1080 | 1086 | ||
1081 | sub store { my ($ref, $cle, $id, $text, $court) = @_ ; |
1087 | sub store { my ($ref, $cle, $id, $text, $court) = @_ ; |
1082 | $ref->{$cle}{$id}=$text ; |
1088 | $ref->{$cle}{$id}=$text ; |
1083 | if (defined($court)) { $court =~ s/\[|\]//g ; $ref->{tittoc}{$id} = $court ; } ; |
1089 | if (defined($court)) { $court =~ s/\[|\]//g ; $ref->{tittoc}{$id} = $court ; } ; |
1084 | ''; |
1090 | ''; |
1085 | } |
1091 | } |
Line 1087... | Line 1093... | ||
1087 | if ($A =~ s/numero//) { $NUMERO = 1 ;} ; |
1093 | if ($A =~ s/numero//) { $NUMERO = 1 ;} ; |
1088 | if ($A =~ s/index//) { $INDEX = 1 ;} |
1094 | if ($A =~ s/index//) { $INDEX = 1 ;} |
1089 | if ($A =~ s/tooltip//) { $TOOLTIP = 1 ;} |
1095 | if ($A =~ s/tooltip//) { $TOOLTIP = 1 ;} |
1090 | if ($A =~ s/depth\s*=\s*([0-8])//) { $depth = $1 ; } |
1096 | if ($A =~ s/depth\s*=\s*([0-8])//) { $depth = $1 ; } |
1091 | $OPTION .= $A ; |
1097 | $OPTION .= $A ; |
1092 | '' ; |
1098 | '' ; |
1093 | } |
1099 | } |
1094 | 1100 | ||
1095 | sub store_include { my ($A) = @_ ; $A = join(' ' , split(',', $A)) ; |
1101 | sub store_include { my ($A) = @_ ; $A = join(' ' , split(',', $A)) ; |
1096 | if ($A =~ s/(\w*)\.(tex|sty)//) { |
1102 | if ($A =~ s/(\w*)\.(tex|sty)//) { |
1097 | if ($MACRO) {$MACRO .= ",$1.$2" } else {$MACRO = "$1.$2" } |
1103 | if ($MACRO) {$MACRO .= ",$1.$2" } else {$MACRO = "$1.$2" } |
1098 | }; |
1104 | }; |
1099 | if ($A =~ s/(\w*\.css)\b//) { if ($STYLE) {$STYLE .= ",$1" } else {$STYLE = $1 } }; |
1105 | if ($A =~ s/(\w*\.css)\b//) { if ($STYLE) {$STYLE .= ",$1" } else {$STYLE = $1 } }; |
1100 | if ($A =~ s/embed\s*=\s*([^}]+)//) { $EMBED = $1 ; } |
1106 | if ($A =~ s/embed\s*=\s*([^}]+)//) { $EMBED = $1 ; } |
1101 | '' ; |
1107 | '' ; |
1102 | } |
1108 | } |
1103 | 1109 | ||
1104 | sub add { my ($a,$b)=@_ ; |
1110 | sub add { my ($a,$b)=@_ ; |
1105 | if ($a) {$a .= ",$b" } else {$a = $b } |
1111 | if ($a) {$a .= ",$b" } else {$a = $b } |
1106 | } |
1112 | } |
1107 | 1113 | ||
1108 | sub Init { my ($file, $ref_env, $ref_command, $ref, $ref_algo) = @_; |
1114 | sub Init { my ($file, $ref_env, $ref_command, $ref, $ref_algo) = @_; |
1109 | my ($total, $TEXT) = (0, find_expand($file)); |
1115 | my ($total, $TEXT) = (0, find_expand($file)); |
1110 | my %hash_spec = (wims =>{}, verbatim =>{}, lstlisting => {}); |
1116 | my %hash_spec = (wims =>{}, verbatim =>{}, lstlisting => {}); |
Line 1115... | Line 1121... | ||
1115 | $TEXT = traitement_initial ($TEXT); |
1121 | $TEXT = traitement_initial ($TEXT); |
1116 | $TEXT =~ s/\\wimsoption\s*\{([^\}]+)\}/store_option($1)/eg ; |
1122 | $TEXT =~ s/\\wimsoption\s*\{([^\}]+)\}/store_option($1)/eg ; |
1117 | $TEXT =~ s/\\makeindex/store_option('index')/eg ; |
1123 | $TEXT =~ s/\\makeindex/store_option('index')/eg ; |
1118 | $TEXT =~ s/\\wimsinclude\s*\{([^\}]+)\}/store_include($1)/eg ; |
1124 | $TEXT =~ s/\\wimsinclude\s*\{([^\}]+)\}/store_include($1)/eg ; |
1119 | $TEXT =~ s/\\(title|email|author|about)\s*(\[[^\]]+\])?\s*\{([^\}]+)\}/store($ref,$1,'main',$3,$2)/eg ; |
1125 | $TEXT =~ s/\\(title|email|author|about)\s*(\[[^\]]+\])?\s*\{([^\}]+)\}/store($ref,$1,'main',$3,$2)/eg ; |
1120 | 1126 | ||
1121 | $TEXT = traite_preambule ($TEXT, $ref_env, $ref_command, $ref); |
1127 | $TEXT = traite_preambule ($TEXT, $ref_env, $ref_command, $ref); |
1122 | for my $command (keys %{$ref_command->{definition}}) { |
1128 | for my $command (keys %{$ref_command->{definition}}) { |
1123 | $TEXT = Traite_command ($TEXT, $command, $ref_command); |
1129 | $TEXT = Traite_command ($TEXT, $command, $ref_command); |
1124 | } |
1130 | } |
1125 | for my $A (@liste_voca) { |
1131 | for my $A (@liste_voca) { |
Line 1141... | Line 1147... | ||
1141 | # $TEXT =~ s/~/ /g; |
1147 | # $TEXT =~ s/~/ /g; |
1142 | $TEXT =~ s:(<br class="spacer" />\s*<br class="spacer" />):<br class="spacer" />:g; |
1148 | $TEXT =~ s:(<br class="spacer" />\s*<br class="spacer" />):<br class="spacer" />:g; |
1143 | $TEXT =~ s:<br class="spacer" />\s*(</?div):$1:g; |
1149 | $TEXT =~ s:<br class="spacer" />\s*(</?div):$1:g; |
1144 | $TEXT =~ s:(class="minipage">)\s*<br class="spacer" />:$1:g; |
1150 | $TEXT =~ s:(class="minipage">)\s*<br class="spacer" />:$1:g; |
1145 | $TEXT; |
1151 | $TEXT; |
1146 | } |
1152 | } |
1147 | 1153 | ||
1148 | sub traitemath {my ($txt) = @_; |
1154 | sub traitemath {my ($txt) = @_; |
1149 | my $test = 0; |
1155 | my $test = 0; |
1150 | while ($txt =~ /\$\$/) { |
1156 | while ($txt =~ /\$\$/) { |
1151 | $txt = $` . ($test == 0 ? '<div class="math">\\(\\displaystyle{' : '}\\)</div>') . $'; |
1157 | $txt = $` . ($test == 0 ? '<div class="math">\\(\\displaystyle{' : '}\\)</div>') . $'; |
Line 1154... | Line 1160... | ||
1154 | $txt; |
1160 | $txt; |
1155 | } |
1161 | } |
1156 | 1162 | ||
1157 | sub traitement_initial { my ($TEXT) = @_; |
1163 | sub traitement_initial { my ($TEXT) = @_; |
1158 | $TEXT =~ s/\s*$//; # strip trailing whitespace |
1164 | $TEXT =~ s/\s*$//; # strip trailing whitespace |
1159 | $TEXT =~ s/\r\n/\n/gs ; |
1165 | $TEXT =~ s/\r\n/\n/gs ; |
1160 | $TEXT = traitemath($TEXT); |
1166 | $TEXT = traitemath($TEXT); |
1161 | $TEXT =~ s/{\s*\\(bf|tt|it)\b/\\text$1\{/g; |
1167 | $TEXT =~ s/{\s*\\(bf|tt|it)\b/\\text$1\{/g; |
1162 | $TEXT =~ s/\\begin\b\s*/\\begin/g; |
1168 | $TEXT =~ s/\\begin\b\s*/\\begin/g; |
1163 | $TEXT =~ s/\\end\b\s*/\\end/g; |
1169 | $TEXT =~ s/\\end\b\s*/\\end/g; |
1164 | #$TEXT =~ s/\\text\b/\\hbox/g; |
1170 | #$TEXT =~ s/\\text\b/\\hbox/g; |
Line 1199... | Line 1205... | ||
1199 | $TEXT =~ s/\\\"\s*o/ö/g; |
1205 | $TEXT =~ s/\\\"\s*o/ö/g; |
1200 | $TEXT =~ s/\\\`\s*o/ò/g; |
1206 | $TEXT =~ s/\\\`\s*o/ò/g; |
1201 | $TEXT =~ s/\\\^\s*u/û/g; |
1207 | $TEXT =~ s/\\\^\s*u/û/g; |
1202 | $TEXT =~ s/\\`\s*u/ù/g; |
1208 | $TEXT =~ s/\\`\s*u/ù/g; |
1203 | $TEXT =~ s/\\c \s*c/ç/g; |
1209 | $TEXT =~ s/\\c \s*c/ç/g; |
1204 | 1210 | ||
1205 | $TEXT =~ s/{\s*\\`\s*a\s*}/à/g; |
1211 | $TEXT =~ s/{\s*\\`\s*a\s*}/à/g; |
1206 | $TEXT =~ s/{\s*\\\^\s*a\s*}/â/g; |
1212 | $TEXT =~ s/{\s*\\\^\s*a\s*}/â/g; |
1207 | $TEXT =~ s/{\s*\\'\s*a\s*}/á/g; |
1213 | $TEXT =~ s/{\s*\\'\s*a\s*}/á/g; |
1208 | $TEXT =~ s/{\s*\\'\s*e\s*}/é/g; |
1214 | $TEXT =~ s/{\s*\\'\s*e\s*}/é/g; |
1209 | $TEXT =~ s/{\s*\\`\s*e\s*}/è/g; |
1215 | $TEXT =~ s/{\s*\\`\s*e\s*}/è/g; |
Line 1230... | Line 1236... | ||
1230 | $TEXT =~ s/\\onslide<[0-9]*>//g; |
1236 | $TEXT =~ s/\\onslide<[0-9]*>//g; |
1231 | $TEXT =~ s/\\onslide\+<[0-9]*\-[0-9]*>//g; |
1237 | $TEXT =~ s/\\onslide\+<[0-9]*\-[0-9]*>//g; |
1232 | $TEXT =~ s/\\onslide<[0-9]*\-[0-9]*->//g; |
1238 | $TEXT =~ s/\\onslide<[0-9]*\-[0-9]*->//g; |
1233 | $TEXT =~ s/\\onslide<[0-9]*\-[0-9]*>//g; |
1239 | $TEXT =~ s/\\onslide<[0-9]*\-[0-9]*>//g; |
1234 | $TEXT =~ s/\[<\+->\]//g; |
1240 | $TEXT =~ s/\[<\+->\]//g; |
1235 | 1241 | ||
1236 | # MODIF YVES NOEL 19/09/2011 (fin) |
1242 | # MODIF YVES NOEL 19/09/2011 (fin) |
1237 | $TEXT =~ s/{}//g; |
1243 | $TEXT =~ s/{}//g; |
1238 | $TEXT =~ s/\\selectlanguage{french}\\sffamily//g; |
1244 | $TEXT =~ s/\\selectlanguage{french}\\sffamily//g; |
1239 | 1245 | ||
1240 | #$TEXT =~ s/([^\\])\%+/$1/g; |
1246 | #$TEXT =~ s/([^\\])\%+/$1/g; |
1241 | $TEXT =~ s/([^\\])\%.*/$1/g; |
1247 | $TEXT =~ s/([^\\])\%.*/$1/g; |
1242 | $TEXT =~ s/\n\%.*/\n/g; |
1248 | $TEXT =~ s/\n\%.*/\n/g; |
1243 | $TEXT =~ s/\\\\\[\S*\]/\n\n/g; |
1249 | $TEXT =~ s/\\\\\[\S*\]/\n\n/g; |
1244 | $TEXT =~ s/\\(vspace|hspace|vskip|hskip)\**{\S*}//g; |
1250 | $TEXT =~ s/\\(vspace|hspace|vskip|hskip)\**{\S*}//g; |
Line 1251... | Line 1257... | ||
1251 | #utiliser verb uniquement dans le cas d'un mot |
1257 | #utiliser verb uniquement dans le cas d'un mot |
1252 | #FIXME: $TEXT =~ s/\verb"([^"]+)"/<tt class=verb>$1<\/tt>/g; |
1258 | #FIXME: $TEXT =~ s/\verb"([^"]+)"/<tt class=verb>$1<\/tt>/g; |
1253 | $TEXT =~ s/\\includegraphics\s*\[(.*)\]\s*{(.*)}/includegraphics($2,$1)/eg; |
1259 | $TEXT =~ s/\\includegraphics\s*\[(.*)\]\s*{(.*)}/includegraphics($2,$1)/eg; |
1254 | $TEXT =~ s/\\includegraphics\s*{([^}]+)}/includegraphics($1)/eg; |
1260 | $TEXT =~ s/\\includegraphics\s*{([^}]+)}/includegraphics($1)/eg; |
1255 | $TEXT =~ s/\\(begin|end){document}/\\document /g; |
1261 | $TEXT =~ s/\\(begin|end){document}/\\document /g; |
1256 | $TEXT =~ s/\\exercise{module=([^\&]+)\&([^}]+)}{([^}]+)}/store_sheet($1,$2,$3,$worksheet)/eg ; |
1262 | $TEXT =~ s/\\exercise{module=([^\&]+)\&([^}]+)}{([^}]+)}/store_sheet($1,$2,$3,$worksheet)/eg ; |
1257 | $TEXT =~ s/\\xspace//g; |
1263 | $TEXT =~ s/\\xspace//g; |
1258 | $TEXT = traite_beamer($TEXT) ; |
1264 | $TEXT = traite_beamer($TEXT) ; |
1259 | $TEXT; |
1265 | $TEXT; |
1260 | } |
1266 | } |
1261 | 1267 | ||
1262 | sub traite_beamer { my ($TEXT) = @_; |
1268 | sub traite_beamer { my ($TEXT) = @_; |
1263 | $TEXT =~ s/\\uncover\s*(<([^>]+)>)?\s*{(.*)}/\\fold{.}{-->}{$3}/g ; |
1269 | $TEXT =~ s/\\uncover\s*(<([^>]+)>)?\s*{(.*)}/\\fold{.}{-->}{$3}/g ; |
1264 | $TEXT =~ s/\s*\\frametitle{([^}]+)}/store_frametitle($1)/ge; |
1270 | $TEXT =~ s/\s*\\frametitle{([^}]+)}/store_frametitle($1)/ge; |
1265 | $TEXT =~ s/\\pause//g; |
1271 | $TEXT =~ s/\\pause//g; |
1266 | $TEXT ; |
1272 | $TEXT ; |
1267 | } |
1273 | } |
1268 | 1274 | ||
1269 | sub store_frametitle{ my ($TEXT)= @_ ; |
1275 | sub store_frametitle{ my ($TEXT)= @_ ; |
1270 | "<div class=\"frametitle\">$TEXT</div>" |
1276 | "<div class=\"frametitle\">$TEXT</div>" |
1271 | } |
1277 | } |
1272 | sub linewidth { my ($line,$w)= @_ ; |
1278 | sub linewidth { my ($line,$w)= @_ ; |
1273 | $line =~ s/1\.[0]\s*\\(line|text)width/100\%/g; |
1279 | $line =~ s/1\.[0]\s*\\(line|text)width/100\%/g; |
1274 | $line =~ s/0?\.([0-9])\s*\\(line|text)width/$1 0\%/g; |
1280 | $line =~ s/0?\.([0-9])\s*\\(line|text)width/$1 0\%/g; |
1275 | $line =~ s/0?\.([0-9]{2})[0-9]?\s*\\(line|text)width/$1\%/g; |
1281 | $line =~ s/0?\.([0-9]{2})[0-9]?\s*\\(line|text)width/$1\%/g; |
1276 | $line =~ s/ //g; |
1282 | $line =~ s/ //g; |
1277 | $line = "$w=\"$line\"" if ($w) ; |
1283 | $line = "$w=\"$line\"" if ($w) ; |
1278 | $line ; |
1284 | $line ; |
1279 | } |
1285 | } |
1280 | sub store_sheet { my ($ad1,$ad2,$titre,$worksheet) = @_ ; |
1286 | sub store_sheet { my ($ad1,$ad2,$titre,$worksheet) = @_ ; |
1281 | $ad2 =~ s/worksheet=(\d)+//g ; |
1287 | $ad2 =~ s/worksheet=(\d)+//g ; |
1282 | $SHEET .= ":$ad1\n$ad2\n$titre\n\n" ; |
1288 | $SHEET .= ":$ad1\n$ad2\n$titre\n\n" ; |
1283 | "\\exercise\{module=$ad1\&$ad2\&worksheet=$worksheet\}\{$titre\}" ; |
1289 | "\\exercise\{module=$ad1\&$ad2\&worksheet=$worksheet\}\{$titre\}" ; |
1284 | } |
1290 | } |
1285 | 1291 | ||
1286 | sub traite_preambule { my ($TEXT, $ref_env, $ref_command, $ref) = @_; |
1292 | sub traite_preambule { my ($TEXT, $ref_env, $ref_command, $ref) = @_; |
1287 | if ($TEXT=~ s/\\usepackage\[([^]]+)\]\{algorithmic\}//) { |
1293 | if ($TEXT=~ s/\\usepackage\[([^]]+)\]\{algorithmic\}//) { |
1288 | $algo_noend = 1 if ($1 =~ /noend/); |
1294 | $algo_noend = 1 if ($1 =~ /noend/); |
1289 | }; |
1295 | }; |
1290 | $TEXT = recup_command($TEXT, $ref_command); |
1296 | $TEXT = recup_command($TEXT, $ref_command); |
1291 | $TEXT = traite_command($TEXT, $ref_command); |
1297 | $TEXT = traite_command($TEXT, $ref_command); |
1292 | $TEXT = recup_environ($TEXT, $ref_env); |
1298 | $TEXT = recup_environ($TEXT, $ref_env); |
1293 | 1299 | ||
1294 | 1300 | ||
1295 | $TEXT = recup_embed($TEXT, $ref) ; |
1301 | $TEXT = recup_embed($TEXT, $ref) ; |
1296 | for my $cmd ('ref','index') { |
1302 | for my $cmd ('ref','index') { |
1297 | $ref->{titb}{$cmd} = $ref_command->{definition}{$cmd . "name"} |
1303 | $ref->{titb}{$cmd} = $ref_command->{definition}{$cmd . "name"} |
1298 | } |
1304 | } |
1299 | $TEXT; |
1305 | $TEXT; |
1300 | } |
1306 | } |
1301 | 1307 | ||
1302 | sub store_embed { my ($id, $titre, $ref) = @_ ; |
1308 | sub store_embed { my ($id, $titre, $ref) = @_ ; |
Line 1325... | Line 1331... | ||
1325 | ($header_tmp = <IN>) =~ s/\n/\t/g; |
1331 | ($header_tmp = <IN>) =~ s/\n/\t/g; |
1326 | $header .= "\t $header_tmp" ; |
1332 | $header .= "\t $header_tmp" ; |
1327 | } |
1333 | } |
1328 | close IN; |
1334 | close IN; |
1329 | $header .= "\t<script type=\"text/javascript\">" |
1335 | $header .= "\t<script type=\"text/javascript\">" |
1330 | . "jQuery(function() {jQuery( \"#left_toc\" ).menu();});" |
1336 | . "jQuery(function() {jQuery( \"#left_toc\" ).menu();});" |
1331 | . "jQuery(function() {jQuery( \"#right_toc\" ).menu();});" |
1337 | . "jQuery(function() {jQuery( \"#right_toc\" ).menu();});" |
1332 | . "</script>" if ($TOOLTIP==1); |
1338 | . "</script>" if ($TOOLTIP==1); |
1333 | 1339 | ||
1334 | "copyright=gnu |
1340 | "copyright=gnu |
1335 | docopen=yes |
1341 | docopen=yes |
1336 | dlang=fr |
1342 | dlang=fr |
1337 | tit=$tit |
1343 | tit=$tit |
1338 | author=$aut |
1344 | author=$aut |
Line 1343... | Line 1349... | ||
1343 | #TODO en fait il faudrait renvoyer dans le cas ou le fichier est de type fold à la page en dessus |
1349 | #TODO en fait il faudrait renvoyer dans le cas ou le fichier est de type fold à la page en dessus |
1344 | # dépliée. Je ne suis pas sure de savoir faire ! sinon, on perd la table des matières. |
1350 | # dépliée. Je ne suis pas sure de savoir faire ! sinon, on perd la table des matières. |
1345 | 1351 | ||
1346 | sub store_ref { my ($link, $titre, $anchor, $ref_bloc) = @_; |
1352 | sub store_ref { my ($link, $titre, $anchor, $ref_bloc) = @_; |
1347 | my $txt = '' ; |
1353 | my $txt = '' ; |
1348 | my @list = (split(',', $link)) ; |
1354 | my @list = (split(',', $link)) ; |
1349 | for my $l (@list) { |
1355 | for my $l (@list) { |
1350 | dbg("... référence fichier: \"$l\" titre \"$l\""); |
1356 | dbg("... référence fichier: \"$l\" titre \"$l\""); |
1351 | my $page = $ref_bloc->{fichier}{$l} ; |
1357 | my $page = $ref_bloc->{fichier}{$l} ; |
1352 | warn "label $link n'existe pas" if !($page) ; |
1358 | warn "label $link n'existe pas" if !($page) ; |
1353 | $txt .= ($#list) ? " \\link{$page}{$l}{$anchor}": |
1359 | $txt .= ($#list) ? " \\link{$page}{$l}{$anchor}": |
Line 1358... | Line 1364... | ||
1358 | 1364 | ||
1359 | 1365 | ||
1360 | #crée la page |
1366 | #crée la page |
1361 | 1367 | ||
1362 | sub toc_HTML {my ($text, $toc_g, $toc_d, $CHEMIN_up, $CHEMIN_down, $index) = @_ ; |
1368 | sub toc_HTML {my ($text, $toc_g, $toc_d, $CHEMIN_up, $CHEMIN_down, $index) = @_ ; |
1363 | my $s='' ; |
1369 | my $s='' ; |
1364 | $s= "l" if($toc_g) ; $s .= "r" if($toc_d) ; |
1370 | $s= "l" if($toc_g) ; $s .= "r" if($toc_d) ; |
1365 | if (($toc_g) || ($toc_d)) { |
1371 | if (($toc_g) || ($toc_d)) { |
1366 | $CHEMIN_up . '<div class="doc_latex2wims' . $s . '">' |
1372 | $CHEMIN_up . '<div class="doc_latex2wims' . $s . '">' |
1367 | . (($toc_g) ? '<ul id="left_toc" class="left_toc">'. $toc_g |
1373 | . (($toc_g) ? '<ul id="left_toc" class="left_toc">'. $toc_g |
1368 | . $index . '</ul>' : '') |
1374 | . $index . '</ul>' : '') |
1369 | . '<div class="wimsdoc">' |
1375 | . '<div class="wimsdoc">' |
1370 | . $text |
1376 | . $text |
1371 | . '</div>' |
1377 | . '</div>' |
1372 | . (($toc_d) ? '<ul id="right_toc" class="right_toc">' |
1378 | . (($toc_d) ? '<ul id="right_toc" class="right_toc">' |
1373 | . $toc_d |
1379 | . $toc_d |
1374 | . '<div class="wimscenter">' |
1380 | . '<div class="wimscenter">' |
1375 | . $LOAD |
1381 | . $LOAD |
1376 | . '</div></div>' : '') |
1382 | . '</div></div>' : '') |
1377 | . $CHEMIN_down . |
1383 | . $CHEMIN_down . |
1378 | '</div>'; |
1384 | '</div>'; |
1379 | 1385 | ||
1380 | } |
1386 | } |
1381 | 1387 | ||
1382 | else {$CHEMIN_up . $text . $CHEMIN_down }; |
1388 | else {$CHEMIN_up . $text . $CHEMIN_down }; |
Line 1424... | Line 1430... | ||
1424 | # $ligne =~ s/\[/<i>/g; |
1430 | # $ligne =~ s/\[/<i>/g; |
1425 | # $ligne =~ s/\]/<\/i>/g; |
1431 | # $ligne =~ s/\]/<\/i>/g; |
1426 | my $cle = 'FOR|WHILE|IF|UNTIL|ELSE|ELSIF|REQUIRE|ENSURE|STATE|ENDFOR|ENDWHILE|ENDIF' ; |
1432 | my $cle = 'FOR|WHILE|IF|UNTIL|ELSE|ELSIF|REQUIRE|ENSURE|STATE|ENDFOR|ENDWHILE|ENDIF' ; |
1427 | if ($ligne =~ /\s*\\($cle)\s*(\[[^\]]+\]*)?\{([^\n]+)\}\s*([^\n]*)/) { |
1433 | if ($ligne =~ /\s*\\($cle)\s*(\[[^\]]+\]*)?\{([^\n]+)\}\s*([^\n]*)/) { |
1428 | ($ligne,$indent) = store_algo($3, $4, $1, $2, $indent) ; |
1434 | ($ligne,$indent) = store_algo($3, $4, $1, $2, $indent) ; |
1429 | } |
1435 | } |
1430 | if ($ligne =~ /\s*\\($cle)\s*(\[[^\]]+\]*)?\s*([^\n]*)/) {($ligne,$indent) = store_algo('',$3, $1, $2, $indent);} |
1436 | if ($ligne =~ /\s*\\($cle)\s*(\[[^\]]+\]*)?\s*([^\n]*)/) {($ligne,$indent) = store_algo('',$3, $1, $2, $indent);} |
1431 | #TODO accepter des commentaires de plusieurs lignes ; présentation |
1437 | #TODO accepter des commentaires de plusieurs lignes ; présentation |
1432 | #des commentaires ? |
1438 | #des commentaires ? |
1433 | if ($ligne =~ /^\s*\\COMMENT/) { $ligne = "<i>$ligne</i>\n" }; |
1439 | if ($ligne =~ /^\s*\\COMMENT/) { $ligne = "<i>$ligne</i>\n" }; |
1434 | $text .= "\n" . $ligne; |
1440 | $text .= "\n" . $ligne; |
Line 1436... | Line 1442... | ||
1436 | $text =~ s/(<br\s*\/>)+/<br \/>/g; |
1442 | $text =~ s/(<br\s*\/>)+/<br \/>/g; |
1437 | $text =~ s/(<br>)+/<br \/>/g; |
1443 | $text =~ s/(<br>)+/<br \/>/g; |
1438 | } |
1444 | } |
1439 | $text =~ s/\n/<br \/>/g; |
1445 | $text =~ s/\n/<br \/>/g; |
1440 | $text ; |
1446 | $text ; |
1441 | } |
1447 | } |
1442 | 1448 | ||
1443 | sub indent { my $espace = " " x 6 ; $espace x $_[0]; } |
1449 | sub indent { my $espace = " " x 6 ; $espace x $_[0]; } |
1444 | 1450 | ||
1445 | sub Numero { my ($id) = @_; |
1451 | sub Numero { my ($id) = @_; |
1446 | return '' if ($id =~ /F_[^S]\d/) || ($id =~ /L_/); #cela ne provient pas d'une section et co |
1452 | return '' if ($id =~ /F_[^S]\d/) || ($id =~ /L_/); #cela ne provient pas d'une section et co |
Line 1469... | Line 1475... | ||
1469 | $text =~ s/<YYYY="\w*">/<\/li>/g; |
1475 | $text =~ s/<YYYY="\w*">/<\/li>/g; |
1470 | $text =~ s/ZZZZZ(\w+)/store_tip($1,$ref)/ge; |
1476 | $text =~ s/ZZZZZ(\w+)/store_tip($1,$ref)/ge; |
1471 | $text; |
1477 | $text; |
1472 | } |
1478 | } |
1473 | 1479 | ||
1474 | sub store_tip { my ($tag,$ref)=@_ ; |
1480 | sub store_tip { my ($tag,$ref)=@_ ; |
1475 | my $tip = $ref->{toctip}{$tag} ; |
1481 | my $tip = $ref->{toctip}{$tag} ; |
1476 | my $title=$ref->{tittoc}{$tag} ; |
1482 | my $title=$ref->{tittoc}{$tag} ; |
1477 | #$tip =~ s/'/\\\\'/g if ($tip) ; |
1483 | #$tip =~ s/'/\\\\'/g if ($tip) ; |
1478 | $title =~ s/'/\\\\'/g if ($title) ; |
1484 | $title =~ s/'/\\\\'/g if ($title) ; |
1479 | $ref->{toctip}{$tag} ? "<ul>$tip</ul>" : '' ; |
1485 | $ref->{toctip}{$tag} ? "<ul>$tip</ul>" : '' ; |
1480 | } |
1486 | } |
1481 | 1487 | ||
1482 | sub chemin { my ($tag, $ref) = @_; |
1488 | sub chemin { my ($tag, $ref) = @_; |
1483 | my $tagsup = $tag; |
1489 | my $tagsup = $tag; |
1484 | my $ch = $tag; |
1490 | my $ch = $tag; |
Line 1496... | Line 1502... | ||
1496 | '<div class="wims_chemin">' . $LOAD . "$linkout $txt" . '</div>';} |
1502 | '<div class="wims_chemin">' . $LOAD . "$linkout $txt" . '</div>';} |
1497 | 1503 | ||
1498 | sub sortuniq { |
1504 | sub sortuniq { |
1499 | my $prev = "not $_[0]"; |
1505 | my $prev = "not $_[0]"; |
1500 | grep { $_ ne $prev && ($prev = $_, 1) } sort @_; |
1506 | grep { $_ ne $prev && ($prev = $_, 1) } sort @_; |
1501 | } |
1507 | } |
1502 | 1508 | ||
1503 | 1509 | ||
1504 | sub isotime { |
1510 | sub isotime { |
1505 | my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time); |
1511 | my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time); |
1506 | $year += 1900; |
1512 | $year += 1900; |
1507 | $mon += 1 ; $mday += 1 ; |
1513 | $mon += 1 ; $mday += 1 ; |
1508 | $mday = sprintf("%02d", $mday); |
1514 | $mday = sprintf("%02d", $mday); |
1509 | $mon = sprintf("%02d", $mon); |
1515 | $mon = sprintf("%02d", $mon); |
1510 | "$year-$mon-$mday $hour:$min:$sec"; |
1516 | "$year-$mon-$mday $hour:$min:$sec"; |
1511 | } |
1517 | } |
1512 | 1518 | ||
1513 | sub usage { |
1519 | sub usage { |
1514 | print STDERR << "EOT" |
1520 | print STDERR << "EOT" |
1515 | latex2wims [--style=style.css] [--macro=wims.sty] [--dir=dossier1] [--docdir=dossier2] [--embed=dossier3] [--verbose] file |
1521 | latex2wims [--style=style.css] [--macro=wims.sty] [--dir=dossier1] [--docdir=dossier2] [--embed=dossier3] [--verbose] file |
1516 | 1522 | ||
1517 | --style=style.css : style.css fichier de style css à utiliser |
1523 | --style=style.css : style.css fichier de style css à utiliser |
1518 | (peut aussi être mis dans le fichier file : \\wimsinclude{style.css}) |
1524 | (peut aussi être mis dans le fichier file : \\wimsinclude{style.css}) |
1519 | --macro=wims.sty : wims.sty fichier de style à utiliser |
1525 | --macro=wims.sty : wims.sty fichier de style à utiliser |
1520 | (peut aussi être mis dans le fichier file : \\wimsinclude{wims.sty}) |
1526 | (peut aussi être mis dans le fichier file : \\wimsinclude{wims.sty}) |
1521 | --dir=dossier1 : dossier1 est le répertoire où se trouvent tous les fichiers dont le fichier file |
1527 | --dir=dossier1 : dossier1 est le répertoire où se trouvent tous les fichiers dont le fichier file |
1522 | --docdir=dossier2 : dossier2 est le répertoire dans lequel sera créé le document |
1528 | --docdir=dossier2 : dossier2 est le répertoire dans lequel sera créé le document |
1523 | (un dossier dans le compte Modtool par exemple) |
1529 | (un dossier dans le compte Modtool par exemple) |
1524 | --embed=dossier3 : les fichiers de dossier3 sont appelés dans file |
1530 | --embed=dossier3 : les fichiers de dossier3 sont appelés dans file |
1525 | par la commande \embed{} (pour expert) |
1531 | par la commande \embed{} (pour expert) |
1526 | --verbose : détails |
1532 | --verbose : détails |
1527 | EOT |
1533 | EOT |
1528 | ; |
1534 | ; |
1529 | exit 1; |
1535 | exit 1; |
1530 | } |
1536 | } |
1531 | 1537 | ||
1532 | ##======================================================================## |
1538 | ##======================================================================## |
1533 | ## Adapted from work by OZAWA Sakuro <ozawa@prince.pe.u-tokyo.ac.jp> |
1539 | ## Adapted from work by OZAWA Sakuro <ozawa@prince.pe.u-tokyo.ac.jp> |
1534 | ## Copyright (c) 1995 OZAWA Sakuro. All rights reserved. This |
1540 | ## Copyright (c) 1995 OZAWA Sakuro. All rights reserved. This |
1535 | ## program is free software; you can redistribute it and/or modify |
1541 | ## program is free software; you can redistribute it and/or modify |
1536 | ## it under the same terms as Perl itself. |
1542 | ## it under the same terms as Perl itself. |