harbor run -t swe-rebench/facelessuser__pymdown-extensions-2576harbor download swe-rebench/facelessuser__pymdown-extensions-2576FancyLists: KeyError when the list number is missing
With FancyLists, when the list number is missing (but the . or ) is present), parsing will throw a KeyError. Example inputs:
1. foo
. bar
1) foo
) bar
Error:
% python3 test.py
Traceback (most recent call last):
File "/Users/USER/Downloads/test.py", line 5, in <module>
html = markdown.markdown("1. foo\n. bar", extensions=["pymdownx.fancylists", "pymdownx.saneheaders"])
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/markdown/core.py", line 482, in markdown
return md.convert(text)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/markdown/core.py", line 357, in convert
root = self.parser.parseDocument(self.lines).getroot()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/markdown/blockparser.py", line 117, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/markdown/blockparser.py", line 136, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/markdown/blockparser.py", line 158, in parseBlocks
if processor.run(parent, blocks) is not False:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pymdownx/fancylists.py", line 214, in run
attrib = {'type': self.OL_TYPES[fancy_type], '__fancylist': fancy_type}
KeyError: 'dot-'
#!/usr/bin/env python3
import markdown
html = markdown.markdown("1. foo\n. bar", extensions=["pymdownx.fancylists", "pymdownx.saneheaders"])
print(html) # KeyError: 'dot-'
html = markdown.markdown("1) foo\n) bar", extensions=["pymdownx.fancylists", "pymdownx.saneheaders"])
print(html) # KeyError: 'paren-'