--- /dev/null
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 10B99431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 4 Aug 2014 10:40:03 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id aUjbAa9K+YFS for <notmuch@notmuchmail.org>;\r
+ Mon, 4 Aug 2014 10:39:54 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 8145C431FAE\r
+ for <notmuch@notmuchmail.org>; Mon, 4 Aug 2014 10:39:54 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 85051100063; Mon, 4 Aug 2014 20:39:38 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] devel: make man-to-mdwn.pl to work with generated manual\r
+ pages\r
+Date: Mon, 4 Aug 2014 20:39:32 +0300\r
+Message-Id: <1407173972-28090-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.0.0\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 04 Aug 2014 17:40:03 -0000\r
+\r
+The new manual pages converted from rst using sphinx or rst2man\r
+has somewhat different syntax. man-to-mdwn.pl is now adjusted\r
+to produce even better output from this syntax. The changes also\r
+include using utf-8 locale (e.g. for tables and generated hypens)\r
+and and quite a few bugs fixes.\r
+This tool still produces better results than just using the\r
+html pages generated using sphinx / rst2html. For example those\r
+tools don't create inter-page hyperlinks -- and the preformatted\r
+pages written by man-to-mdwn.pl just works well with manual page\r
+content.\r
+---\r
+\r
+This is version 2 of id:1399497879-27392-1-git-send-email-tomi.ollila@iki.fi\r
+\r
+The changes in notmuch-wiki commit 6562766 (Mon Aug 4 10:15:07 2014 +0300)\r
+were generated with this tool, now on Fedora 20 (should be comparable with\r
+Debian testing David used). Thanks to David for that -- quite a few things\r
+did now work on these systems compared to Scientific Linux 6.2.\r
+\r
+ devel/man-to-mdwn.pl | 42 ++++++++++++++++++++++--------------------\r
+ 1 file changed, 22 insertions(+), 20 deletions(-)\r
+\r
+diff --git a/devel/man-to-mdwn.pl b/devel/man-to-mdwn.pl\r
+index 4b59bd663698..5024569e5d84 100755\r
+--- a/devel/man-to-mdwn.pl\r
++++ b/devel/man-to-mdwn.pl\r
+@@ -6,18 +6,18 @@\r
+ # This program is used to generate mdwn-formatted notmuch manual pages\r
+ # for notmuch wiki. Example run:\r
+ #\r
+-# $ ./devel/man-to-mdwn.pl man ../notmuch-wiki\r
++# $ ./devel/man-to-mdwn.pl doc/_build/man ../notmuch-wiki\r
+ #\r
+ # In case taken into more generic use, modify these comments and examples.\r
+ \r
+-use 5.8.1;\r
++use 5.10.1;\r
+ use strict;\r
+ use warnings;\r
+ \r
+ unless (@ARGV == 2) {\r
+ warn "\n$0 <source-directory> <destination-directory>\n\n";\r
+ # Remove/edit this comment if this script is taken into generic use.\r
+- warn "Example: ./devel/man-to-mdwn.pl man ../notmuch-wiki\n\n";\r
++ warn "Example: ./devel/man-to-mdwn.pl doc/_build/man ../notmuch-wiki\n\n";\r
+ exit 1;\r
+ }\r
+ \r
+@@ -48,11 +48,6 @@ while (<P>)\r
+ }\r
+ close P;\r
+ \r
+-#undef $ENV{'GROFF_NO_SGR'};\r
+-#delete $ENV{'GROFF_NO_SGR'};\r
+-$ENV{'GROFF_NO_SGR'} = '1';\r
+-$ENV{'TERM'} = 'vt100'; # does this matter ?\r
+-\r
+ my %htmlqh = qw/& & < < > > ' ' " "/;\r
+ # do html quotation to $_[0] (which is an alias to the given arg)\r
+ sub htmlquote($)\r
+@@ -70,8 +65,11 @@ while (my ($k, $v) = each %fhash)\r
+ #next if -l $v; # skip symlinks here. -- not... references there may be.\r
+ \r
+ my @lines;\r
+- #open I, '-|', qw/groff -man -T utf8/, $v;\r
+- open I, '-|', qw/groff -man -T latin1/, $v; # this and GROFF_NO_SGR='1'\r
++ open I, '-|', qw/env -i/, "PATH=$ENV{PATH}",\r
++ qw/TERM=vt100 LANG=en_US.utf8 LC_ALL=en_US.utf8/,\r
++ qw/GROFF_NO_SGR=1 MAN_KEEP_FORMATTING=1 MANWIDTH=80/,\r
++ qw/man/, $v or die "$!";\r
++ binmode I, ':utf8';\r
+ \r
+ my ($emptyline, $pre, $hl) = (0, 0, 'h1');\r
+ while (<I>) {\r
+@@ -79,13 +77,15 @@ while (my ($k, $v) = each %fhash)\r
+ $emptyline = 1;\r
+ next;\r
+ }\r
+- s/(?<=\S)\s{8,}.*//; # $hl = 'h1' if s/(?<=\S)\s{8,}.*//;\r
+- htmlquote $_;\r
++ # keep only leftmost in lines like 'NOTMUCH(1) notmuch NOTMUCH(1)'\r
++ s/\S\K\s{8,}\S.+\s{8,}\S.*//; # $hl = 'h1' if s/(?<=\S)\s{8,}.*//;\r
+ s/[_&]\010&/&/g;\r
+- s/((?:_\010[^_])+)/<u>$1<\/u>/g;\r
++ s/((?:_\010[^_])+)/\001u\002$1\001\/u\002/g;\r
+ s/_\010(.)/$1/g;\r
+- s/((?:.\010.)+)/<b>$1<\/b>/g;\r
++ s/((?:.\010.)+)/\001b\002$1\001\/b\002/g;\r
+ s/.\010(.)/$1/g;\r
++ htmlquote $_;\r
++ s/\001/</g; s/\002/>/g;\r
+ \r
+ if (/^\S/) {\r
+ $pre = 0, push @lines, "</pre>\n" if $pre;\r
+@@ -111,16 +111,18 @@ while (my ($k, $v) = each %fhash)\r
+ $lines[0] =~ s/^\n//;\r
+ $k = "$ARGV[1]/manpages/$k.mdwn";\r
+ open O, '>', $k or die;\r
++ binmode O, ':utf8';\r
+ print STDOUT 'Writing ', "'$k'\n";\r
+ select O;\r
+- my $pe = '';\r
++ my ($pe, $hyphen) = ('', '');\r
+ foreach (@lines) {\r
++ #print $_; next;\r
+ if ($pe) {\r
+- if (s/^(\s+)<b>([^<]+)<\/b>\((\d+)\)//) {\r
++ if (s/^(\s+)<b>([^<]+)\((\d+)\)<\/b>//) {\r
+ my $link = maymakelink "$pe-$2-$3";\r
+ $link = maymakelink "$pe$2-$3" unless $link;\r
+ if ($link) {\r
+- print "<a href='$link'>$pe-</a>\n";\r
++ print "<a href='$link'>$pe$hyphen</a>\n";\r
+ print "$1<a href='$link'>$2</a>($3)";\r
+ }\r
+ else {\r
+@@ -132,8 +134,8 @@ while (my ($k, $v) = each %fhash)\r
+ }\r
+ $pe = '';\r
+ }\r
+- s/<b>([^<]+)<\/b>\((\d+)\)/mayconvert($1, $2)/ge;\r
+- $pe = $1 if s/<b>([^<]+)-<\/b>\s*$//;\r
++ s/<b>([^<]+)\((\d+)\)<\/b>/mayconvert($1, $2)/ge;\r
++ ($pe, $hyphen) = ($1, $2) if s/<b>([^<]+)([-\x{2010}])<\/b>\s*$//;\r
+ print $_;\r
+ }\r
+ }\r
+@@ -169,7 +171,7 @@ foreach (sort srt values %fhash)\r
+ open I, '<', $in or die $!;\r
+ my $s;\r
+ while (<I>) {\r
+- if (/^\s*[.]TH\s+\S+\s+(\S+)/) {\r
++ if (/^\s*[.]TH\s+\S+\s+"?(\S+?)"?\s/) {\r
+ $s = $1;\r
+ last;\r
+ }\r
+-- \r
+2.0.0\r
+\r