Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 624C0429E5B for ; Wed, 1 Feb 2012 07:22:55 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s69OosxUxL9X for ; Wed, 1 Feb 2012 07:22:54 -0800 (PST) Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66]) by olra.theworths.org (Postfix) with ESMTP id 18596429E34 for ; Wed, 1 Feb 2012 07:22:54 -0800 (PST) Received: by guru.guru-group.fi (Postfix, from userid 501) id EA80768055; Wed, 1 Feb 2012 17:22:56 +0200 (EET) From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH 2/2] devel: added newssplit.pl for splitting NEWS for markdown processing. Date: Wed, 1 Feb 2012 17:22:50 +0200 Message-Id: <1328109770-29279-2-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 1.7.6.1 In-Reply-To: <1328109770-29279-1-git-send-email-tomi.ollila@iki.fi> References: <1328109770-29279-1-git-send-email-tomi.ollila@iki.fi> Cc: Tomi Ollila X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Feb 2012 15:22:55 -0000 devel/newssplit.pl splits NEWS file to separate files per release. In addition to splitting it changes lines starting with '*' to start with '###' (markdown for h3) and concatenates continuing non-empty lines to the same line; markdown does now allow (long) header line to be split into multiple lines -- such long lines would look ugly when reading the original NEWS file in text format. --- See http://notmuchmail.org/news/ (as of 2012-02-01) to see current output devel/newssplit.pl | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-) create mode 100755 devel/newssplit.pl diff --git a/devel/newssplit.pl b/devel/newssplit.pl new file mode 100755 index 0000000..c1a0b26 --- /dev/null +++ b/devel/newssplit.pl @@ -0,0 +1,56 @@ +#!/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/newssplit.pl NEWS ../notmuch-wiki/news + +use strict; +use warnings; + +die "$0 \n" unless @ARGV == 2; + +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 = (); +print "\nWriting to $ARGV[1]: "; +while () +{ + # The date part in regex regognizes wip version dates like: (201x-xx-xx). + if (/^Notmuch\s+(\S+)\s+\((\w\w\w\w-\w\w-\w\w)\)/) { + # open O... autocloses previously opened file. + open O, '>', "$ARGV[1]/release-$1.mdwn" or die $!; + print " release-$1.mdwn..."; + print O "[[!meta date=\"$2\"]]\n\n"; + @emptylines = (); + } + # buffer "trailing" empty lines -- dropped at end of file. + push(@emptylines, $_), next if s/^\s*$/\n/; + if (@emptylines) { + print O @emptylines; + @emptylines = (); + } + # convert top-level list item to level 4 header. + if (s/^\*\s+//) { + chomp; + my @l = $_; + while () { + last if /^\s*$/; + chomp; s/^\s+//; + push @l, $_; + } + print O "### ", (join ' ', @l), "\n"; + @emptylines = ( "\n" ); + next; + } + + print O $_; +} +print "\ndone.\n"; +close O; -- 1.7.6.5