summaryrefslogtreecommitdiff
path: root/localmarkdown2sms
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2009-08-08 20:06:49 +0200
committerJonas Smedegaard <dr@jones.dk>2009-08-08 20:06:49 +0200
commit244b61d5f12466c603e6f929ba2a73152ab829ae (patch)
treea540c8a312676a008d8bca3bf3d4b83fbce8a9f2 /localmarkdown2sms
parent9145cd2544a5c52962dc2244eed89e3bd942b863 (diff)
Skip content tied to skipped keys and delays.
Diffstat (limited to 'localmarkdown2sms')
-rwxr-xr-xlocalmarkdown2sms15
1 files changed, 13 insertions, 2 deletions
diff --git a/localmarkdown2sms b/localmarkdown2sms
index 100ef52..704304e 100755
--- a/localmarkdown2sms
+++ b/localmarkdown2sms
@@ -37,7 +37,7 @@ my (%delay, %reply);
my ($path) = shift @ARGV;
foreach my $file (read_dir( $path )) {
- my ($key, $i);
+ my ($key, $i, $skipkey, $skipcontent);
# suppress repeated warnings for same issue
my ($warn_nonkey_delay, $warn_nonkey_content);
next unless ($file =~ /\.mdwn$/);
@@ -56,6 +56,8 @@ foreach my $file (read_dir( $path )) {
if ($level == 1 and $content =~ /(\w+)/) {
$key = lc($1);
$i = 0;
+ $skipkey = undef;
+ $skipcontent = undef;
if (lc($content) ne $key) {
print STDERR "key \"$key\" extracted from fuzzy string \"$content\" in file \"$file\"\n";
}
@@ -66,9 +68,12 @@ foreach my $file (read_dir( $path )) {
} else {
print STDERR "skipping non-unique key \"$key\" in file \"$file\"\n";
$key = undef;
+ $skipkey = 1;
+ $skipcontent = 1;
}
# delay
} elsif ($level == 2 and $content =~ /((\d+[sm](\s+|\Z))+)/) {
+ $skipcontent = undef;
if (defined( $key)) {
my $delay = parse_duration($1);
if (defined($reply{$key}[$i])) {
@@ -79,15 +84,19 @@ foreach my $file (read_dir( $path )) {
if ($content ne $1) {
print STDERR "delay (${delay}s) resolved from fuzzy string \"$content\" in file \"$file\"\n";
}
+ } elsif ($skipkey) {
+ # skipping - already warned about it...
} else {
print STDERR "ignoring non-key'ed delay line \"$1\" in file \"$file\"\n" unless ($warn_nonkey_delay);
$warn_nonkey_delay = 1;
+ $skipcontent = 1;
}
} else {
print STDERR "ignoring non-parsable headline \"$line\" in file \"$file\"\n";
+ $skipcontent = 1;
}
# reply
- } elsif ( defined( $key )) {
+ } elsif ( defined( $key ) and not ($skipcontent)) {
$content = $reply{$key}[$i] if (defined($reply{$key}[$i]));
$content .= $line . "\n";
$content =~ s/^\h*$//g; # clean virtually empty lines
@@ -96,6 +105,8 @@ foreach my $file (read_dir( $path )) {
$content =~ s/(\S)\n([^\n])/$1 $2/g; # convert newline to space
$content =~ s/\h*$//g; # strip all trailing spaces
$reply{$key}[$i] = $content;
+ } elsif ($skipkey or $skipcontent) {
+ # skipping - already warned about it...
} else {
print STDERR "skipping non-key'ed content \"$line\" in file \"$file\"\n" unless ($warn_nonkey_content);
$warn_nonkey_content = 1;