From bf0791a5687a4c1248d69ce040620b3bb79a95ac Mon Sep 17 00:00:00 2001
From: Waylan Limberg
Date: Sun, 16 Jun 2013 20:54:44 -0400
Subject: AbbrExtension now handles abbreviations nested in other markup.
Just set each abreviation as an AtomicString. Given the nature of
abbreviations, they are not likely to ever contain any other markup
anyway. Also added a test.
Fixes #224. Thanks for the report @JakeChampion.
---
markdown/extensions/abbr.py | 4 ++--
tests/test_extensions.py | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/markdown/extensions/abbr.py b/markdown/extensions/abbr.py
index 5e46f1d..3f8a443 100644
--- a/markdown/extensions/abbr.py
+++ b/markdown/extensions/abbr.py
@@ -28,7 +28,7 @@ from __future__ import unicode_literals
from . import Extension
from ..preprocessors import Preprocessor
from ..inlinepatterns import Pattern
-from ..util import etree
+from ..util import etree, AtomicString
import re
# Global Vars
@@ -88,7 +88,7 @@ class AbbrPattern(Pattern):
def handleMatch(self, m):
abbr = etree.Element('abbr')
- abbr.text = m.group('abbr')
+ abbr.text = AtomicString(m.group('abbr'))
abbr.set('title', self.title)
return abbr
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index cb27a30..cce2adf 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -27,6 +27,15 @@ class TestAbbr(unittest.TestCase):
'and a REF. Ignore '
'REFERENCE and ref.
')
+ def testNestedAbbr(self):
+ """ Test Nested Abbreviations. """
+ text = '[ABBR](/foo) and _ABBR_\n\n' + \
+ '*[ABBR]: Abreviation'
+ self.assertEqual(self.md.convert(text),
+ 'ABBR '
+ 'and ABBR
')
+
+
class TestCodeHilite(unittest.TestCase):
""" Test codehilite extension. """
--
cgit v1.2.3