Home
Virtual Image Printer DriverMiraplacid Publisher converts documents to images
Virtual Text Printer DriverMiraplacid Text Driver extracts text from documents
Miraplacid Data ViewerMiraplacid Data Viewer - access to internal structure of a binary file
Miraplacid Text ViewerMiraplacid Text Viewer - access to internal structure of a text file
Common:   Login | Rules of forum | Register
Management:  New topic | Close topic | Move topic | Delete topic
  

Miraplacid Forum >> Web Development >> shtml to htm conversionModerator:Supervisor

Author Topic:  shtml to htm conversion
Stephen Anderson
Member

From: Denmark
posted 2004-04-02 11:27:41 Reply -Delete

Is there a tool to convert SHTML files to HTM?

Kon
Member

From: USA
Email
posted 2004-04-03 01:50:37 Reply -Delete

Enjoy it! This script processes all the files in folder $ARGV[0]

sub xssi;
sub putline;

$path_from=$ARGV[0] . "\\*.shtml";

@files = glob ($path_from);
#@files = <*.shtml>;

if ($AGRV[2] eq "") {
if ($ARGV[0] eq "") {
$inc_path="";
} else {
$inc_path=$ARGV[0] . '\\';
}
} else {
$inc_path=$AGRV[2] . '\\';
}

print "\nArgv[0] = $ARGV[0] path_from = $path_from inc path = $inc_path Files = @files";

foreach $fn (@files) {
print "\nProcessing file $fn";
$from = $fn;
$to=$from;
if ($to =~ /\\(.+)\.shtml$/) {
$to = ($1);
}
# print " ($to) ";

$to = (($ARGV[1] eq "")?"":"$ARGV[1]\\") . $to . '.htm';

# print " - results will be in $to";

xssi $from, $to, $inc_path;
}

sub xssi {
my $from = shift(@_);
my $to = shift(@_);
my $inc_path = shift(@_);
my $omit=0;

print "\nGet from = $from to = $to inc path = $inc_path";
open(FILE,"<$from");
open(XFILE,">$to");

#
foreach $a () {
# if ($a =~ /\<\!\-\-\#include\s+virtual\s*=\s*[\`|\"]?(.+)[\`|\"]?\s*\-\-\>/) {
if ($a =~ /\<\!\-\-\#include\s+virtual\s*=\s*(.+)\s*\-\-\>/) {
my $ifn_draft=$1;
if ($ifn_draft =~ /^\"(.*)\"/) {
$ifn_draft=$1;
} elsif ($ifn_draft =~ /^\'(.*)\'/) {
$ifn_draft=$1;
}
my $ifn = $inc_path . $ifn_draft;
print "\n---include file $ifn";
open(IFILE,"<$ifn");
@i=;
close IFILE;
foreach $z (@i) {
$omit=putline $z,$omit,$from;
}
} else {
$omit=putline $a,$omit,$from;
}
}
close XFILE;
}
sub putline {
my $z = shift(@_);
my $omit = shift(@_);
my $from = shift(@_);
if ($from =~ /^.*\\(.+?)$/) {
$from=$1;
}
if ($from =~ /(.*)\..*$/) {
$from=$1;
}
if ($z =~ /\<\!\-\-\s*\#if\s*expr=[\"|]\$filename(\=|\!\=|\<|\>|\<\=|\>\=|\<\>)\s*(.*?)?[\"|]\s*\-\-\>/i) {
if ($omit == 0) {
# print "\nMatch! a omit=$omit '$from' == '$2' sign == '$1'";
if (($2 ne $from) && ($1 eq '=')) {
# print "\n Yes!";
$omit=1;
} elsif (($2 eq $from) && ($1 ne '=')) {
# print "\n Yes!";
$omit=1;
}

}
} elsif ($z =~ /\<\!\-\-\s*\#end\s*if\s*\-\-\>/i) {
# print "\nMatch! b";
$omit=0;
} elsif ($z =~ /\<\!\-\-\s*\#else\s*\-\-\>/i) {
# print "\nMatch! b";
if ($omit==0) {
$omit=1;
} else {
$omit=0;
}
} else {
if ($omit==0) {
$z =~ s/\<\!\-\-\s*\#echo\s+var\s*\=\s*\"?\$filename\"?\s*\-\-\>/$from/gi;
$z =~ s/\<\!\-\-\s*\#.*\-\-\>//gi;
print XFILE $z;
}
}
return $omit;
}

Your message:
Name, password:
Go to category:  

Technical Support

Copyright © Miraplacid, 2003 - 2024