The following program (script.pl) uses htmx [ 200612011227 ] to had LaTeX support to the VooDooPad web export process. 


usage : cd /path-to-the-html-folder/ ; perl script.pl





#!/usr/bin/perl


# This program was written by Pascal in London on the 8th August 2006.

# The objective was to add LaTeX support to the web export process of VooDooPad but can be use with any html export. 

#

# 14 August 2006 : improvment in the regular expression for .html files



$list_of_files = `ls`;

@list_of_files = split('\n',$list_of_files);


foreach (@list_of_files) {

$file = $_;

if($file =~ /(.+)\.(html)$/){

$new_name = "$1" . "." . "htmx";

&transformation($file,$new_name);

&htmx($new_name);

}

} 


sub transformation{

local ($old_name,$new_name) = @_;

open(SOURCE,"$old_name");

open(TARGET,">$new_name");

while(<SOURCE>){

$line = $_;

$line = replace($line,"{latex}","<latex>\$");

$line = replace($line,"{/latex}","\$</latex>");

print TARGET $line;

}

close(TARGET);

close(SOURCE);

}


sub replace {

    local ($line,$old_pattern,$new_pattern) = @_;

    local ($line_old)=$line;

    $line =~ s/$old_pattern/$new_pattern/;

    until($line_old eq $line){

        $line_old=$line;

        $line =~ s/$old_pattern/$new_pattern/;

    }

    return $line;   

}


sub htmx {

local ($name) =@_;

`htmx $name`;

}