Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Revert "Update pygments version constraint in pyproject.toml" (#8979)

Myles Scolnick82b0a68ed2e1
diff --git a/Makefile b/Makefile
index 4f654e56a0..7acf0ff501 100644
--- a/Makefile
+++ b/Makefile
@@ -138,8 +138,7 @@ py-snapshots:
uv run --group test pytest \
tests/_server/templates/test_templates.py \
tests/_server/api/endpoints/test_export.py \
- tests/test_api.py \
- tests/test_project_dependencies.py
+ tests/test_api.py
##############
# Packaging #
diff --git a/marimo/_output/md.py b/marimo/_output/md.py
index 0b1c1efb15..8c47acfb76 100644
--- a/marimo/_output/md.py
+++ b/marimo/_output/md.py
@@ -35,7 +35,7 @@ class PyconDetectorExtension(markdown.Extension):
def extendMarkdown(self, md: markdown.Markdown) -> None:
"""Add the preprocessor to the markdown instance."""
processor = PyconDetectorPreprocessor(md)
- md.preprocessors.register(processor, "pycon_detector", 175)
+ md.preprocessors.register(processor, "pycon_detector", 30)
class PyconDetectorPreprocessor(markdown.preprocessors.Preprocessor):
@@ -53,12 +53,9 @@ class PyconDetectorPreprocessor(markdown.preprocessors.Preprocessor):
def __init__(self, md: markdown.Markdown) -> None:
super().__init__(md)
- # Pattern to match fenced code blocks (backreference \2 ensures the
- # closing fence matches the opening fence marker, preventing greedy
- # over-consumption of adjacent fenced blocks)
+ # Pattern to match fenced code blocks
self.fence_pattern = re.compile(
- r"^(\s*)(```+|~~~+)(\w*)\s*\n(.*?)^\s*\2\s*$",
- re.MULTILINE | re.DOTALL,
+ r"^(\s*)```(\w*)\s*\n(.*?)^(\s*)```\s*$", re.MULTILINE | re.DOTALL
)
def run(self, lines: list[str]) -> list[str]:
@@ -67,14 +64,14 @@ class PyconDetectorPreprocessor(markdown.preprocessors.Preprocessor):
def replace_fence(match: re.Match[str]) -> str:
indent = match.group(1)
- fence = match.group(2)
- language = match.group(3) or ""
- code = match.group(4)
+ language = match.group(2) or ""
+ code = match.group(3)
# Only process if no language is specified
- if not language and self._detect_pycon(code):
- # Replace with pycon language
- return f"{indent}{fence}pycon\n{code}{indent}{fence}"
+ if not language:
+ if self._detect_pycon(code):
+ # Replace with pycon language
+ return f"{indent}```pycon\n{code}{indent}```"
# Return original
return match.group(0)
@@ -253,10 +250,7 @@ class _md(Html):
text,
extensions=_get_extensions(),
extension_configs=_get_extension_configs(),
- )
- if html_text is None:
- html_text = ""
- html_text = html_text.strip()
+ ).strip()
# replace <p> tags with <span> as HTML doesn't allow nested <div>s in <p>s
html_text = html_text.replace(
"<p>", '<span class="paragraph">'
diff --git a/pyproject.toml b/pyproject.toml
index 898dcb9103..2cd03b1f38 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,10 +17,10 @@ dependencies = [
# compile markdown to html
"markdown>=3.6,<4",
# add features to markdown
- # 10.21.2+ required for compatibility with pygments>=2.20 (filename=None fix).
- "pymdown-extensions>=10.21.2,<11",
+ # Pinned to specific version for introduction of codeblock handling.
+ "pymdown-extensions>=10.15,<11",
# syntax highlighting of code in markdown
- "pygments>=2.20,<3",
+ "pygments>=2.19,<3",
# for reading, writing configs
"tomlkit>=0.12.0",
# for managing frontmatter headers in markdown
diff --git a/tests/snapshots/dependencies.txt b/tests/snapshots/dependencies.txt
index d5b610ef54..9524422e04 100644
--- a/tests/snapshots/dependencies.txt
+++ b/tests/snapshots/dependencies.txt
@@ -8,8 +8,8 @@ msgspec>=0.20.0
narwhals>=2.0.0
packaging
psutil>=5.0
-pygments>=2.20,<3
-pymdown-extensions>=10.21.2,<11
+pygments>=2.19,<3
+pymdown-extensions>=10.15,<11
pyyaml>=6.0.1
pyzmq>=27.1.0; python_version < '3.15'
starlette>=0.37.2