diff options
author | Jonas Smedegaard <dr@jones.dk> | 2009-08-08 21:30:04 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2009-08-08 21:30:04 +0200 |
commit | 4aaf7f0ffe97b1a4a4317c9970fee0bb9923632c (patch) | |
tree | 40df40c8b4e72999cc007eee771b3c66630a8fde /localmarkdown2sms | |
parent | 244b61d5f12466c603e6f929ba2a73152ab829ae (diff) |
Supporess directives and extract tags (not yet used).
Diffstat (limited to 'localmarkdown2sms')
-rwxr-xr-x | localmarkdown2sms | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/localmarkdown2sms b/localmarkdown2sms index 704304e..51d3bf9 100755 --- a/localmarkdown2sms +++ b/localmarkdown2sms @@ -33,7 +33,7 @@ use Proc::Fork; #Proc::Daemon::Init; -my (%delay, %reply); +my (%file, %delay, %reply); my ($path) = shift @ARGV; foreach my $file (read_dir( $path )) { @@ -96,20 +96,28 @@ foreach my $file (read_dir( $path )) { $skipcontent = 1; } # reply - } 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 - $content =~ s/(\S)\h$/$1/g; # strip single trailing space - $content =~ s/\n\n+/\n\n/g; # strip excess newlines - $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; + $content = $line . "\n"; + # ikiwiki directives - strip from content and parse for tags + $content =~ s/(?<!\\)\[\[([^\[\]]*)(?<!\\)\]\]//gs and do { + my $directive_string = $1; + my ($directive, $directive_content); + $directive_string =~ /^\s*\!(tag|taglink)\s*((\s*?\b\w+)+)/ and $file{$file}{'directive'}{'tag'} = [ split /\s+/, $2 ]; + }; + if ( defined( $key ) and not ($skipcontent)) { + $content = $reply{$key}[$i] . $content if (defined($reply{$key}[$i])); + $content =~ s/^\h*$//g; # clean virtually empty lines + $content =~ s/(\S)\h$/$1/g; # strip single trailing space + $content =~ s/\n\n+/\n\n/g; # strip excess newlines + $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; + } } } # tidy latest reply (TODO: use sub) |