checks for unbalanced tags

git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@2083 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert
2012-11-04 19:03:27 +00:00
parent 4e1d34fba3
commit e721f700d2

View File

@@ -3,9 +3,12 @@
use strict; use strict;
use warnings; use warnings;
# $Id:
my $docIn = "docs/commandref_frame.html"; my $docIn = "docs/commandref_frame.html";
my $docOut = "docs/commandref.html"; my $docOut = "docs/commandref.html";
my @modDir = ("FHEM"); my @modDir = ("FHEM");
use constant TAGS => qw{ul li code};
open(IN, "$docIn") || die "Cant open $docIn: $!\n"; open(IN, "$docIn") || die "Cant open $docIn: $!\n";
open(OUT, ">$docOut") || die "Cant open $docOut: $!\n"; open(OUT, ">$docOut") || die "Cant open $docOut: $!\n";
@@ -52,6 +55,8 @@ while(my $l = <IN>) {
# Copy the doc part from the module # Copy the doc part from the module
foreach my $mod (sort keys %mods) { foreach my $mod (sort keys %mods) {
my $tag;
my %tagcount= ();
open(MOD, $mods{$mod}) || die("Cant open $mods{$mod}:$!\n"); open(MOD, $mods{$mod}) || die("Cant open $mods{$mod}:$!\n");
my $skip = 1; my $skip = 1;
while(my $l = <MOD>) { while(my $l = <MOD>) {
@@ -60,10 +65,18 @@ foreach my $mod (sort keys %mods) {
} elsif($l =~ m/^=end html/) { } elsif($l =~ m/^=end html/) {
$skip = 1; $skip = 1;
} elsif(!$skip) { } elsif(!$skip) {
# here we copy line by line from the module
print OUT $l; print OUT $l;
foreach $tag (TAGS) {
$tagcount{$tag}+= ($l =~ /<$tag>/i);
$tagcount{$tag}-= ($l =~ /<\/$tag>/i);
}
} }
} }
close(MOD); close(MOD);
foreach $tag (TAGS) {
print("$mods{$mod}: Unbalanced $tag\n") if($tagcount{$tag});
}
} }
# Copy the tail # Copy the tail