Skip to main content

Process Python code embedded in LaTeX math blocks in Markdown files

Project description

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

pip install markdown-math-solver

Or install from source:

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

For development:

pip install -e .

Quick Start

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

# My Math Document

$5 + 3 py(mySum = THIS)$

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

2. Run the tool

markdown-math-solver yourfile.md

3. Check output

Your results will be in yourfile.output.md:

# 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

# 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:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markdown_math_solver-1.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markdown_math_solver-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file markdown_math_solver-1.0.0.tar.gz.

File metadata

  • Download URL: markdown_math_solver-1.0.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for markdown_math_solver-1.0.0.tar.gz
Algorithm Hash digest
SHA256 62edf771ede56c30682abffff6ad5e8e01dbb50cf4f2f894a50b68f366511b07
MD5 30f9780484bab31c194ce5fbf767f41e
BLAKE2b-256 387d4828e6a54c135c27ed8d84186511ca44871a542a4e485eb2d1d2af05281b

See more details on using hashes here.

File details

Details for the file markdown_math_solver-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for markdown_math_solver-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab413a55afe9a0ee21aac18ad118d2032c4226f210bc4815d2a06e25fa5dddc1
MD5 c1ab5b37730b4b69b75beb7cac340ba3
BLAKE2b-256 0a1813d168d733f3b8a95b8b31e9e3a716bd951c0430eafe7548ef2984600021

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page