5 our ($nom, $dir, $ext) = fileparse($ARGV[0],qr{\..*});
6 our $tex = qx{cat $ARGV[0]};
8 ## === Filtres amont -----------------------------------------------------------
9 $tex =~ s{\\util\s+}{}g;
10 $tex =~ s/\\label\{.+?\}//g;
11 $tex =~ s/\\opt\s*\{/\\modifopt\{/g;
12 $tex =~ s{\\desc\s+}{§§desc§:}g;
13 $tex =~ s/\\textbf\s*\[(.+?)\]\s*(\{(?:[^\{\}]++|(?2))*\})/§§textbf§$1§$2§:/g;
14 $tex =~ s/\\centerline\s*(\{(?:[^\{\}]++|(?1))*\})/§§centerline§$1§:/g;
16 ## === Fichier temporaire et transformation ------------------------------------
17 open TMP, ">temp.tex";
21 qx{pandoc --ascii temp.tex -o temp.html};
23 our $html = qx{cat temp.html};
24 ## === Filtres aval ------------------------------------------------------------
25 $html =~ s/\&\#167\;/§/g;
26 $html =~ s/§§bks§:\s*/\&\#92\;/g;
27 $html =~ s{§§exem§:}{<u>Exemple(s)</u> : }g;
28 $html =~ s/§§textbf§(.*?)§\{(.*?)\}§:/<b>$2<\/b>/g;
29 $html =~ s/§§desc§:/<u>Description<\/u> : /g;
30 $html =~ s{§§opt§(.+?)§:}{<span style="color:blue">$1</span>}g;
31 $html =~ s{§§helpref§(.+?)§(.+?)§:}{&helpa($1,$2)}ge;
32 $html =~ s{§§span§co§(.+?)§:}{<span style="color:red">$1</span>}g;
33 $html =~ s{§§span§var§(.+?)§:}{<span style="font-style:italic;color:red">$1</span>}g;
34 $html =~ s{§§span§res§(.+?)§:}{<span style="color:magenta">$1</span>}g;
35 $html =~ s{§§textsl§(.+?)§:}{<span style="font-style:italic">$1</span>}g;
36 $html =~ s{§§centerline§\{(.+?)\}§:}{<div style="text-align:center">$1</div>}g;
37 $html =~ s{<h3 id="(.+?)">(.+?)</h3>}{&modh3($1,$2)}ge;
38 $html =~ s{<h2 id="(.+?)">(.+?)</h2>}{&modh2($1,$2)}ge;
41 ## === Fichier final -----------------------------------------------------------
42 open HTM, ">$nom.html";
49 \\newcommand{\\argu}[1]{<\\textit{#1}>}
50 \\newcommand{\\exem}{§§exem§:}
51 \\newcommand{\\Nil}{\\textit{Nil}}
52 \\newcommand{\\jump}{\\textit{jump}}
53 \\newcommand{\\var}[1]{§§span§var§#1§:}
54 \\newcommand{\\co}[1]{§§span§co§#1§:}
55 \\newcommand{\\res}[1]{§§span§res§#1§:}
56 \\newcommand{\\Mytextbf}[1]{\\textbf{#1}}
57 \\newcommand{\\textsl}[1]{§§textsl§#1§:}
58 \\newcommand{\\modifopt}[2]{§§opt§#1 := < #2 >§:}
59 \\newcommand{\\Helpref}[2]{§§helpref§#1§#2§:}
60 \\newcommand{\\bks}{§§bks§:}
66 if ("\U$i" eq "\U$c") {
67 return qq{<h3 id="$c">$c</h3>};
69 return qq{<h3 id="$i">$c</h3>};
75 if ("\U$i" eq "\U$c") {
76 return qq{<h2 id="$c">$c</h3>};
78 return qq{<h2 id="$i">$c</h3>};
86 return qq{<a href="#$b">$a</a>};