From 5c1eaf55cd635c96a3e263e19dd89c8e5667c43d Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 22 Jul 2011 17:47:11 -0400 Subject: Fixed a few minor Python2.4 incompatabilities. Runs in 2.4-2.7 cleanly. --- markdown/extensions/attr_list.py | 8 +++++++- markdown/postprocessors.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/markdown/extensions/attr_list.py b/markdown/extensions/attr_list.py index 7a4014f..60287fe 100644 --- a/markdown/extensions/attr_list.py +++ b/markdown/extensions/attr_list.py @@ -22,6 +22,12 @@ import markdown import re from markdown.util import isBlockLevel +try: + Scanner = re.Scanner +except AttributeError: + # must be on Python 2.4 + from sre import Scanner + def _handle_double_quote(s, t): k, v = t.split('=') return k, v.strip('"') @@ -40,7 +46,7 @@ def _handle_word(s, t): return u'id', t[1:] return t, t -_scanner = re.Scanner([ +_scanner = Scanner([ (r'[^ ]+=".*?"', _handle_double_quote), (r"[^ ]+='.*?'", _handle_single_quote), (r'[^ ]+=[^ ]*', _handle_key_value), diff --git a/markdown/postprocessors.py b/markdown/postprocessors.py index 8985fb8..b646027 100644 --- a/markdown/postprocessors.py +++ b/markdown/postprocessors.py @@ -82,7 +82,7 @@ class RawHtmlPostprocessor(Postprocessor): def isblocklevel(self, html): m = re.match(r'^\<\/?([^ ]+)', html) if m: - if m.group(1).startswith(('!', '?', '@', '%')): + if m.group(1)[0] in ('!', '?', '@', '%'): # Comment, php etc... return True return util.isBlockLevel(m.group(1)) -- cgit v1.2.3