X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=devel%2Fnews2wiki.pl;fp=devel%2Fnews2wiki.pl;h=8066ba7feb74a5147a8a32c8a39b21fb3b6261c1;hb=a629b2e1cb5be87abf7914730c80620e6a8c1139;hp=0000000000000000000000000000000000000000;hpb=5872cba1ebfd69de738f31da3a491b573f7c2779;p=obsolete%2Fnotmuch-old diff --git a/devel/news2wiki.pl b/devel/news2wiki.pl new file mode 100755 index 00000000..8066ba7f --- /dev/null +++ b/devel/news2wiki.pl @@ -0,0 +1,102 @@ +#!/usr/bin/perl +# +# Author: Tomi Ollila +# License: same as notmuch + +# This program is used to split NEWS file to separate (mdwn) files +# for notmuch wiki. Example run: +# +# $ ./devel/news2wiki.pl NEWS ../notmuch-wiki/news +# +# In case taken into more generic use, modify these comments and examples. + +use strict; +use warnings; + +unless (@ARGV == 2) { + warn "\n$0 \n\n"; + warn "Example: ./devel/news2wiki.pl NEWS ../notmuch-wiki/news\n\n"; + exit 1; +} + +die "'$ARGV[0]': no such file\n" unless -f $ARGV[0]; +die "'$ARGV[1]': no such directory\n" unless -d $ARGV[1]; + +open I, '<', $ARGV[0] or die "Cannot open '$ARGV[0]': $!\n"; + +open O, '>', '/dev/null' or die $!; +my @emptylines = (); +my $cln; +print "\nWriting to $ARGV[1]:\n"; +while () +{ + warn "$ARGV[0]:$.: tab(s) in line!\n" if /\t/; + warn "$ARGV[0]:$.: trailing whitespace\n" if /\s\s$/; + # The date part in regex recognizes wip version dates like: (201x-xx-xx). + if (/^Notmuch\s+(\S+)\s+\((\w\w\w\w-\w\w-\w\w)\)\s*$/) { + # open O... autocloses previously opened file. + open O, '>', "$ARGV[1]/release-$1.mdwn" or die $!; + print "+ release-$1.mdwn...\n"; + print O "[[!meta date=\"$2\"]]\n\n"; + @emptylines = (); + } + + last if /^