nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Python-Markdown/markdown
Pull request #672 (2018-06-19 14:52:21)

Implement reset() for Meta extension
This is a fix for #671 

facelessuser: Make sure to address the failing flake8 lint errors that are occurring on Travis-CI.  You can ignore the Py3.3 failures as that is being removed moving forward.

Patch:
diff --git a/markdown/extensions/meta.py b/markdown/extensions/meta.py
index cafad4a..2c2c8e3 100644
--- a/markdown/extensions/meta.py
+++ b/markdown/extensions/meta.py
@@ -36,10 +36,15 @@ class MetaExtension (Extension):
 
     def extendMarkdown(self, md, md_globals):
         """ Add MetaPreprocessor to Markdown instance. """
+        md.registerExtension(self)
+        self.md = md
         md.preprocessors.add("meta",
                              MetaPreprocessor(md),
                              ">normalize_whitespace")
 
+    def reset(self):
+        self.md.Meta = {}
+
 
 class MetaPreprocessor(Preprocessor):
     """ Get Meta-Data. """


Test patch:
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index aee9bac..35eaf1d 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -454,6 +454,20 @@ The body. This is paragraph one.'''
         self.assertEqual(self.md.convert(text), '')
         self.assertEqual(self.md.Meta, {'title': ['No newline']})
 
+    def testMetaDataReset(self):
+        """ Test that reset call remove Meta entirely """
+
+        text = '''Title: A Test Doc.
+Author: Waylan Limberg
+        John Doe
+Blank_Data:
+
+The body. This is paragraph one.'''
+        self.md.convert(text)
+
+        self.md.reset()
+        self.assertEqual(self.md.Meta, {})
+
 
 class TestWikiLinks(unittest.TestCase):
     """ Test Wikilinks Extension. """
Repository: Python-Markdown/markdown
Pull request #1092 (2020-12-30 09:52:59)

Don't wrongly discard text immediately before an admonition
```markdown
foo
**foo**
!!! note "Admonition"
```
    
In the previous state, the "foo" text would be completely obliterated, but now it will be kept, and the admonition will be rendered as well.


oprypin: This is a bug, but it's not 100% obvious what behavior is the correct one.
This PR is the **more pragmatic one**, and https://github.com/Python-Markdown/markdown/pull/1093 is an alternative. One of the two should be chosen.

Patch:
diff --git a/docs/change_log/index.md b/docs/change_log/index.md
index 90ed1a3..b9a1a90 100644
--- a/docs/change_log/index.md
+++ b/docs/change_log/index.md
@@ -8,6 +8,7 @@ Under development: version 3.3.4 (a bug-fix release).
 * Properly parse unclosed tags in code spans (#1066).
 * Properly parse processing instructions in md_in_html (#1070).
 * Properly parse code spans in md_in_html (#1069).
+* Preserve text immediately before an admonition (#1092).
 * Simplified regex for HTML placeholders (#928) addressing (#932).
 
 Oct 25, 2020: version 3.3.3 (a bug-fix release).
diff --git a/markdown/extensions/admonition.py b/markdown/extensions/admonition.py
index 01f9940..916d931 100644
--- a/markdown/extensions/admonition.py
+++ b/markdown/extensions/admonition.py
@@ -113,6 +113,8 @@ class AdmonitionProcessor(BlockProcessor):
         m = self.RE.search(block)
 
         if m:
+            if m.start() > 0:
+                self.parser.parseBlocks(parent, [block[:m.start()]])
             block = block[m.end():]  # removes the first line
         else:
             sibling, block = self.get_sibling(parent, block)


Test patch:
diff --git a/tests/test_syntax/extensions/test_admonition.py b/tests/test_syntax/extensions/test_admonition.py
index 39be997..b8d4f06 100644
--- a/tests/test_syntax/extensions/test_admonition.py
+++ b/tests/test_syntax/extensions/test_admonition.py
@@ -192,3 +192,24 @@ class TestAdmonition(TestCase):
             ),
             extensions=['admonition', 'def_list']
         )
+
+    def test_with_preceding_text(self):
+        self.assertMarkdownRenders(
+            self.dedent(
+                '''
+                foo
+                **foo**
+                !!! note "Admonition"
+                '''
+            ),
+            self.dedent(
+                '''
+                <p>foo
+                <strong>foo</strong></p>
+                <div class="admonition note">
+                <p class="admonition-title">Admonition</p>
+                </div>
+                '''
+            ),
+            extensions=['admonition']
+        )
Repository: Python-Markdown/markdown
Pull request #1161 (2021-07-27 10:21:43)

Better toc detection 
Fix for issue #1160

See issue, and code comment for more details.

facelessuser: I'm not familiar with the "checklinks" failures, so I would ignore them as it seems to be a failure with a recent update to the checker.

I would, however, add a note in the changelog for the fix in order to resolve the "require_changelog" failure.

Patch:
diff --git a/docs/change_log/index.md b/docs/change_log/index.md
index aed19e3..fe40094 100644
--- a/docs/change_log/index.md
+++ b/docs/change_log/index.md
@@ -6,6 +6,7 @@ Python-Markdown Change Log
 Under development: version 3.3.5 (a bug-fix release).
 
 * Make the `slugify_unicode` function not remove diacritical marks (#1118).
+* Fix `[toc]` detection when used with `nl2br` extension (#1160)
 
 Feb 24, 2021: version 3.3.4 (a bug-fix release).
 
diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py
index 965ba4a..e4dc378 100644
--- a/markdown/extensions/toc.py
+++ b/markdown/extensions/toc.py
@@ -195,7 +195,12 @@ class TocTreeprocessor(Treeprocessor):
             # To keep the output from screwing up the
             # validation by putting a <div> inside of a <p>
             # we actually replace the <p> in its entirety.
-            if c.text and c.text.strip() == self.marker:
+
+            # The <p> element may contain more than a single text content
+            # (nl2br can introduce a <br>). In this situation, c.text returns
+            # the very first content, ignore children contents or tail content.
+            # len(c) == 0 is here to ensure there is only text in the <p>.
+            if c.text and c.text.strip() == self.marker and len(c) == 0:
                 for i in range(len(p)):
                     if p[i] == c:
                         p[i] = elem


Test patch:
diff --git a/tests/test_syntax/extensions/test_toc.py b/tests/test_syntax/extensions/test_toc.py
index 83c990f..6871340 100644
--- a/tests/test_syntax/extensions/test_toc.py
+++ b/tests/test_syntax/extensions/test_toc.py
@@ -21,6 +21,7 @@ License: BSD (see LICENSE.md for details).
 
 from markdown.test_tools import TestCase
 from markdown.extensions.toc import TocExtension
+from markdown.extensions.nl2br import Nl2BrExtension
 
 
 class TestTOC(TestCase):
@@ -561,3 +562,10 @@ class TestTOC(TestCase):
             '</h1>',                                                                       # noqa
             extensions=[TocExtension(permalink=True)]
         )
+
+    def testNl2brCompatibility(self):
+        self.assertMarkdownRenders(
+            '[TOC]\ntext',
+            '<p>[TOC]<br />\ntext</p>',
+            extensions=[TocExtension(), Nl2BrExtension()]
+        )
Repository: Python-Markdown/markdown
Pull request #1254 (2022-05-12 02:37:40)

Use `@deprecated` for Registry.add()
Clean the redundancy codes.


Patch:
diff --git a/markdown/util.py b/markdown/util.py
index 46cfe68..c31f6e2 100644
--- a/markdown/util.py
+++ b/markdown/util.py
@@ -423,6 +423,7 @@ class Registry:
         else:
             raise KeyError('Cannot delete key {}, not registered.'.format(key))
 
+    @deprecated('Use the `register` method instead.')
     def add(self, key, value, location):
         """ Register a key by location. """
         if len(self) == 0:
@@ -459,12 +460,6 @@ class Registry:
             raise ValueError('Not a valid location: "%s". Location key '
                              'must start with a ">" or "<".' % location)
         self.register(value, key, priority)
-        warnings.warn(
-            'Using the add method to register a processor or pattern is deprecated. '
-            'Use the `register` method instead.',
-            DeprecationWarning,
-            stacklevel=2,
-        )
 
 
 def __getattr__(name):


Test patch:
diff --git a/tests/test_apis.py b/tests/test_apis.py
index 16f3088..c977e6b 100644
--- a/tests/test_apis.py
+++ b/tests/test_apis.py
@@ -420,7 +420,7 @@ class RegistryTests(unittest.TestCase):
                 r.add('f', Item('f'), 'badlocation')
 
             # Check the warnings
-            self.assertEqual(len(w), 7)
+            self.assertEqual(len(w), 8)
             self.assertTrue(all(issubclass(x.category, DeprecationWarning) for x in w))
Repository: Python-Markdown/markdown
Pull request #1256 (2022-05-13 01:26:39)

Use `@deprecated` for __setitem__ and __delitem__ of Registry.


Patch:
diff --git a/markdown/util.py b/markdown/util.py
index 46cfe68..4c690c0 100644
--- a/markdown/util.py
+++ b/markdown/util.py
@@ -387,15 +387,10 @@ class Registry:
 
     # Deprecated Methods which provide a smooth transition from OrderedDict
 
+    @deprecated('Use the `register` method instead.')
     def __setitem__(self, key, value):
         """ Register item with priority 5 less than lowest existing priority. """
         if isinstance(key, str):
-            warnings.warn(
-                'Using setitem to register a processor or pattern is deprecated. '
-                'Use the `register` method instead.',
-                DeprecationWarning,
-                stacklevel=2,
-            )
             if key in self:
                 # Key already exists, replace without altering priority
                 self._data[key] = value
@@ -410,19 +405,15 @@ class Registry:
         else:
             raise TypeError
 
+    @deprecated('Use the `deregister` method instead.')
     def __delitem__(self, key):
         """ Deregister an item by name. """
         if key in self:
             self.deregister(key)
-            warnings.warn(
-                'Using del to remove a processor or pattern is deprecated. '
-                'Use the `deregister` method instead.',
-                DeprecationWarning,
-                stacklevel=2,
-            )
         else:
             raise KeyError('Cannot delete key {}, not registered.'.format(key))
 
+    @deprecated('Use the `register` method instead.')
     def add(self, key, value, location):
         """ Register a key by location. """
         if len(self) == 0:
@@ -459,12 +450,6 @@ class Registry:
             raise ValueError('Not a valid location: "%s". Location key '
                              'must start with a ">" or "<".' % location)
         self.register(value, key, priority)
-        warnings.warn(
-            'Using the add method to register a processor or pattern is deprecated. '
-            'Use the `register` method instead.',
-            DeprecationWarning,
-            stacklevel=2,
-        )
 
 
 def __getattr__(name):


Test patch:
diff --git a/tests/test_apis.py b/tests/test_apis.py
index 16f3088..7a3c735 100644
--- a/tests/test_apis.py
+++ b/tests/test_apis.py
@@ -358,7 +358,7 @@ class RegistryTests(unittest.TestCase):
             self.assertEqual(list(r), [])
 
             # Check the warnings
-            self.assertEqual(len(w), 3)
+            self.assertEqual(len(w), 4)
             self.assertTrue(all(issubclass(x.category, DeprecationWarning) for x in w))
 
     def testRegistrySlice(self):
@@ -420,7 +420,7 @@ class RegistryTests(unittest.TestCase):
                 r.add('f', Item('f'), 'badlocation')
 
             # Check the warnings
-            self.assertEqual(len(w), 7)
+            self.assertEqual(len(w), 8)
             self.assertTrue(all(issubclass(x.category, DeprecationWarning) for x in w))