Skip to content

Commit e2675e4

Browse files
authored
Merge pull request #1 from dynstat/dev
Dev
2 parents 300768d + df9240a commit e2675e4

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
here = os.path.abspath(os.path.dirname(__file__))
77

8-
# Get the long description from the README file
9-
with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
8+
# Get the long description from the README file (match actual filename)
9+
with open(os.path.join(here, "Readme.md"), encoding="utf-8") as f:
1010
long_description = f.read()
1111

1212
# Get the version from the __init__.py file
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.1.5"
1+
__version__ = "1.1.6"

src/markdown_equations_fixer/cli.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ def __init__(self, dry_run: bool = False, verbose: bool = False):
3333
def fix_equations(self, content: str) -> str:
3434
"""Fix mathematical equations in markdown content."""
3535
try:
36+
# Pattern to match block equations delimited by standalone lines with [ and ]
37+
# Example:
38+
# [\n
39+
# equation content\n
40+
# ]
41+
# This converts to:
42+
# $$\n
43+
# equation content\n
44+
# $$
45+
content = re.sub(
46+
r"(?ms)^\[\s*$\n(.*?)\n^\]\s*$",
47+
r"$$\n\1\n$$",
48+
content,
49+
)
50+
3651
# Pattern to match block equations: \[ ... \]
3752
# The re.DOTALL flag allows the match to span multiple lines.
3853
content = re.sub(

src/test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def test_fix_inline_equations(fixer):
4242
)
4343

4444

45+
def test_fix_bracket_line_block(fixer):
46+
"""Test fixing blocks where [ and ] are on their own lines."""
47+
input_text = "[\nE=mc^2\n]"
48+
expected = "$$\nE=mc^2\n$$"
49+
assert fixer.fix_equations(input_text) == expected
50+
51+
4552
def test_validate_paths_recursive(temp_dir):
4653
"""Test recursive path validation."""
4754
paths = [temp_dir]

0 commit comments

Comments
 (0)