-
Notifications
You must be signed in to change notification settings - Fork 55
Description
Describe the bug
context
When I try and format a simple text string using mdformat.text(), i get an error. Here's my simplified test case:
import mdformat
clean = mdformat.text("** hello World*")
print(clean)expectation
I expected to see my horribly malformed Markdown string throw an error or somehow be prettified.
bug
But instead an unexpected error happens
Here's an error message I ran into...
% uv run mdformat-test.py
Traceback (most recent call last):
File "/Users/peterdehaan/Dev/python-test/feedparser-test/mdformat-test.py", line 1, in <module>
import mdformat
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/__init__.py", line 4, in <module>
from mdformat._api import file, text
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/_api.py", line 4, in <module>
from mdformat._util import EMPTY_MAP, build_mdit
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/_util.py", line 8, in <module>
import mdformat.plugins
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/plugins.py", line 7, in <module>
from mdformat.renderer.typing import RendererFunc
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/renderer/__init__.py", line 8, in <module>
from markdown_it.common.normalize_url import unescape_string
ImportError: cannot import name 'unescape_string' from 'markdown_it.common.normalize_url' (/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/markdown_it/common/normalize_url.py)I'm a bit new to Python, but here's my pyproject.toml, since I assume that'd be the first or second question:
[project]
name = "feedparser-test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"feedparser>=6.0.11",
"markdown-it-py>=4.0.0",
"markdownify>=1.2.0",
"mdformat>=0.6.0",
"mdit-py-plugins>=0.5.0",
"pydantic>=2.11.7",
"python-dateutil>=2.9.0.post0",
"python-slugify>=8.0.4",
]Reproduce the bug
import mdformat
clean = mdformat.text("** hello World*")
print(clean)But I think this is possibly a conflict between mdformat and "markdown-it-py>=4.0.0"
List your environment
Oddly, it seems like calling --version throws the same error. Digging into the .venv/lib site packages, it seems like I'm on 0.6.0 which seems... old.
mdformat --version
Traceback (most recent call last):
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/bin/mdformat", line 4, in <module>
from mdformat.__main__ import run
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/__init__.py", line 4, in <module>
from mdformat._api import file, text
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/_api.py", line 4, in <module>
from mdformat._util import EMPTY_MAP, build_mdit
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/_util.py", line 8, in <module>
import mdformat.plugins
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/plugins.py", line 7, in <module>
from mdformat.renderer.typing import RendererFunc
File "/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/mdformat/renderer/__init__.py", line 8, in <module>
from markdown_it.common.normalize_url import unescape_string
ImportError: cannot import name 'unescape_string' from 'markdown_it.common.normalize_url' (/Users/peterdehaan/Dev/python-test/feedparser-test/.venv/lib/python3.13/site-packages/markdown_it/common/normalize_url.py)Looks like ths is a comflict w/ markdown-it-py when I try and force some updates to mdformat==0.7.22:
% uv add "mdformat>=0.7.22" --upgrade-package mdformat
× No solution found when resolving dependencies:
╰─▶ Because only mdformat<=0.7.22 is available and mdformat==0.7.22 depends on markdown-it-py>=1.0.0,<4.0.0, we can conclude that mdformat>=0.7.22 depends on markdown-it-py>=1.0.0,<4.0.0.
And because your project depends on markdown-it-py>=4.0.0 and mdformat>=0.7.22, we can conclude that your project's requirements are unsatisfiable.
help: If you want to add the package regardless of the failed resolution, provide the `--frozen` flag to skip locking and syncing.