From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 50D7E421160 for ; Mon, 10 Feb 2014 10:45:08 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001] 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 XNHEnDkSXNzy for ; Mon, 10 Feb 2014 10:45:03 -0800 (PST) Received: from qmta13.westchester.pa.mail.comcast.net (qmta13.westchester.pa.mail.comcast.net [76.96.59.243]) by olra.theworths.org (Postfix) with ESMTP id 4A4B2429E41 for ; Mon, 10 Feb 2014 10:44:03 -0800 (PST) Received: from omta15.westchester.pa.mail.comcast.net ([76.96.62.87]) by qmta13.westchester.pa.mail.comcast.net with comcast id QeJC1n0031swQuc5Dik1Ad; Mon, 10 Feb 2014 18:44:01 +0000 Received: from odin.tremily.us ([24.18.63.50]) by omta15.westchester.pa.mail.comcast.net with comcast id Qihz1n01A152l3L3bii0ft; Mon, 10 Feb 2014 18:42:00 +0000 Received: from mjolnir.tremily.us (unknown [192.168.0.140]) by odin.tremily.us (Postfix) with ESMTPS id 853D010167C1; Mon, 10 Feb 2014 10:41:59 -0800 (PST) Received: (nullmailer pid 1278 invoked by uid 1000); Mon, 10 Feb 2014 18:40:45 -0000 From: "W. Trevor King" To: notmuch@notmuchmail.org Subject: [PATCH v2 16/20] nmbug-status: Slug the title when using it as an id Date: Mon, 10 Feb 2014 10:40:37 -0800 Message-Id: X-Mailer: git-send-email 1.8.5.2.8.g0f6c0d1 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1392057841; bh=5c3DZNU92key6Fiks4Dxs8lHBDjvARDV5JrrIZJL45A=; h=Received:Received:Received:Received:From:To:Subject:Date: Message-Id; b=PbK5sEN/0sxUuvbJEDy54SqrUxMCqx5FIfne9X6eeccAhfbaW6hwodelT9Ow8K6a8 DhiPrYJN/9JWeyBlXvcAkZd5VxUnMK9l3JAVcH6vF2mGTDgpqrsrviCsY/7GBvN3id JSD0YO9biImgf4krl3KnHMdZesTHRjmXw1gV9MOaUMUIHxZU1NTmRFuK6bxY57dvH2 7j3BtQ44qD5Pb+K+tl+RwwTI5xLL36ZOJhgMTOWD7ztg6ivIXXRL5Dj6Fn8z80YKhC PmTWtusmWmdqL9pR2og2NySOPSpcF/5QMbxYcV1TajL0lEplDJQxbf7+iepHkznZf+ wCpu8BkgKqw1w== 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: Mon, 10 Feb 2014 18:45:08 -0000 Also allow manual id overrides from the JSON config. Sluggin avoids errors like: Bad value '#Possible bugs' for attribute href on element a: Whitespace in fragment component. Use %20 in place of spaces. from http://validator.w3.org. I tried just quoting the titles (e.g. 'Possible%20bugs'), but that didn't work (at least with Firefox 24.2.0). Slugging avoids any ambiguity over when the quotes are expanded in the client. The specs are unclear about quoting, saying only [1]: Value: Any string, with the following restrictions: must be at least one character long must not contain any space characters [1]: http://dev.w3.org/html5/markup/global-attributes.html#common.attrs.id --- devel/nmbug/nmbug-status | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status index 2b1f364..989d065 100755 --- a/devel/nmbug/nmbug-status +++ b/devel/nmbug/nmbug-status @@ -21,6 +21,7 @@ except ImportError: # Python 2 import json import argparse import os +import re import sys import subprocess @@ -168,16 +169,20 @@ class Page (object): class HtmlPage (Page): + _slug_regexp = re.compile('\W+') + def _write_header(self, views, stream): super(HtmlPage, self)._write_header(views=views, stream=stream) stream.write('
    \n') for view in views: + if 'id' not in view: + view['id'] = self._slug(view['title']) stream.write( - '
  • {title}
  • \n'.format(**view)) + '
  • {title}
  • \n'.format(**view)) stream.write('
\n') def _write_view_header(self, view, stream): - stream.write('

{title}

\n'.format(**view)) + stream.write('

{title}

\n'.format(**view)) if 'comment' in view: stream.write(view['comment']) stream.write('\n') @@ -224,6 +229,9 @@ class HtmlPage (Page): ).format(**d) return (running_data, display_data) + def _slug(self, string): + return self._slug_regexp.sub('-', string) + _PAGES['text'] = Page() _PAGES['html'] = HtmlPage( -- 1.8.5.2.8.g0f6c0d1