From 8fdd91ecc1e0fba3c29df42fccf9b4164dc54dc9 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 20 Apr 2011 03:35:26 +0300 Subject: [PATCH] Change the markdown-link-rewriting script to remove explicit labels --- scripts/markdown-identifiers.py | 111 +++++++++++++++++--------------- 1 file changed, 59 insertions(+), 52 deletions(-) diff --git a/scripts/markdown-identifiers.py b/scripts/markdown-identifiers.py index 20752bd..13c81d8 100644 --- a/scripts/markdown-identifiers.py +++ b/scripts/markdown-identifiers.py @@ -1,7 +1,11 @@ # Encoding: UTF-8 -"""Rewrite Markdown strings to use identifiers instead of names +"""Rewrite markdown links from [Label]{category:thing} to just {category:thing} -This is an unmaintained one-shot script, only included in the repo for reference. +There was a version of this script that rewrote stuff from an even earlier +format. Git log should find it without problems. + +This is an unmaintained one-shot script, only included in the repo for +reference. """ @@ -12,7 +16,7 @@ import re from sqlalchemy.orm.exc import MultipleResultsFound from sqlalchemy.sql.expression import func -from pokedex.db import connect, tables +from pokedex.db import connect, tables, util sanity_re = re.compile(ur"^[-A-Za-z0-9 é\[\]{}.%':;,×/()\"|–`—!*♂♀\\]$") @@ -20,12 +24,12 @@ sanity_re = re.compile(ur"^[-A-Za-z0-9 é\[\]{}.%':;,×/()\"|–`—!*♂♀\\]$ fuzzy_link_re = re.compile(r""" \[ [^]]+ - \] + \]? \{ [^}]+ \}""", re.VERBOSE) -# Very specific RE that matches links that appear in our Markdown strings +# Very specific RE that matches links that appear in source Markdown strings strict_link_re = re.compile(r""" \[ (?P