aboutsummaryrefslogtreecommitdiff
path: root/stest.pl
diff options
context:
space:
mode:
Diffstat (limited to 'stest.pl')
-rw-r--r--stest.pl24
1 files changed, 14 insertions, 10 deletions
diff --git a/stest.pl b/stest.pl
index 5480f8f..a22c5ce 100644
--- a/stest.pl
+++ b/stest.pl
@@ -9,29 +9,33 @@ use File::Cache::Parsed;
use Cwd 'abs_path';
use Text::Restructured;
use Text::Restructured::Writer::LibXML;
+use XML::LibXML;
+use XML::LibXSLT;
my $stash={};
my $template=Template->new();
my $rest=Text::Restructured->new({},'WebCoso');
+my $xml_parser=XML::LibXML->new();
+my $xslt_proc=XML::LibXSLT->new();
my $fc=File::Cache::Parsed->new();
-$fc->add_parser(qr{\.rest\.tt2?$} =>
+$fc->add_parser(qr{\.tt2?$} =>
sub {
- my ($name,$content)=@_;
- my $real_name=abs_path($name);
- my $output;
- $template->process($real_name,
- {%$stash,name=>$name},
- \$output);
- return $output;
+ $template->context->template($_[0]);
});
$fc->add_parser(qr{\.rest\.txt$} =>
sub {
- my ($name,$content)=@_;
- my $dudom=$rest->Parse($content,$name);
+ my $dudom=$rest->Parse($_[1],$_[0]);
return Text::Restructured::Writer::LibXML
->new->ProcessDOM($dudom);
});
+$fc->add_parser(qr{\.xml$} =>
+ sub { $xml_parser->parse_string($_[1],$_[0]) });
+$fc->add_parser(qr{\.xslt?$} =>
+ sub { $xslt_proc->parse_stylesheet
+ ($xml_parser->parse_string($_[1],$_[0])) });
+$fc->add_writer(qr{\.xml$} =>
+ sub { $_[1]->toFile($_[0]) });
sub expandTT {
my ($maker,$target,$deps,$matches)=@_;