Metadata-Version: 2.4
Name: markdown-math-solver
Version: 1.0.0
Summary: Process Python code embedded in LaTeX math blocks in Markdown files
License-Expression: MIT
Project-URL: Homepage, https://github.com/abdxdev/markdown-math-solver
Project-URL: Issues, https://github.com/abdxdev/markdown-math-solver/issues
Keywords: markdown,latex,katex,math,solver,sympy
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Text Processing :: Markup :: Markdown
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: sympy>=1.12
Requires-Dist: antlr4-python3-runtime==4.11
Dynamic: license-file

# Markdown Math Solver

A command-line tool that **processes Python code embedded in LaTeX math blocks** in Markdown files. Define expressions, bind parameters, evaluate math, and generate computed results.

## Installation

```bash
pip install markdown-math-solver
```

Or install from source:

```bash
git clone https://github.com/yourusername/markdown-math-solver.git
cd markdown-math-solver
pip install .
```

For development:

```bash
pip install -e .
```

## Quick Start

### 1. Create a Markdown file with embedded `py()` blocks

```markdown
# My Math Document

$5 + 3 py(mySum = THIS)$

Result: $py(ReplaceThis(mySum()))$
```

### 2. Run the tool

```bash
markdown-math-solver yourfile.md
```

### 3. Check output

Your results will be in `yourfile.output.md`:

```markdown
# My Math Document

$5 + 3$

Result: $8$
```

## Usage

```
markdown-math-solver [-h] [-o OUTPUT] [-v] file
```

| Argument          | Description                                     |
| ----------------- | ----------------------------------------------- |
| `file`            | Path to the Markdown file to process            |
| `-o`, `--output`  | Output file path (default: `<input>.output.md`) |
| `-v`, `--version` | Show version number                             |
| `-h`, `--help`    | Show help message                               |

### Examples

```bash
# Basic usage (output to yourfile.output.md)
markdown-math-solver yourfile.md

# Custom output path
markdown-math-solver yourfile.md -o result.md

# Check version
markdown-math-solver --version
```

## Syntax Overview

| Syntax                   | Description                                      |
| ------------------------ | ------------------------------------------------ |
| `expr py(name = THIS)`   | Store the expression before `py()` as `name`     |
| `param(var)`             | Parameter placeholder in expressions             |
| `py(ReplaceThis(value))` | Replace the `py(...)` with `value`               |
| `py(ReplaceAll(value))`  | Replace the entire `$...$` block with `value`    |
| `name.bind(var=value)`   | Bind parameters to expression                    |
| `name.unbind()`          | Reset to original with all `param(var)` restored |
| `name(var=value)`        | Bind and evaluate                                |
| `name()`                 | Evaluate expression                              |
| `THIS`                   | Reference to LaTeX before `py()` in same block   |

## Python API

You can also use it as a library:

```python
from markdown_math_solver import process_markdown, store

store.clear()
result = process_markdown("$1+2 py(x = THIS)$ equals $py(ReplaceThis(x()))$")
print(result)  # $1+2$ equals $3$
```

## License

MIT
