X-Git-Url: https://melusine.eu.org/syracuse/G/git/?p=geshi.git;a=blobdiff_plain;f=docs%2Ftexgraph%2Ftex2html;fp=docs%2Ftexgraph%2Ftex2html;h=d9d45e12eba86b25c4c3a3d4f7f0a5a306957f96;hp=0000000000000000000000000000000000000000;hb=ae575882b0c25855564e1f482d98a681c8d8e445;hpb=8bbf37a1f79985b7c9713b71085f1fc707f8b244 diff --git a/docs/texgraph/tex2html b/docs/texgraph/tex2html new file mode 100755 index 0000000..d9d45e1 --- /dev/null +++ b/docs/texgraph/tex2html @@ -0,0 +1,87 @@ +#!/usr/bin/perl + +use File::Basename; + +our ($nom, $dir, $ext) = fileparse($ARGV[0],qr{\..*}); +our $tex = qx{cat $ARGV[0]}; + +## === Filtres amont ----------------------------------------------------------- +$tex =~ s{\\util\s+}{}g; +$tex =~ s/\\label\{.+?\}//g; +$tex =~ s/\\opt\s*\{/\\modifopt\{/g; +$tex =~ s{\\desc\s+}{§§desc§:}g; +$tex =~ s/\\textbf\s*\[(.+?)\]\s*(\{(?:[^\{\}]++|(?2))*\})/§§textbf§$1§$2§:/g; +$tex =~ s/\\centerline\s*(\{(?:[^\{\}]++|(?1))*\})/§§centerline§$1§:/g; + +## === Fichier temporaire et transformation ------------------------------------ +open TMP, ">temp.tex"; +print TMP &pretex(); +print TMP $tex; +close TMP; +qx{pandoc --ascii temp.tex -o temp.html}; + +our $html = qx{cat temp.html}; +## === Filtres aval ------------------------------------------------------------ +$html =~ s/\&\#167\;/§/g; +$html =~ s/§§bks§:\s*/\&\#92\;/g; +$html =~ s{§§exem§:}{Exemple(s) : }g; +$html =~ s/§§textbf§(.*?)§\{(.*?)\}§:/$2<\/b>/g; +$html =~ s/§§desc§:/Description<\/u> : /g; +$html =~ s{§§opt§(.+?)§:}{$1}g; +$html =~ s{§§helpref§(.+?)§(.+?)§:}{&helpa($1,$2)}ge; +$html =~ s{§§span§co§(.+?)§:}{$1}g; +$html =~ s{§§span§var§(.+?)§:}{$1}g; +$html =~ s{§§span§res§(.+?)§:}{$1}g; +$html =~ s{§§textsl§(.+?)§:}{$1}g; +$html =~ s{§§centerline§\{(.+?)\}§:}{
$1
}g; +$html =~ s{

(.+?)

}{&modh3($1,$2)}ge; +$html =~ s{

(.+?)

}{&modh2($1,$2)}ge; + + +## === Fichier final ----------------------------------------------------------- +open HTM, ">$nom.html"; +print HTM $html; +close HTM; + + +sub pretex { + return << "eop"; +\\newcommand{\\argu}[1]{<\\textit{#1}>} +\\newcommand{\\exem}{§§exem§:} +\\newcommand{\\Nil}{\\textit{Nil}} +\\newcommand{\\jump}{\\textit{jump}} +\\newcommand{\\var}[1]{§§span§var§#1§:} +\\newcommand{\\co}[1]{§§span§co§#1§:} +\\newcommand{\\res}[1]{§§span§res§#1§:} +\\newcommand{\\Mytextbf}[1]{\\textbf{#1}} +\\newcommand{\\textsl}[1]{§§textsl§#1§:} +\\newcommand{\\modifopt}[2]{§§opt§#1 := < #2 >§:} +\\newcommand{\\Helpref}[2]{§§helpref§#1§#2§:} +\\newcommand{\\bks}{§§bks§:} +eop +} + +sub modh3 { + my ($i, $c) = @_; + if ("\U$i" eq "\U$c") { + return qq{

$c

}; + } else { + return qq{

$c

}; + } +} + +sub modh2 { + my ($i, $c) = @_; + if ("\U$i" eq "\U$c") { + return qq{

$c

}; + } else { + return qq{

$c

}; + } +} + +sub helpa { + my ($a, $b) =@_; + $a =~ s/^\{|\}$//g; + $b =~ s/^cmd|^mac//; + return qq{$a}; +} \ No newline at end of file