Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 05B6E10242 for ; Fri, 4 Oct 2013 14:43:05 +0000 (UTC) Received: (qmail 45030 invoked by uid 500); 4 Oct 2013 14:42:59 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 44224 invoked by uid 500); 4 Oct 2013 14:42:51 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 44010 invoked by uid 99); 4 Oct 2013 14:42:50 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Oct 2013 14:42:50 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9A23690F985; Fri, 4 Oct 2013 14:42:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brondsem@apache.org To: allura-commits@incubator.apache.org Date: Fri, 04 Oct 2013 14:43:02 -0000 Message-Id: <72922665cae64139ae381e59be8ce40a@git.apache.org> In-Reply-To: <4e630057a87148c2948bce4ae81d81e3@git.apache.org> References: <4e630057a87148c2948bce4ae81d81e3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [14/44] git commit: [#6534] ticket:441 gollum page links conversion [#6534] ticket:441 gollum page links conversion Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f06327ad Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f06327ad Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f06327ad Branch: refs/heads/master Commit: f06327ad00c1b63db274ba7af9a03e7e0310cdd9 Parents: ec066ab Author: Igor Bondarenko Authored: Wed Sep 18 15:50:02 2013 +0300 Committer: Dave Brondsema Committed: Fri Oct 4 14:21:21 2013 +0000 ---------------------------------------------------------------------- ForgeImporters/forgeimporters/github/wiki.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f06327ad/ForgeImporters/forgeimporters/github/wiki.py ---------------------------------------------------------------------- diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py index feaca46..027bc89 100644 --- a/ForgeImporters/forgeimporters/github/wiki.py +++ b/ForgeImporters/forgeimporters/github/wiki.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +import re from datetime import datetime from tempfile import mkdtemp from shutil import rmtree @@ -204,7 +205,24 @@ class GitHubWikiImporter(ToolImporter): rmtree(wiki_path) def convert_gollum_page_links(self, text): - return text + _re = re.compile(r'''(?P')? # possible tag escaping + (?P\[\[ # tag start + (?:(?P[^]|]*)\|)? # optional title + (?P<page>[^]]+) # page name + \]\]) # tag end''', re.VERBOSE) + + def repl(match): + page = match.group('page').replace('-', ' ').replace('/', ' ') + title = match.groupdict().get('title') + quote = match.groupdict().get('quote') + if quote: + # tag is escaped, return untouched + return match.group('tag') + if title: + return u'[{}]({})'.format(title, page) + return u'[{}]'.format(page) + + return _re.sub(repl, text) def convert_gollum_external_links(self, text): return text