Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: "https://github.com/ambv/black"
rev: 23.1.0
rev: 25.1.0
hooks:
- id: black-jupyter
language_version: python3
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.259"
rev: "v0.11.2"
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.1.1"
rev: "v1.15.0"
hooks:
- id: mypy
additional_dependencies: ["types-PyYAML", "types-requests", "types-setuptools"]
5 changes: 4 additions & 1 deletion markdown_code_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
echo "Hello, world!"
```
Which will similarly print the output of the code block between next to the output markers.

"""

from __future__ import annotations
Expand Down Expand Up @@ -134,11 +135,12 @@ def execute_code(
exec(full_code, context) # noqa: S102
output = string.getvalue().split("\n")
elif language == "bash":
result = subprocess.run(
result = subprocess.run( # noqa: S602
full_code,
capture_output=True,
text=True,
shell=True,
check=False,
)
output = result.stdout.split("\n")
else:
Expand Down Expand Up @@ -304,6 +306,7 @@ def process_markdown(content: list[str], *, verbose: bool = False) -> list[str]:
-------
list[str]
A modified list of Markdown-formatted strings with code block output inserted.

"""
assert isinstance(content, list), "Input must be a list"
state = ProcessingState()
Expand Down
9 changes: 1 addition & 8 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the markdown_code_runner app."""

from __future__ import annotations

import argparse
Expand Down Expand Up @@ -748,10 +749,6 @@ def test_patterns() -> None:
),
("```python markdown-code-runner", {"language": "python"}),
("This is a regular text line", {}),
(
"```javascript markdown-code-runner filename=test.js",
{"language": "javascript", "filename": "test.js"},
),
(
"```python markdown-code-runner arg=test.js",
{"language": "python", "arg": "test.js"},
Expand All @@ -760,10 +757,6 @@ def test_patterns() -> None:
"```javascript markdown-code-runner filename=test.js arg2=1",
{"language": "javascript", "filename": "test.js", "arg2": "1"},
),
(
"```python markdown-code-runner",
{"language": "python"},
),
(
"```python markdown-code-runner arg1=value1 arg2=value2 arg3=value3",
{
Expand Down
Loading