Skip to content

Commit

Permalink
Fix an issue where attrs would not handle braces in attributes proper…
Browse files Browse the repository at this point in the history
…ly (#2210)

* Fix an issue where attrs would not handle braces in attributes properly

* Align comments
  • Loading branch information
facelessuser authored Oct 17, 2023
1 parent 3005982 commit adf13e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 10.3.1

- **FIX**: SuperFences: Fix an issue where attributes would not handle braces in attributes properly.

## 10.3

- **NEW**: Officially support Python 3.12.
Expand Down
2 changes: 1 addition & 1 deletion pymdownx/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ def parse_version(ver, pre=False):
return Version(major, minor, micro, release, pre, post, dev)


__version_info__ = Version(10, 3, 0, "final")
__version_info__ = Version(10, 3, 1, "final")
__version__ = __version_info__._get_canonical()
2 changes: 1 addition & 1 deletion pymdownx/superfences.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
RE_NESTED_FENCE_START = re.compile(
r'''(?x)
(?P<fence>~{3,}|`{3,})[ \t]* # Fence opening
(?:(\{(?P<attrs>[^\}\n]*)\})?| # Optional attributes or
(?:(\{(?P<attrs>[^\n]*)\})?| # Optional attributes or
(?:\.?(?P<lang>[\w#.+-]*))?[ \t]* # Language
(?P<options>
(?:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_extensions/test_superfences.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,22 @@ class TestSuperFencesClassesIdsAttrList(util.MdCase):
extension = ['pymdownx.superfences', 'markdown.extensions.attr_list']
extension_configs = {}

def test_attribute_lists_with_braces(self):
"""Test attribute lists with braces."""

self.check_markdown(
R'''
``` { .c data-copy="int main() { return 0; }" }
Try copying me for some C code
```
''',
R'''
<div class="highlight" data-copy="int main() { return 0; }"><pre><span></span><code><span class="n">Try</span><span class="w"> </span><span class="n">copying</span><span class="w"> </span><span class="n">me</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">some</span><span class="w"> </span><span class="n">C</span><span class="w"> </span><span class="n">code</span>
</code></pre></div>
''', # noqa: E501
True
)

def test_classes(self):
"""Test extra classes."""

Expand Down

0 comments on commit adf13e0

Please sign in to comment.