Skip to content

Commit

Permalink
Fix list patterns in FancyList (#2576)
Browse files Browse the repository at this point in the history
Prevent detecting a list when a line starts with `.` or `)`.

Fixes #2575
  • Loading branch information
facelessuser authored Jan 21, 2025
1 parent b5d3826 commit 2aba189
Show file tree
Hide file tree
Showing 4 changed files with 31 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.14.2

- **FIX**: FancyLists: Fix case were lists could be falsely created when a line started with `.` or `)`.

## 10.14.1

- **FIX**: MagicLink: Ensure that repo names that start with `.` are handled correctly.
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, 14, 1, "final")
__version_info__ = Version(10, 14, 2, "final")
__version__ = __version_info__._get_canonical()
3 changes: 2 additions & 1 deletion pymdownx/fancylists.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def __init__(self, parser, config):
(?:C[MD]|D(?:C{0,4}|C{5}\b)|(?:C{0,9}|C{10}\b))
(?:X[CL]|L(?:X{0,4}|X{5}\b)|(?:X{0,9}|X{10}\b))
(?:I[XV]|V(?:I{0,4}|I{5}\b)|(?:I{0,9}|I{10}\b))
| m*
| (?=[ivxlcdm])
m*
(?:c[md]|d(?:c{0,4}|c{5}\b)|(?:c{0,9}|c{10}\b))
(?:x[cl]|l(?:x{0,4}|x{5}\b)|(?:x{0,9}|x{10}\b))
(?:i[xv]|v(?:i{0,4}|i{5}\b)|(?:i{0,9}|i{10}\b))
Expand Down
24 changes: 24 additions & 0 deletions tests/test_extensions/test_fancylists.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ class TestFancyLists(util.MdCase):
extension = ['pymdownx.fancylists', 'pymdownx.saneheaders']
extension_configs = {}

def test_fail_case(self):
"""Test failed case."""

self.check_markdown(
"""
1. foo
. bar
1) foo
) bar
""",
"""
<ol type="1">
<li>foo
. bar</li>
</ol>
<ol type="1">
<li>foo
) bar</li>
</ol>
""",
True
)

def test_unordered(self):
"""Test unordered lists."""

Expand Down

0 comments on commit 2aba189

Please sign in to comment.