#!/usr/bin/perl -w
# Copyright: GPL2
# Written by Egon Willighagen (egon.w@linuxfocus.org)
#
use strict;
use diagnostics;

my $lfdir = $ENV{'LFDIR'};

my $file = "index.pre";
my $target = "index.html";

open(OUT, ">$target");
open(INPUT, "<$file");
my $line = "";
while ($line = <INPUT>) {
    if ($line =~ m/\<\!\-\-\s*macro\s*insert\s*([^\s]*)\s*(.*?)\s*\-\-\>/i) {
	# try to expand macro
        my $macro = $1;
        my $month = $2;
	print "Macro: $macro -> $month$/";
        if ($macro eq "monthindex") {
            print OUT `cd $lfdir/Nederlands/data/; ../WorkSpace/bin/xml2any -PARAM current $month -IN lfdb.nl.xml -XSL issuetoc_full.xslt`;
	}
    } else {
        print OUT $line;
    }
}
close(INPUT);
close(OUT);

