From 422d3917ac6a51925d43746e8eded9b37d6a723c Mon Sep 17 00:00:00 2001 From: facelessuser Date: Wed, 13 Mar 2019 10:26:39 -0500 Subject: [PATCH 1/9] Refactor em strong to consolidate code and fix issue #792 --- markdown/extensions/legacy_em.py | 29 ++++-- markdown/inlinepatterns.py | 173 +++++++++++++++++++++++++++++-- 2 files changed, 187 insertions(+), 15 deletions(-) diff --git a/markdown/extensions/legacy_em.py b/markdown/extensions/legacy_em.py index 566d46936..381ab8d64 100644 --- a/markdown/extensions/legacy_em.py +++ b/markdown/extensions/legacy_em.py @@ -13,10 +13,28 @@ from __future__ import absolute_import from __future__ import unicode_literals from . import Extension -from ..inlinepatterns import SimpleTagInlineProcessor +from ..import inlinepatterns -EMPHASIS_RE = r'(\*|_)(.+?)\1' -STRONG_RE = r'(\*{2}|_{2})(.+?)\1' +# _emphasis_ +EMPHASIS_RE = r'(_)([^_]+)\1' + +# __strong__ +STRONG_RE = r'(_{2})(.+?)\1' + +# __strong_em___ +STRONG_EM_RE = r'(_)\1(?!\1)(.+?)\1(?!\1)(.+?)\1{3}' + + +class LegacyUnderscoreProcessor(inlinepatterns.UnderscoreProcessor): + """Emphasis processor for handling strong and em matches inside underscores.""" + + PATTERNS = [ + (re.compile(inlinepatterns.EM_STRONG2_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), + (re.compile(inlinepatterns.STRONG_EM2_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), + (re.compile(STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), + (re.compile(EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), + (re.compile(STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'em') + ] class LegacyEmExtension(Extension): @@ -24,7 +42,4 @@ class LegacyEmExtension(Extension): def extendMarkdown(self, md): """ Modify inline patterns. """ - md.inlinePatterns.register(SimpleTagInlineProcessor(STRONG_RE, 'strong'), 'strong', 40) - md.inlinePatterns.register(SimpleTagInlineProcessor(EMPHASIS_RE, 'em'), 'emphasis', 30) - md.inlinePatterns.deregister('strong2') - md.inlinePatterns.deregister('emphasis2') + md.inlinepatterns.register(LegacyUnderscoreProcessor(r'_'), 'em_strong2', 50) diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index 23f7c5a1e..fa206aa3a 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -69,6 +69,7 @@ from html import entities except ImportError: # pragma: no cover import htmlentitydefs as entities +from collections import OrderedDict def build_inlinepatterns(md, **kwargs): @@ -91,12 +92,8 @@ def build_inlinepatterns(md, **kwargs): inlinePatterns.register(HtmlInlineProcessor(HTML_RE, md), 'html', 90) inlinePatterns.register(HtmlInlineProcessor(ENTITY_RE, md), 'entity', 80) inlinePatterns.register(SimpleTextInlineProcessor(NOT_STRONG_RE), 'not_strong', 70) - inlinePatterns.register(DoubleTagInlineProcessor(EM_STRONG_RE, 'strong,em'), 'em_strong', 60) - inlinePatterns.register(DoubleTagInlineProcessor(STRONG_EM_RE, 'em,strong'), 'strong_em', 50) - inlinePatterns.register(SimpleTagInlineProcessor(STRONG_RE, 'strong'), 'strong', 40) - inlinePatterns.register(SimpleTagInlineProcessor(EMPHASIS_RE, 'em'), 'emphasis', 30) - inlinePatterns.register(SimpleTagInlineProcessor(SMART_STRONG_RE, 'strong'), 'strong2', 20) - inlinePatterns.register(SimpleTagInlineProcessor(SMART_EMPHASIS_RE, 'em'), 'emphasis2', 10) + inlinePatterns.register(AsteriskProcessor(r'\*'), 'em_strong', 60) + inlinePatterns.register(UnderscoreProcessor(r'_'), 'em_strong2', 50) return inlinePatterns @@ -125,11 +122,23 @@ def build_inlinepatterns(md, **kwargs): # _smart_emphasis_ SMART_EMPHASIS_RE = r'(?) or [text](url "title") LINK_RE = NOIMG + r'\[' @@ -431,6 +440,154 @@ def get_stash(m): return util.INLINE_PLACEHOLDER_RE.sub(get_stash, text) +class AsteriskProcessor(InlineProcessor): + """Emphasis processor for handling strong and em matches inside asterisks.""" + + PATTERNS = [ + (re.compile(EM_STRONG_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), + (re.compile(STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), + (re.compile(STRONG_EM3_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), + (re.compile(STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), + (re.compile(EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em') + ] + + def build_single(self, m, tag, idx): + """Return single tag.""" + el1 = util.etree.Element(tag) + text = m.group(2) + self.parse_sub_patterns(text, el1, None, idx) + return el1 + + def build_double(self, m, tags, idx): + """Return double tag.""" + + tag1, tag2 = tags.split(",") + el1 = util.etree.Element(tag1) + el2 = util.etree.Element(tag2) + text = m.group(2) + self.parse_sub_patterns(text, el2, None, idx) + el1.append(el2) + if len(m.groups()) == 3: + text = m.group(3) + self.parse_sub_patterns(text, el1, el2, idx) + return el1 + + def build_double2(self, m, tags, idx): + """Return double tags (variant 2): `text text`.""" + + tag1, tag2 = tags.split(",") + el1 = util.etree.Element(tag1) + el2 = util.etree.Element(tag2) + text = m.group(2) + self.parse_sub_patterns(text, el1, None, idx) + text = m.group(3) + el1.append(el2) + self.parse_sub_patterns(text, el2, None, idx) + return el1 + + def parse_sub_patterns(self, data, parent, last, idx): + """ + Parses sub patterns. + + `data` (`str`): + text to evaluate. + + `parent` (`etree.Element`): + Parent to attach text and sub elements to. + + `last` (`etree.Element`): + Last appended child to parent. Can also be None if parent has no children. + + `idx` (`int`): + Current pattern index that was used to evaluate the parent. + + """ + + offset = 0 + pos = 0 + + length = len(data) + while pos < length: + # Find the start of potential emphasis or strong tokens + if self.compiled_re.match(data, pos): + matched = False + # See if the we can match an emphasis/strong pattern + for index, pattern in enumerate(self.PATTERNS): + # Only evaluate patterns that are after what was used on the parent + if index <= idx: + continue + m = pattern[0].match(data, pos) + if m: + # Append child nodes to parent + # Text nodes should be appended to the last + # child if present, and if not, it should + # be added as the parent's text node. + text = data[offset:m.start(0)] + if text: + if last is not None: + last.tail = text + else: + parent.text = text + el = self.build_element(m, pattern[1], pattern[2], index) + parent.append(el) + last = el + # Move our position past the matched hunk + offset = pos = m.end(0) + matched = True + if not matched: + # We matched nothing, move on to the next character + pos += 1 + else: + # Increment position as no potential emphasis start was found. + pos += 1 + + # Append any leftover text as a text node. + text = data[offset:] + if text: + if last is not None: + last.tail = text + else: + parent.text = text + + def build_element(self, m, builder, tags, index): + """Element builder.""" + + if builder == 'double2': + return self.build_double2(m, tags, index) + elif builder == 'double': + return self.build_double(m, tags, index) + else: + return self.build_single(m, tags, index) + + def handleMatch(self, m, data): + """Parse patterns.""" + + el = None + start = None + end = None + + for index, pattern in enumerate(self.PATTERNS): + m1 = pattern[0].match(data, m.start(0)) + if m1: + start = m1.start(0) + end = m1.end(0) + el = self.build_element(m1, pattern[1], pattern[2], index) + break + return el, start, end + + +class UnderscoreProcessor(InlineProcessor): + """Emphasis processor for handling strong and em matches inside underscores.""" + + PATTERNS = [ + (re.compile(EM_STRONG2_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), + (re.compile(STRONG_EM2_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), + (re.compile(SMART_STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), + (re.compile(SMART_STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), + (re.compile(SMART_EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em') + ] + + class LinkInlineProcessor(InlineProcessor): """ Return a link element from the given match. """ RE_LINK = re.compile(r'''\(\s*(?:(<[^<>]*>)\s*(?:('[^']*'|"[^"]*")\s*)?\))?''', re.DOTALL | re.UNICODE) From a46f403530b9c893231e056cde90ebafcecb2e10 Mon Sep 17 00:00:00 2001 From: facelessuser Date: Wed, 13 Mar 2019 11:22:41 -0500 Subject: [PATCH 2/9] Fix some copy paste issues and typos --- markdown/extensions/legacy_em.py | 9 +++++---- markdown/inlinepatterns.py | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/markdown/extensions/legacy_em.py b/markdown/extensions/legacy_em.py index 381ab8d64..8c7944ff6 100644 --- a/markdown/extensions/legacy_em.py +++ b/markdown/extensions/legacy_em.py @@ -13,7 +13,8 @@ from __future__ import absolute_import from __future__ import unicode_literals from . import Extension -from ..import inlinepatterns +from .. import inlinepatterns +import re # _emphasis_ EMPHASIS_RE = r'(_)([^_]+)\1' @@ -32,8 +33,8 @@ class LegacyUnderscoreProcessor(inlinepatterns.UnderscoreProcessor): (re.compile(inlinepatterns.EM_STRONG2_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), (re.compile(inlinepatterns.STRONG_EM2_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), (re.compile(STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), - (re.compile(EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), - (re.compile(STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'em') + (re.compile(STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), + (re.compile(EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em') ] @@ -42,4 +43,4 @@ class LegacyEmExtension(Extension): def extendMarkdown(self, md): """ Modify inline patterns. """ - md.inlinepatterns.register(LegacyUnderscoreProcessor(r'_'), 'em_strong2', 50) + md.inlinePatterns.register(LegacyUnderscoreProcessor(r'_'), 'em_strong2', 50) diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index fa206aa3a..3a317a521 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -69,7 +69,6 @@ from html import entities except ImportError: # pragma: no cover import htmlentitydefs as entities -from collections import OrderedDict def build_inlinepatterns(md, **kwargs): @@ -576,7 +575,7 @@ def handleMatch(self, m, data): return el, start, end -class UnderscoreProcessor(InlineProcessor): +class UnderscoreProcessor(AsteriskProcessor): """Emphasis processor for handling strong and em matches inside underscores.""" PATTERNS = [ From f03a322ceca9092cc0a9d7939a397594cfa6705c Mon Sep 17 00:00:00 2001 From: facelessuser Date: Wed, 13 Mar 2019 14:59:28 -0500 Subject: [PATCH 3/9] Add tests --- markdown/extensions/legacy_em.py | 5 ++++ .../test_syntax/extensions/test_legacy_em.py | 14 +++++++++++ tests/test_syntax/inline/test_emphasis.py | 24 +++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/markdown/extensions/legacy_em.py b/markdown/extensions/legacy_em.py index 8c7944ff6..d1d2ac824 100644 --- a/markdown/extensions/legacy_em.py +++ b/markdown/extensions/legacy_em.py @@ -44,3 +44,8 @@ class LegacyEmExtension(Extension): def extendMarkdown(self, md): """ Modify inline patterns. """ md.inlinePatterns.register(LegacyUnderscoreProcessor(r'_'), 'em_strong2', 50) + + +def makeExtension(**kwargs): # pragma: no cover + """ Return an instance of the LegacyEmExtension """ + return LegacyEmExtension(**kwargs) diff --git a/tests/test_syntax/extensions/test_legacy_em.py b/tests/test_syntax/extensions/test_legacy_em.py index ddb207912..e173242f3 100644 --- a/tests/test_syntax/extensions/test_legacy_em.py +++ b/tests/test_syntax/extensions/test_legacy_em.py @@ -38,3 +38,17 @@ def test_legacy_strong(self): '

connectedwords__

', extensions=['legacy_em'] ) + + def test_complex_emphasis_underscore(self): + self.assertMarkdownRenders( + 'This is text __bold _italic bold___ with more text', + '

This is text bold italic bold with more text

', + extensions=['legacy_em'] + ) + + def test_complex_emphasis_underscore_mid_word(self): + self.assertMarkdownRenders( + 'This is text __bold_italic bold___ with more text', + '

This is text bolditalic bold with more text

', + extensions=['legacy_em'] + ) diff --git a/tests/test_syntax/inline/test_emphasis.py b/tests/test_syntax/inline/test_emphasis.py index d96861be1..aa8c2c04e 100644 --- a/tests/test_syntax/inline/test_emphasis.py +++ b/tests/test_syntax/inline/test_emphasis.py @@ -84,3 +84,27 @@ def test_standalone_understores_at_begin_end(self): '_ bar _', '

_ bar _

' ) + + def test_complex_emphasis_asterisk(self): + self.assertMarkdownRenders( + 'This is text **bold *italic bold*** with more text', + '

This is text bold italic bold with more text

' + ) + + def test_complex_emphasis_asterisk_mid_word(self): + self.assertMarkdownRenders( + 'This is text **bold*italic bold*** with more text', + '

This is text bolditalic bold with more text

' + ) + + def test_complex_emphasis_smart_underscore(self): + self.assertMarkdownRenders( + 'This is text __bold _italic bold___ with more text', + '

This is text bold italic bold with more text

' + ) + + def test_complex_emphasis_smart_underscore_mid_word(self): + self.assertMarkdownRenders( + 'This is text __bold_italic bold___ with more text', + '

This is text __bold_italic bold___ with more text

' + ) From e7f72c6c233de37af8a3039be3cb733823bd90b7 Mon Sep 17 00:00:00 2001 From: facelessuser Date: Sun, 24 Mar 2019 13:49:22 -0600 Subject: [PATCH 4/9] Use named tuple --- markdown/extensions/legacy_em.py | 14 ++++++------ markdown/inlinepatterns.py | 37 ++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/markdown/extensions/legacy_em.py b/markdown/extensions/legacy_em.py index d1d2ac824..71ad14f49 100644 --- a/markdown/extensions/legacy_em.py +++ b/markdown/extensions/legacy_em.py @@ -13,7 +13,7 @@ from __future__ import absolute_import from __future__ import unicode_literals from . import Extension -from .. import inlinepatterns +from ..inlinepatterns import UnderscoreProcessor, EmStrongItem, EM_STRONG2_RE, STRONG_EM2_RE import re # _emphasis_ @@ -26,15 +26,15 @@ STRONG_EM_RE = r'(_)\1(?!\1)(.+?)\1(?!\1)(.+?)\1{3}' -class LegacyUnderscoreProcessor(inlinepatterns.UnderscoreProcessor): +class LegacyUnderscoreProcessor(UnderscoreProcessor): """Emphasis processor for handling strong and em matches inside underscores.""" PATTERNS = [ - (re.compile(inlinepatterns.EM_STRONG2_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), - (re.compile(inlinepatterns.STRONG_EM2_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), - (re.compile(STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), - (re.compile(STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), - (re.compile(EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em') + EmStrongItem(re.compile(EM_STRONG2_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), + EmStrongItem(re.compile(STRONG_EM2_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), + EmStrongItem(re.compile(STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), + EmStrongItem(re.compile(STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), + EmStrongItem(re.compile(EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em') ] diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index 3a317a521..78416221c 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -64,6 +64,7 @@ from __future__ import absolute_import from __future__ import unicode_literals from . import util +from collections import namedtuple import re try: # pragma: no cover from html import entities @@ -179,6 +180,10 @@ def dequote(string): return string +class EmStrongItem(namedtuple('EmStrongItem', ['pattern', 'builder', 'tags'])): + """Emphasis/strong pattern item.""" + + """ The pattern classes ----------------------------------------------------------------------------- @@ -443,11 +448,11 @@ class AsteriskProcessor(InlineProcessor): """Emphasis processor for handling strong and em matches inside asterisks.""" PATTERNS = [ - (re.compile(EM_STRONG_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), - (re.compile(STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), - (re.compile(STRONG_EM3_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), - (re.compile(STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), - (re.compile(EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em') + EmStrongItem(re.compile(EM_STRONG_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), + EmStrongItem(re.compile(STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), + EmStrongItem(re.compile(STRONG_EM3_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), + EmStrongItem(re.compile(STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), + EmStrongItem(re.compile(EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em') ] def build_single(self, m, tag, idx): @@ -511,11 +516,11 @@ def parse_sub_patterns(self, data, parent, last, idx): if self.compiled_re.match(data, pos): matched = False # See if the we can match an emphasis/strong pattern - for index, pattern in enumerate(self.PATTERNS): + for index, item in enumerate(self.PATTERNS): # Only evaluate patterns that are after what was used on the parent if index <= idx: continue - m = pattern[0].match(data, pos) + m = item.pattern.match(data, pos) if m: # Append child nodes to parent # Text nodes should be appended to the last @@ -527,7 +532,7 @@ def parse_sub_patterns(self, data, parent, last, idx): last.tail = text else: parent.text = text - el = self.build_element(m, pattern[1], pattern[2], index) + el = self.build_element(m, item.builder, item.tags, index) parent.append(el) last = el # Move our position past the matched hunk @@ -565,12 +570,12 @@ def handleMatch(self, m, data): start = None end = None - for index, pattern in enumerate(self.PATTERNS): - m1 = pattern[0].match(data, m.start(0)) + for index, item in enumerate(self.PATTERNS): + m1 = item.pattern.match(data, m.start(0)) if m1: start = m1.start(0) end = m1.end(0) - el = self.build_element(m1, pattern[1], pattern[2], index) + el = self.build_element(m1, item.builder, item.tags, index) break return el, start, end @@ -579,11 +584,11 @@ class UnderscoreProcessor(AsteriskProcessor): """Emphasis processor for handling strong and em matches inside underscores.""" PATTERNS = [ - (re.compile(EM_STRONG2_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), - (re.compile(STRONG_EM2_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), - (re.compile(SMART_STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), - (re.compile(SMART_STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), - (re.compile(SMART_EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em') + EmStrongItem(re.compile(EM_STRONG2_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'), + EmStrongItem(re.compile(STRONG_EM2_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'), + EmStrongItem(re.compile(SMART_STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'), + EmStrongItem(re.compile(SMART_STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'), + EmStrongItem(re.compile(SMART_EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em') ] From bef1af49022b2b692a3f433362d8ee9d555c9823 Mon Sep 17 00:00:00 2001 From: facelessuser Date: Sat, 30 Mar 2019 09:37:49 -0600 Subject: [PATCH 5/9] Add nested emphasis test and ignore coverage in legacy inline tags --- markdown/inlinepatterns.py | 4 ++-- tests/test_syntax/inline/test_emphasis.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index 78416221c..030cf9b05 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -352,7 +352,7 @@ def __init__(self, pattern, tag): InlineProcessor.__init__(self, pattern) self.tag = tag - def handleMatch(self, m, data): + def handleMatch(self, m, data): # pragma: no cover el = util.etree.Element(self.tag) el.text = m.group(2) return el, m.start(0), m.end(0) @@ -408,7 +408,7 @@ class DoubleTagInlineProcessor(SimpleTagInlineProcessor): Useful for strong emphasis etc. """ - def handleMatch(self, m, data): + def handleMatch(self, m, data): # pragma: no cover tag1, tag2 = self.tag.split(",") el1 = util.etree.Element(tag1) el2 = util.etree.SubElement(el1, tag2) diff --git a/tests/test_syntax/inline/test_emphasis.py b/tests/test_syntax/inline/test_emphasis.py index aa8c2c04e..ba01d708b 100644 --- a/tests/test_syntax/inline/test_emphasis.py +++ b/tests/test_syntax/inline/test_emphasis.py @@ -108,3 +108,10 @@ def test_complex_emphasis_smart_underscore_mid_word(self): 'This is text __bold_italic bold___ with more text', '

This is text __bold_italic bold___ with more text

' ) + + def test_nested_emphasis(self): + + self.assertMarkdownRenders( + 'This text is **bold *italic* *italic* bold**', + '

This text is bold italic italic bold

' + ) From e6fc48a9e02026be05e22ec86569577cb68247f6 Mon Sep 17 00:00:00 2001 From: facelessuser Date: Sat, 30 Mar 2019 12:27:34 -0600 Subject: [PATCH 6/9] Experiment by forcing tox to match last known passing version 3.7.0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2cade8658..d7b72fdf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ addons: install: # NOTE: setuptools needs to be installed explicitly for py34 (trusty). - - pip install 'setuptools>=36' tox + - pip install 'setuptools>=36' 'tox==3.7.0' script: - tox From 6889761070c7692cd7396a716303a53616a6b549 Mon Sep 17 00:00:00 2001 From: facelessuser Date: Sat, 31 Aug 2019 20:00:09 -0600 Subject: [PATCH 7/9] Revert "Experiment by forcing tox to match last known passing version 3.7.0" This reverts commit 91873ae3371f8ee16b1a55b975616ed95052052a. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d7b72fdf2..2cade8658 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ addons: install: # NOTE: setuptools needs to be installed explicitly for py34 (trusty). - - pip install 'setuptools>=36' 'tox==3.7.0' + - pip install 'setuptools>=36' tox script: - tox From 7a097e62a210762bfe4892110a0595536ce8ffbf Mon Sep 17 00:00:00 2001 From: facelessuser Date: Sun, 1 Sep 2019 19:24:18 -0600 Subject: [PATCH 8/9] Add new release notes for 3.2 --- docs/change_log/release-3.2.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docs/change_log/release-3.2.md diff --git a/docs/change_log/release-3.2.md b/docs/change_log/release-3.2.md new file mode 100644 index 000000000..872354f0b --- /dev/null +++ b/docs/change_log/release-3.2.md @@ -0,0 +1,12 @@ +title: Release Notes for v3.2 + +# Python-Markdown 3.2 Release Notes + +Python-Markdown version 3.2 supports Python versions 2.7, 3.5, 3.6, 3.7, +PyPy and PyPy3. + +## Bug fixes + +The following bug fixes are included in the 3.2 release: + +* Refactor bold and italic logic in order to solve complex nesting issues (#792). From ced6377df86e0a7aa50399ff3458cb863e3404fb Mon Sep 17 00:00:00 2001 From: facelessuser Date: Mon, 2 Sep 2019 15:20:31 -0600 Subject: [PATCH 9/9] Note backwards incompatible changes --- docs/change_log/release-3.2.md | 22 ++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 23 insertions(+) diff --git a/docs/change_log/release-3.2.md b/docs/change_log/release-3.2.md index 872354f0b..917a8161b 100644 --- a/docs/change_log/release-3.2.md +++ b/docs/change_log/release-3.2.md @@ -5,6 +5,28 @@ title: Release Notes for v3.2 Python-Markdown version 3.2 supports Python versions 2.7, 3.5, 3.6, 3.7, PyPy and PyPy3. +## Backwards-incompatible changes + +## `em` and `strong` inline processor changes + +In order to fix issue #792, `em`/`strong` inline processors were refactored. This +translated into removing many of the existing inline processors that handled this +logic: + +* `em_strong` +* `strong` +* `emphasis` +* `strong2` +* `emphasis` + +These processors were replaced with two new ones: + +* `em_strong` +* `em_strong2` + +The [`legacy_em`](../extensions/legacy_em.md) extension was also modified with new, +refactored logic and simply overrides the `em_strong2` inline processor. + ## Bug fixes The following bug fixes are included in the 3.2 release: diff --git a/mkdocs.yml b/mkdocs.yml index 448ce761f..41e8c7df2 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -40,6 +40,7 @@ nav: - Test Tools: test_tools.md - Contributing to Python-Markdown: contributing.md - Change Log: change_log/index.md + - Release Notes for v.3.2: change_log/release-3.2.md - Release Notes for v.3.1: change_log/release-3.1.md - Release Notes for v.3.0: change_log/release-3.0.md - Release Notes for v.2.6: change_log/release-2.6.md